Repository navigation
Fix type checks - #164
Open
Bouni wants to merge 5 commits into
Open
Fix type checks#164Bouni wants to merge 5 commits into
Bouni wants to merge 5 commits into
Conversation
closeDatabase() resets the module-level handle to undefined, which the DB type did not permit. Type it as DB | undefined and route the invoice-numbering helpers through getDatabase() so they get a clear 'Database not initialized' error instead of a TypeError. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The zip upload is always built from an ArrayBuffer; stating that lets it be passed to new Blob() under TypeScript 5.7+ typed arrays. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Read the JWK 'kid' via Record<string, unknown> like the other non-standard fields, and return Uint8Array<ArrayBuffer> from b64urlToBytes so the signature is accepted as a BufferSource by crypto.subtle.verify. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Leftover copy of the templates controller that nothing imports; it no longer matched the Template type and broke the type check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
I have not tested OIDC due to the lack of an OIDC provider, someone willing to test this is highly appreciated! @KeplerAeroIT As you implemented this feature you are a hot candidate for testing 😅 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix backend type check errors
Running
deno check src/inbackend/reported 9 errors onmain. This PR fixes all of them, so the backend type check now passes cleanly.Behaviour stays the same. The changes are type annotations, one dead file removed, and a clearer error when the database isn't initialized.
Summary
database/init.ts:741Type 'undefined' is not assignable to type 'DB'dbasDB | undefineddatabase/init.ts:775–832(×5)'db' is possibly 'undefined'(follows from the change above)getDatabase()controllers/templates.ts:650Uint8Array<ArrayBufferLike>not assignable toBlobPartUint8Array<ArrayBuffer>utils/oidc.ts:196Property 'kid' does not exist on type 'JsonWebKey'kidthroughRecord<string, unknown>utils/oidc.ts:216Uint8Array<ArrayBufferLike>not assignable toBufferSourceUint8Array<ArrayBuffer>fromb64urlToBytescontrollers/templates_new.ts:23Property 'templateType' is missingCommits
1. Allow
dbto be undefined aftercloseDatabase()closeDatabase()resets the module-level handle toundefined, butdbwas declared as plainDB. It is nowDB | undefined.That made five direct
db.query(...)calls in the invoice-numbering helpers (getNumberingConfig,findMaxSequence,getCustomerNumber) fail the type check. They now go throughgetDatabase(), like the rest of the codebase. If the database isn't initialized, they now throwDatabase not initialized. Call initDatabase() first.instead ofTypeError: Cannot read properties of undefined (reading 'query'). Callers that wrap these calls intry/catchbehave as before.2. Type template zip data as
Uint8Array<ArrayBuffer>Since TypeScript 5.7,
Uint8Arrayis generic over its buffer type, and a bareUint8Array(Uint8Array<ArrayBufferLike>) may be backed by aSharedArrayBuffer.new Blob([...])doesn't accept that. Inroutes/admin.tsthe zip upload is always created withnew Uint8Array(arrayBuffer), so the parameter and the local variable are now typedUint8Array<ArrayBuffer>.3. Fix OIDC type errors in ID token verification
JsonWebKeyin the DOM lib doesn't declarekid. It is now read throughRecord<string, unknown>, which is how the next lines already readuseandalg.b64urlToBytesnow returnsUint8Array<ArrayBuffer>(which is whatUint8Array.fromproduces), so the signature is accepted as aBufferSourcebycrypto.subtle.verify.4. Remove unused
templates_new.tsThis was an old copy of the templates controller. Nothing imports it and it hasn't changed since early development. It no longer matched the
Templateinterface (notemplateType), so deleting it was the cleanest fix.Testing
cd backend && deno check src/→ 0 errors.zipin Settings still works🤖 Generated with Claude Code