Closed decapination-labs closed 7 months ago
Works fine in this TypeScript Playground. Please add a minimal reproduction if you want us to re-open this issue.
minimal reproduction:
pnpm create wagmi >> react >> next >> pnpm i
make sure u set declaration : true in ur tsconfig.ts
reason of adding declare : TSConfig Option
run pnpm build and u will get the error :
Type error: The inferred type of 'config' cannot be named without a reference to '.pnpm/viem@2.0.0_bufferutil@4.0.8_typescript@5.3.3_utf-8-validate@6.0.3/node_modules/viem'. This is likely not portable. A type annotation is necessary.
import type { Config } from 'wagmi';
import { http, createConfig } from 'wagmi'
import { mainnet, sepolia } from 'wagmi/chains'
import { coinbaseWallet, injected, walletConnect } from 'wagmi/connectors'
export const config : Config = createConfig({
chains: [mainnet, sepolia],
connectors: [
injected(),
coinbaseWallet({ appName: 'Create Wagmi' }),
walletConnect({ projectId: process.env.NEXT_PUBLIC_WC_PROJECT_ID ?? '123' }),
],
ssr: true,
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
declare module 'wagmi' {
interface Register {
config: typeof config
}
}
adding type Config for config removes the error while keeping declaration : true in tsconfig
any thoughts??
make sure u set declaration : true in ur tsconfig.ts
"declaration": true
is set in this TypeScript Playground.
adding type Config for config removes the error
It may remove the error, but it widens the type of config
to Config
so Wagmi cannot infer anything useful.
Again, if you want me to look into this further, you need to attach a minimal reproduction. You can use this TypeScript Playground as a starting place.
not sure how i can change the PM to pnpm and build
This issue has been locked since it has been closed for more than 14 days.
If you found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest wagmi version. If you have any other comments you can create a new discussion.
Describe the bug
This is my wagmi.ts file
I have a. nextjs14 app router application and i use pnpm .
all packages are up to date ( wagmi , viem , typescript.. )
I keep getting type error :
Type error: The inferred type of 'config' cannot be named without a reference to '.pnpm/viem@2.1.1_typescript@5.3.3_zod@3.22.4/node_modules/viem'. This is likely not portable. A type annotation is necessary.
Link to Minimal Reproducible Example
No response
Steps To Reproduce
No response
Wagmi Version
2.2.1
Viem Version
2.1.1
TypeScript Version
5.3.3
Check existing issues
Anything else?
No response