-
Notifications
You must be signed in to change notification settings - Fork 364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TS declaration error: Type 'IndexNames<DBTypes, StoreName>' does not satisfy the constraint 'string' #311
Comments
I'm also getting this issue but only after upgrading typescript to 5.4.5 from 5.2.2: - X [ERROR] TS2344: Type 'IndexNames<DBTypes, StoreName>' does not satisfy the constraint 'string'.
|
+1 |
1 similar comment
+1 |
"@tempfix/idb": "^8.0.3" solves the problem for now by implementing the fix suggested above. |
+1 |
+1 |
1 similar comment
+1 |
+1 First of all, thanks for maintaining this neat project. We have an angular app which should be updated to v18. Angular v18 requires ts version to be >=5.4.0 <5.5.0. We are experiencing the same behaviour as described starting with ts 5.4.x, meaning our ng update is blocked. Is there any update on this? I see there is a fix by switching the to @tempfix/idb but if this is getting solved any time in the near future I rather stick with the original library. |
+1 |
Would you be so kind to make the PR? |
+1 |
+1 |
+1 |
2 similar comments
+1 |
+1 |
any update? |
Maybe someone may create the PR in tagging the issuer for credit? |
I tried to do that today, but only the dust folder is available from the npm package, so I don’t have the code for the fix.
…On Thu, Oct 3, 2024 at 9:48 AM, oliviercochet ***@***.***(mailto:On Thu, Oct 3, 2024 at 9:48 AM, oliviercochet <<a href=)> wrote:
Maybe someone may create the PR in tagging the issuer for credit?
—
Reply to this email directly, [view it on GitHub](#311 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/ABRT6JVM6AOQX3EKGMGXCM3ZZVDLNAVCNFSM6AAAAABG6KMCC6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOJRGQ3TIMRRGM).
You are receiving this because you commented.Message ID: ***@***.***>
|
Any updates ? I'm also blocked with angular 18v updating ... |
I asked Copilot - is it possible to solve this problem locally ? It proposed to override typing of the idb lib locally
However, this approach didn't work for me )). Maybe I'm doing something wrong, or perhaps locally overriding typings isn't possible at all? |
@uaKorona I don't see the PR for this, did you intend that with the branch? |
No, I’ve made a personal fork with a minimal fix and am waiting for the official resolution. |
FYI, as the original poster I considered creating a PR, but my confidence that it'll get merged is a bit on the low side as there hasn't been a commit since Dec 1, 2023. Anyway, suffering with this issue I got to know a very handy package that I'd like to share: patch-package. Just apply any hotfix directly in the node_modules folder and then run patch-package to create a patch file:
This will create a file
To apply the fixes in all your patch files (e.g. after a fresh install of node_modules), either manually run Hope this helps mitigate the pain / include such fixing into your CI pipeline ;-). |
@uaKorona if you could create a PR with your commit, that'd be great! |
When compiling any project that relies on the idb library, I'm getting the following TypeScript error:
Error: node_modules/idb/build/entry.d.ts:359:45 - error TS2344: Type 'IndexNames<DBTypes, StoreName>' does not satisfy the constraint 'string'
Looking at entry.d.ts, this error is actually correct.
The error occurs in the property definition of
indexNames
:TypesDOMStringList<T extends string>
expectsIndexedNames
to be of assignable tostring
but this turns out to bestring | number
due to the wayIndexedNames
is defined. The expressionkeyof DBTypes[StoreName]['indexes']
is unfortunatelystring | number
even if it should intuitively bestring
only.To verify this, let's look at a simplified example:
To solve the problem, I propose changing the type
IndexNames
fromexport declare type IndexNames<DBTypes extends DBSchema | unknown, StoreName extends StoreNames<DBTypes>> = DBTypes extends DBSchema ? keyof DBTypes[StoreName]['indexes'] : string;
to
export declare type IndexNames<DBTypes extends DBSchema | unknown, StoreName extends StoreNames<DBTypes>> = DBTypes extends DBSchema ? keyof DBTypes[StoreName]['indexes'] & string : string;
As it's a very quick fix it may be easier for you to just do it; if you'd like a PR, just let me know :-).
Thanks a lot for your help and the great work on this library!
The text was updated successfully, but these errors were encountered: