nft.storage
nft.storage copied to clipboard
Typescript 5 support - Building fails - cid.d.ts, token.d.ts
Hi, When building by using nft.storage 7.0.3, or 7.0.0, I get the following error
node_modules/.pnpm/[email protected]/node_modules/multiformats/types/src/cid.d.ts:160:85 - error TS2344: Type 'Prefix' does not satisfy the constraint 'string'.
160 export type MultibaseEncoder<Prefix> = import('./bases/interface').MultibaseEncoder<Prefix>;
~~~~~~
node_modules/.pnpm/[email protected]/node_modules/multiformats/types/src/cid.d.ts:160:30
160 export type MultibaseEncoder<Prefix> = import('./bases/interface').MultibaseEncoder<Prefix>;
~~~~~~
This type parameter might need an `extends string` constraint.
node_modules/.pnpm/[email protected]/node_modules/multiformats/types/src/cid.d.ts:161:85 - error TS2344: Type 'Prefix' does not satisfy the constraint 'string'.
161 export type MultibaseDecoder<Prefix> = import('./bases/interface').MultibaseDecoder<Prefix>;
~~~~~~
node_modules/.pnpm/[email protected]/node_modules/multiformats/types/src/cid.d.ts:161:30
161 export type MultibaseDecoder<Prefix> = import('./bases/interface').MultibaseDecoder<Prefix>;
~~~~~~
This type parameter might need an `extends string` constraint.
node_modules/.pnpm/[email protected][email protected]/node_modules/nft.storage/dist/src/token.d.ts:29:61 - error TS2344: Type '(input: BlobExport) => URL' does not satisfy the constraint '((input: unknown) => unknown) | ((input: unknown) => unknown)'.
Type '(input: BlobExport) => URL' is not assignable to type '(input: unknown) => unknown'.
Types of parameters 'input' and 'input' are incompatible.
Type 'unknown' is not assignable to type 'BlobExport'.
29 data: import("./lib/interface.js").MatchRecord<T_1, (input: Blob) => URL>;
~~~~~~~~~~~~~~~~~~~~
node_modules/.pnpm/[email protected][email protected]/node_modules/nft.storage/dist/src/token.d.ts:30:55 - error TS2344: Type '(input: BlobExport) => URL' does not satisfy the constraint '((input: unknown) => unknown) | ((input: unknown) => unknown)'.
Type '(input: BlobExport) => URL' is not assignable to type '(input: unknown) => unknown'.
Types of parameters 'input' and 'input' are incompatible.
Type 'unknown' is not assignable to type 'BlobExport'.
30 }): import("./lib/interface.js").MatchRecord<T_1, (input: Blob) => URL>;
~~~~~~~~~~~~~~~~~~~~
node_modules/.pnpm/[email protected][email protected]/node_modules/nft.storage/dist/src/token.d.ts:72:64 - error TS2344: Type '(input: BlobExport) => URL' does not satisfy the constraint '((input: unknown) => unknown) | ((input: unknown) => unknown)'.
Type '(input: BlobExport) => URL' is not assignable to type '(input: unknown) => unknown'.
Types of parameters 'input' and 'input' are incompatible.
Type 'unknown' is not assignable to type 'BlobExport'.
72 readonly data: import("./lib/interface.js").MatchRecord<T, (input: Blob) => URL>;
~~~~~~~~~~~~~~~~~~~~
node_modules/.pnpm/[email protected][email protected]/node_modules/nft.storage/dist/src/token.d.ts:78:77 - error TS2344: Type '(input: BlobExport) => URL' does not satisfy the constraint '((input: unknown) => unknown) | ((input: unknown) => unknown)'.
Type '(input: BlobExport) => URL' is not assignable to type '(input: unknown) => unknown'.
Types of parameters 'input' and 'input' are incompatible.
Type 'unknown' is not assignable to type 'BlobExport'.
78 export function embed<T>(input: import("./lib/interface.js").MatchRecord<T, (input: Blob) => URL>, options: EmbedOptions): import("./lib/interface.js").MatchRecord<T, (input: Blob) => URL>;
~~~~~~~~~~~~~~~~~~~~
node_modules/.pnpm/[email protected][email protected]/node_modules/nft.storage/dist/src/token.d.ts:78:168 - error TS2344: Type '(input: BlobExport) => URL' does not satisfy the constraint '((input: unknown) => unknown) | ((input: unknown) => unknown)'.
Type '(input: BlobExport) => URL' is not assignable to type '(input: unknown) => unknown'.
Types of parameters 'input' and 'input' are incompatible.
Type 'unknown' is not assignable to type 'BlobExport'.
78 export function embed<T>(input: import("./lib/interface.js").MatchRecord<T, (input: Blob) => URL>, options: EmbedOptions): import("./lib/interface.js").MatchRecord<T, (input: Blob) => URL>;
~~~~~~~~~~~~~~~~~~~~
node_modules/.pnpm/[email protected][email protected]/node_modules/nft.storage/dist/src/token.d.ts:80:126 - error TS2344: Type '(input: BlobExport) => BlobExport' does not satisfy the constraint '((input: unknown) => unknown) | ((input: unknown) => unknown)'.
Type '(input: BlobExport) => BlobExport' is not assignable to type '(input: unknown) => unknown'.
Types of parameters 'input' and 'input' are incompatible.
Type 'unknown' is not assignable to type 'BlobExport'.
80 export function encode<T extends import("./lib/interface.js").TokenInput>(input: import("./lib/interface.js").MatchRecord<T, (input: Blob) => Blob>): FormData;
~~~~~~~~~~~~~~~~~~~~~
node_modules/.pnpm/[email protected][email protected]/node_modules/nft.storage/dist/src/token.d.ts:81:95 - error TS2344: Type '(input: I) => X' does not satisfy the constraint '((input: unknown) => unknown) | ((input: unknown) => unknown)'.
Type '(input: I) => X' is not assignable to type '(input: unknown) => unknown'.
Types of parameters 'input' and 'input' are incompatible.
Type 'unknown' is not assignable to type 'I'.
'I' could be instantiated with an arbitrary type which could be unrelated to 'unknown'.
81 export function mapWith<T, I, X, O, State>(input: import("./lib/interface.js").MatchRecord<T, (input: I) => X>, p: (input: any, state: State, path: PropertyKey[]) => input is X, f: (state: State, input: X, path: PropertyKey[]) => [State, O], state: State): import("./lib/interface.js").MatchRecord<T, (input: I) => O>;
~~~~~~~~~~~~~~~
node_modules/.pnpm/[email protected][email protected]/node_modules/nft.storage/dist/src/token.d.ts:81:302 - error TS2344: Type '(input: I) => O' does not satisfy the constraint '((input: unknown) => unknown) | ((input: unknown) => unknown)'.
Type '(input: I) => O' is not assignable to type '(input: unknown) => unknown'.
Types of parameters 'input' and 'input' are incompatible.
Type 'unknown' is not assignable to type 'I'.
'I' could be instantiated with an arbitrary type which could be unrelated to 'unknown'.
81 export function mapWith<T, I, X, O, State>(input: import("./lib/interface.js").MatchRecord<T, (input: I) => X>, p: (input: any, state: State, path: PropertyKey[]) => input is X, f: (state: State, input: X, path: PropertyKey[]) => [State, O], state: State): import("./lib/interface.js").MatchRecord<T, (input: I) => O>;
~~~~~~~~~~~~~~~
Found 10 errors in 2 files.
Errors Files
2 node_modules/.pnpm/[email protected]/node_modules/multiformats/types/src/cid.d.ts:160
8 node_modules/.pnpm/[email protected][email protected]/node_modules/nft.storage/dist/src/token.d.ts:29
 ELIFECYCLE  Command failed with exit code 2.
This happens when upgrading from typescript 4.9.5 to 5.0.2
This issue still needs to be resolved. For anyone that uses this library in its projects - keep typescript version in package.json locked on 4.9.5 - "typescript": "^4.9.5" inside devDependencies.
If you still need support, please re-open this issue and provide more detail. Thanks!