nftstorage / nft.storage

**Notice: Uploads Decommissioned - Existing Data is Safe!** NFT.Storage Classic (classic.nft.storage) offers free decentralized storage and bandwidth for NFTs on IPFS and Filecoin. June 2024 Update: No new uploads, but all existing data is safe. Try the new NFT.Storage, which preserves data in long term Filecoin storage. Go to app.nft.storage
https://classic.nft.storage
Other
619 stars 167 forks source link

Typescript 5 support - Building fails - cid.d.ts, token.d.ts #2355

Closed mbledkowski closed 5 months ago

mbledkowski commented 1 year ago

Hi, When building by using nft.storage 7.0.3, or 7.0.0, I get the following error

node_modules/.pnpm/multiformats@9.9.0/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/multiformats@9.9.0/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/multiformats@9.9.0/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/multiformats@9.9.0/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/nft.storage@7.0.3_node-fetch@3.3.1/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/nft.storage@7.0.3_node-fetch@3.3.1/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/nft.storage@7.0.3_node-fetch@3.3.1/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/nft.storage@7.0.3_node-fetch@3.3.1/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/nft.storage@7.0.3_node-fetch@3.3.1/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/nft.storage@7.0.3_node-fetch@3.3.1/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/nft.storage@7.0.3_node-fetch@3.3.1/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/nft.storage@7.0.3_node-fetch@3.3.1/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/multiformats@9.9.0/node_modules/multiformats/types/src/cid.d.ts:160
     8  node_modules/.pnpm/nft.storage@7.0.3_node-fetch@3.3.1/node_modules/nft.storage/dist/src/token.d.ts:29
 ELIFECYCLE  Command failed with exit code 2.
mbledkowski commented 1 year ago

This happens when upgrading from typescript 4.9.5 to 5.0.2

mbledkowski commented 1 year ago

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.

elizabeth-griffiths commented 5 months ago

If you still need support, please re-open this issue and provide more detail. Thanks!