From 95014935739d03f7984be0e45843daf4c1fb2e6d Mon Sep 17 00:00:00 2001 From: JunichiSugiura Date: Thu, 11 Apr 2024 20:12:19 +0200 Subject: [PATCH] Apply to all tsconfig --- examples/get-starknet/tsconfig.json | 29 +------------------ .../src/components/ConnectWallet.tsx | 1 - .../src/components/DojoSpawnAndMove.tsx | 6 ++-- .../src/components/SignMessage.tsx | 6 +++- .../src/components/TransferEth.tsx | 10 +++++++ .../starknet-react-next/src/pages/token.tsx | 1 + examples/starknet-react-next/tsconfig.json | 20 +------------ packages/keychain/tsconfig.json | 1 + packages/ui-next/tsconfig.json | 3 ++ packages/ui/tsconfig.json | 4 +-- tsconfig.base.json | 1 + tsconfig.react.json | 1 - 12 files changed, 28 insertions(+), 55 deletions(-) diff --git a/examples/get-starknet/tsconfig.json b/examples/get-starknet/tsconfig.json index 5aea9a43f..4491a4a5a 100644 --- a/examples/get-starknet/tsconfig.json +++ b/examples/get-starknet/tsconfig.json @@ -1,35 +1,8 @@ { + "extends": "../../tsconfig.react.json", "compilerOptions": { "baseUrl": ".", "rootDir": "./src", - "lib": [ - "dom", - "dom.iterable", - "esnext" - ], - "declaration": true, - "target": "ES2020", - "module": "ESNext", - "strict": false, - "jsx": "preserve", - "jsxImportSource": "@emotion/react", - "allowJs": true, - "skipLibCheck": true, - "forceConsistentCasingInFileNames": true, - "incremental": true, - "esModuleInterop": true, - "moduleResolution": "Bundler", - "resolveJsonModule": true, - "isolatedModules": true, - "downlevelIteration": true, "noEmit": true, }, - "include": [ - "next-env.d.ts", - "**/*.ts", - "**/*.tsx" - ], - "exclude": [ - "node_modules" - ], } diff --git a/examples/starknet-react-next/src/components/ConnectWallet.tsx b/examples/starknet-react-next/src/components/ConnectWallet.tsx index ef7dfe4f2..08a18608e 100644 --- a/examples/starknet-react-next/src/components/ConnectWallet.tsx +++ b/examples/starknet-react-next/src/components/ConnectWallet.tsx @@ -1,4 +1,3 @@ -import ControllerConnector from "@cartridge/connector"; import { useAccount, useConnect, useDisconnect } from "@starknet-react/core"; export function ConnectWallet() { diff --git a/examples/starknet-react-next/src/components/DojoSpawnAndMove.tsx b/examples/starknet-react-next/src/components/DojoSpawnAndMove.tsx index 92fe85a8b..0f9bc34a2 100644 --- a/examples/starknet-react-next/src/components/DojoSpawnAndMove.tsx +++ b/examples/starknet-react-next/src/components/DojoSpawnAndMove.tsx @@ -1,8 +1,8 @@ import { useAccount, useContractWrite } from "@starknet-react/core"; -import { useEffect, useState } from "react"; +import { useState } from "react"; -const worldAddress = - "0x426bf51e62109e5c98e7d36dddf813881b610a1ff7c241e51ec3533ce58778c"; +// const worldAddress = +// "0x426bf51e62109e5c98e7d36dddf813881b610a1ff7c241e51ec3533ce58778c"; const actionsAddress = "0x6823753387c85935c6a3d141fb273e35ea9114a5f6e1c2b69d7c5bc3916c7f2"; diff --git a/examples/starknet-react-next/src/components/SignMessage.tsx b/examples/starknet-react-next/src/components/SignMessage.tsx index 76ba8bad8..2688ed939 100644 --- a/examples/starknet-react-next/src/components/SignMessage.tsx +++ b/examples/starknet-react-next/src/components/SignMessage.tsx @@ -7,7 +7,10 @@ import { useState } from "react"; import { typedData } from "starknet"; export function SignMessage() { - const { address, account } = useAccount(); + const { + // address, + account, + } = useAccount(); // const { contract } = useContract({ // address, // }); @@ -99,6 +102,7 @@ export function SignMessage() { ); } +// @ts-expect-error workaround to parse json with bigint BigInt.prototype["toJSON"] = function () { return this.toString(); }; diff --git a/examples/starknet-react-next/src/components/TransferEth.tsx b/examples/starknet-react-next/src/components/TransferEth.tsx index 730e5223b..15e0f6138 100644 --- a/examples/starknet-react-next/src/components/TransferEth.tsx +++ b/examples/starknet-react-next/src/components/TransferEth.tsx @@ -13,6 +13,10 @@ export const TransferEth = () => { const [txnHash, setTxnHash] = useState(); const executePointOne = useCallback(async () => { + if (!account) { + return; + } + const res = await account.execute( [ { @@ -39,6 +43,9 @@ export const TransferEth = () => { .finally(() => console.log("done")); }, [account, chainId]); const executeOne = useCallback(async () => { + if (!account) { + return; + } setTxnHash(undefined); const res = await account.execute( [ @@ -66,6 +73,9 @@ export const TransferEth = () => { .finally(() => console.log("done")); }, [account, chainId]); const execute005 = useCallback(async () => { + if (!account) { + return; + } setTxnHash(undefined); const res = await account.execute( [ diff --git a/examples/starknet-react-next/src/pages/token.tsx b/examples/starknet-react-next/src/pages/token.tsx index c065aef16..8150709b9 100644 --- a/examples/starknet-react-next/src/pages/token.tsx +++ b/examples/starknet-react-next/src/pages/token.tsx @@ -32,6 +32,7 @@ function UserBalance() { return
Error!
; } + // @ts-expect-error TODO: fix type const balance = uint256.uint256ToBN(cairo.uint256(data[0])); return
{balance.toString(10)}
; }, [data, isLoading, error]); diff --git a/examples/starknet-react-next/tsconfig.json b/examples/starknet-react-next/tsconfig.json index 53c09c515..a0cd9da98 100644 --- a/examples/starknet-react-next/tsconfig.json +++ b/examples/starknet-react-next/tsconfig.json @@ -1,25 +1,7 @@ { + "extends": "../../tsconfig.react.json", "compilerOptions": { "baseUrl": "./src", - "lib": [ - "dom", - "dom.iterable", - "esnext" - ], - "declaration": true, - "target": "ES2020", - "module": "ESNext", - "strict": false, - "jsx": "preserve", - "allowJs": true, - "skipLibCheck": true, - "forceConsistentCasingInFileNames": true, - "incremental": true, - "esModuleInterop": true, - "moduleResolution": "Bundler", - "resolveJsonModule": true, - "isolatedModules": true, - "downlevelIteration": true, "noEmit": true }, "include": [ diff --git a/packages/keychain/tsconfig.json b/packages/keychain/tsconfig.json index e51ea9cbc..c6b5ee8b7 100644 --- a/packages/keychain/tsconfig.json +++ b/packages/keychain/tsconfig.json @@ -6,6 +6,7 @@ "types": [ "@emotion/react/types/css-prop" ], + "noEmit": true, // TODO(#262): Enable these options (too many errors for this scope) "strict": false, "noImplicitAny": false, diff --git a/packages/ui-next/tsconfig.json b/packages/ui-next/tsconfig.json index 80a186579..48484510c 100644 --- a/packages/ui-next/tsconfig.json +++ b/packages/ui-next/tsconfig.json @@ -1,6 +1,9 @@ { "extends": "../../tsconfig.react.json", "compilerOptions": { + "baseUrl": ".", + "rootDir": "./src", + "outDir": "./lib", "jsx": "react-jsx", "paths": { "@/*": ["./src/*"] diff --git a/packages/ui/tsconfig.json b/packages/ui/tsconfig.json index 94a41aaf3..95acc2ef7 100644 --- a/packages/ui/tsconfig.json +++ b/packages/ui/tsconfig.json @@ -3,8 +3,8 @@ "compilerOptions": { "baseUrl": ".", "rootDir": "./src", - "outDir": "lib", - "types": ["@emotion/react/types/css-prop"] + "outDir": "./lib", + "types": ["@emotion/react/types/css-prop"], }, "paths": { "@cartridge/ui/components": ["./src/components"], diff --git a/tsconfig.base.json b/tsconfig.base.json index bd412ffdf..a17f88e6c 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -13,5 +13,6 @@ "noUnusedLocals": true, "noUnusedParameters": true, "noFallthroughCasesInSwitch": true, + "noEmit": false } } diff --git a/tsconfig.react.json b/tsconfig.react.json index 69afbf6ad..dd5160c2a 100644 --- a/tsconfig.react.json +++ b/tsconfig.react.json @@ -4,7 +4,6 @@ // nextjs override these if not exist "lib": ["ES2020", "DOM", "DOM.Iterable"], "allowJs": true, - "noEmit": true, "incremental": true, "esModuleInterop": true, "resolveJsonModule": true,