workbenchapp / solana-workbench

Your one-stop shop for developing on Solana
MIT License
63 stars 7 forks source link

Typescript checking on CI is broken -- many errors #245

Open nathanleclaire opened 2 years ago

nathanleclaire commented 2 years ago

My VSCode is filled with many errors that weren't caught by our CI. And I'm pretty sure they're all legit. If I run npm exec tsc from the root repo I get the following:

src/renderer/App.tsx(70,42): error TS2322: Type 'string | undefined' is not assignable to type 'To'.
  Type 'undefined' is not assignable to type 'To'.
src/renderer/components/AccountView.tsx(55,55): error TS2554: Expected 3 arguments, but got 2.
src/renderer/components/AccountView.tsx(83,20): error TS2339: Property 'accountInfo' does not exist on type 'NonNullable<TQueryFnData>'.
src/renderer/components/AccountView.tsx(84,20): error TS2339: Property 'accountInfo' does not exist on type 'TQueryFnData'.
src/renderer/components/AccountView.tsx(95,32): error TS2339: Property 'accountInfo' does not exist on type 'TQueryFnData'.
src/renderer/components/AccountView.tsx(118,45): error TS2345: Argument of type 'TQueryFnData | undefined' is not assignable to parameter of type 'AccountInfo | undefined'.
  Type 'TQueryFnData' is not assignable to type 'AccountInfo | undefined'.
    Type 'TQueryFnData' is not assignable to type 'AccountInfo'.
src/renderer/components/AccountView.tsx(208,40): error TS2339: Property 'accountInfo' does not exist on type 'NonNullable<TQueryFnData>'.
src/renderer/components/AccountView.tsx(222,58): error TS2345: Argument of type 'TQueryFnData' is not assignable to parameter of type 'AccountInfo | undefined'.
src/renderer/components/AccountView.tsx(231,33): error TS2339: Property 'accountInfo' does not exist on type 'NonNullable<TQueryFnData>'.
src/renderer/components/MintInfoView.tsx(72,15): error TS2339: Property 'accountInfo' does not exist on type 'TQueryFnData'.
src/renderer/components/MintInfoView.tsx(73,15): error TS2339: Property 'accountInfo' does not exist on type 'TQueryFnData'.
src/renderer/components/MintInfoView.tsx(89,14): error TS2339: Property 'accountInfo' does not exist on type 'TQueryFnData'.
src/renderer/components/MintInfoView.tsx(92,16): error TS2339: Property 'accountInfo' does not exist on type 'NonNullable<TQueryFnData>'.
src/renderer/components/MintInfoView.tsx(94,30): error TS2339: Property 'data' does not exist on type 'NonNullable<TQueryFnData>'.
src/renderer/components/MintInfoView.tsx(114,28): error TS2339: Property 'accountInfo' does not exist on type 'NonNullable<TQueryFnData>'.
src/renderer/components/MintInfoView.tsx(116,23): error TS2339: Property 'accountInfo' does not exist on type 'NonNullable<TQueryFnData>'.
src/renderer/components/tokens/MetaplexMintMetaDataView.tsx(49,5): error TS2345: Argument of type '(params: ParsedAccountParams) => Promise<Metadata | undefined>' is not assignable to parameter of type 'QueryFunction<Metadata | undefined, QueryKey>'.
src/renderer/components/tokens/MetaplexMintMetaDataView.tsx(73,30): error TS2339: Property 'data' does not exist on type 'TQueryFnData'.
src/renderer/components/tokens/MetaplexMintMetaDataView.tsx(89,14): error TS2339: Property 'data' does not exist on type 'TQueryFnData'.
src/renderer/components/tokens/MetaplexMintMetaDataView.tsx(90,14): error TS2339: Property 'data' does not exist on type 'TQueryFnData'.
src/renderer/components/tokens/MetaplexMintMetaDataView.tsx(97,34): error TS2339: Property 'pubkey' does not exist on type 'TQueryFnData'.
src/renderer/components/tokens/MetaplexMintMetaDataView.tsx(100,46): error TS2339: Property 'data' does not exist on type 'NonNullable<TQueryFnData>'.
src/renderer/components/tokens/MetaplexMintMetaDataView.tsx(101,24): error TS2339: Property 'data' does not exist on type 'NonNullable<TQueryFnData>'.
src/renderer/components/tokens/MetaplexMintMetaDataView.tsx(103,31): error TS2339: Property 'data' does not exist on type 'NonNullable<TQueryFnData>'.
src/renderer/components/tokens/MetaplexTokenData.tsx(36,5): error TS2345: Argument of type '(params: ParsedAccountParams) => Promise<Metadata | undefined>' is not assignable to parameter of type 'QueryFunction<Metadata | undefined, QueryKey>'.
  Types of parameters 'params' and 'context' are incompatible.
    Type 'QueryFunctionContext<QueryKey, any>' is not assignable to type 'ParsedAccountParams'.
src/renderer/components/tokens/MetaplexTokenData.tsx(41,15): error TS2339: Property 'data' does not exist on type 'NonNullable<TQueryFnData>'.
src/renderer/components/tokens/MetaplexTokenData.tsx(44,15): error TS2339: Property 'data' does not exist on type 'NonNullable<TQueryFnData>'.
src/renderer/components/tokens/MetaplexTokenData.tsx(47,15): error TS2339: Property 'data' does not exist on type 'NonNullable<TQueryFnData>'.
src/renderer/components/tokens/MetaplexTokenData.tsx(51,15): error TS2339: Property 'data' does not exist on type 'NonNullable<TQueryFnData>'.
src/renderer/components/tokens/MetaplexTokenData.tsx(73,32): error TS2339: Property 'data' does not exist on type 'TQueryFnData'.
src/renderer/components/tokens/MetaplexTokenData.tsx(77,11): error TS2322: Type 'WalletContextState' is not assignable to type 'Wallet'.
  Types of property 'publicKey' are incompatible.
    Type 'PublicKey | null' is not assignable to type 'PublicKey'.
      Type 'null' is not assignable to type 'PublicKey'.
src/renderer/components/tokens/MetaplexTokenData.tsx(90,11): error TS2322: Type 'WalletContextState' is not assignable to type 'Wallet'.
src/renderer/components/tokens/MetaplexTokenData.tsx(165,58): error TS2345: Argument of type 'string' is not assignable to parameter of type 'SetStateAction<number>'.
src/renderer/components/tokens/MetaplexTokenData.tsx(214,30): error TS2322: Type 'PublicKey | undefined' is not assignable to type 'PublicKey'.
  Type 'undefined' is not assignable to type 'PublicKey'.
src/renderer/components/tokens/TokensListView.tsx(45,5): error TS2769: No overload matches this call.
  Overload 1 of 3, '(queryKey: QueryKey, options?: Omit<UseQueryOptions<AccountInfo<ParsedAccountData>, Error, AccountInfo<ParsedAccountData>, QueryKey>, "queryKey"> | undefined): UseQueryResult<...>', gave the following error.
    Type '(params: ParsedAccountParams) => Promise<RpcResponseAndContext<TokenAccountArray>>' has no properties in common with type 'Omit<UseQueryOptions<AccountInfo<ParsedAccountData>, Error, AccountInfo<ParsedAccountData>, QueryKey>, "queryKey">'.
  Overload 2 of 3, '(queryKey: QueryKey, queryFn: QueryFunction<AccountInfo<ParsedAccountData>, QueryKey>, options?: Omit<UseQueryOptions<AccountInfo<ParsedAccountData>, Error, AccountInfo<...>, QueryKey>, "queryKey" | "queryFn"> | undefined): UseQueryResult<...>', gave the following error.
    Argument of type '(params: ParsedAccountParams) => Promise<RpcResponseAndContext<TokenAccountArray>>' is not assignable to parameter of type 'QueryFunction<AccountInfo<ParsedAccountData>, QueryKey>'.
      Types of parameters 'params' and 'context' are incompatible.
        Type 'QueryFunctionContext<QueryKey, any>' is not assignable to type 'ParsedAccountParams'.
src/renderer/components/tokens/TokensListView.tsx(60,43): error TS2339: Property 'value' does not exist on type 'TQueryFnData'.
src/renderer/components/tokens/TransferTokenButton.tsx(190,41): error TS2345: Argument of type 'string | undefined' is not assignable to parameter of type 'PublicKeyInitData'.
  Type 'undefined' is not assignable to type 'PublicKeyInitData'.
src/renderer/data/accounts/getAccount.ts(49,9): error TS2741: Property 'programID' is missing in type '{ accountId: sol.PublicKey; accountInfo: sol.AccountInfo<Buffer | sol.ParsedAccountData> | null; pubKey: string; net: Net; count: number; solDelta: number; maxDelta: number; }' but required in type 'AccountInfo'.
src/renderer/data/accounts/getAccount.ts(60,3): error TS2739: Type 'AccountInfo' is missing the following properties from type 'AccountInfo<ParsedAccountData>': executable, owner, lamports, data
src/renderer/data/accounts/getAccount.ts(80,3): error TS7006: Parameter 'queryOption' implicitly has an 'any' type.
src/renderer/data/accounts/getAccount.ts(88,5): error TS2345: Argument of type '(params: ParsedAccountParams) => Promise<AccountInfo<ParsedAccountData>>' is not assignable to parameter of type 'QueryFunction<AccountInfo<ParsedAccountData>, QueryKey>'.
  Types of parameters 'params' and 'context' are incompatible.
    Type 'QueryFunctionContext<QueryKey, any>' is not assignable to type 'ParsedAccountParams'.
      Types of property 'queryKey' are incompatible.
        Type 'readonly unknown[] | [string]' is not assignable to type '[string, { net: Net; pubKey: string; }]'.
          The type 'readonly unknown[]' is 'readonly' and cannot be assigned to the mutable type '[string, { net: Net; pubKey: string; }]'.
src/renderer/data/accounts/getAccount.ts(120,7): error TS2322: Type 'undefined' is not assignable to type 'Buffer | ParsedAccountData'.
src/renderer/data/accounts/getAccount.ts(192,9): error TS2739: Type '{}' is missing the following properties from type 'Metadata': pubkey, info, data, assertOwner, toJSON
src/renderer/nav/TokenPage.tsx(53,73): error TS2694: Namespace '"@solana/spl-token"' has no exported member 'Account'.
src/renderer/wallet-adapter/web3.ts(4,3): error TS2305: Module '"@solana/spl-token"' has no exported member 'MINT_SIZE'.
src/renderer/wallet-adapter/web3.ts(5,3): error TS2305: Module '"@solana/spl-token"' has no exported member 'getMinimumBalanceForRentExemptMint'.
src/renderer/wallet-adapter/web3.ts(49,14): error TS2339: Property 'createInitializeMintInstruction' does not exist on type 'typeof import("@solana/spl-token")'.
src/renderer/wallet-adapter/web3.ts(119,21): error TS2694: Namespace '"@solana/spl-token"' has no exported member 'Account'.
src/renderer/wallet-adapter/web3.ts(120,42): error TS2339: Property 'getAssociatedTokenAddress' does not exist on type 'typeof import("@solana/spl-token")'.
src/renderer/wallet-adapter/web3.ts(130,25): error TS2694: Namespace '"@solana/spl-token"' has no exported member 'Account'.
src/renderer/wallet-adapter/web3.ts(132,30): error TS2339: Property 'getAccount' does not exist on type 'typeof import("@solana/spl-token")'.
src/renderer/wallet-adapter/web3.ts(143,33): error TS2339: Property 'TokenAccountNotFoundError' does not exist on type 'typeof import("@solana/spl-token")'.
src/renderer/wallet-adapter/web3.ts(144,33): error TS2339: Property 'TokenInvalidAccountOwnerError' does not exist on type 'typeof import("@solana/spl-token")'.
src/renderer/wallet-adapter/web3.ts(149,20): error TS2339: Property 'createAssociatedTokenAccountInstruction' does not exist on type 'typeof import("@solana/spl-token")'.
src/renderer/wallet-adapter/web3.ts(202,32): error TS2339: Property 'getAccount' does not exist on type 'typeof import("@solana/spl-token")'.
src/renderer/wallet-adapter/web3.ts(213,54): error TS2339: Property 'TokenInvalidMintError' does not exist on type 'typeof import("@solana/spl-token")'.
src/renderer/wallet-adapter/web3.ts(214,56): error TS2339: Property 'TokenInvalidOwnerError' does not exist on type 'typeof import("@solana/spl-token")'.
src/renderer/wallet-adapter/web3.ts(260,14): error TS2339: Property 'createMintToInstruction' does not exist on type 'typeof import("@solana/spl-token")'.
src/renderer/wallet-adapter/web3.ts(334,14): error TS2339: Property 'createTransferInstruction' does not exist on type 'typeof import("@solana/spl-token")'.
src/renderer/wallet-adapter/web3.ts(411,14): error TS2339: Property 'createSetAuthorityInstruction' does not exist on type 'typeof import("@solana/spl-token")'.

We should get these fixed up -- I'll write some more notes about what I've found about 'em so far below

nathanleclaire commented 2 years ago

for these --

TS2339 with @solana/spl-token -- Property 'blah' does not exist

They look exactly like this issue -- https://github.com/solana-labs/solana-program-library/issues/3057

So far, it looks like some incompatibility between metaplex lib(s) and spl-token version we're using. We are using the deprecated @metaplex/js, not the new @metaplex-foundation/js, and the former looks like it came out before the 0.2.0 version of @solana/spl-token that we have (which seems to have had some breaking changes vs. 0.1.*).

nathanleclaire commented 2 years ago

Property 'accountInfo' does not exist on type 'TQueryFnData'

These must be React query related?