T
TanStack3y ago
stormy-gold

Weird build error when building my app

yarn run v1.22.19
$ tsc
node_modules/@tanstack/query-core/src/queryObserver.ts:543:46 - error TS2345: Argument of type '(TQueryData & ({} | null)) | (TData & ({} | null))' is not assignable to parameter of type 'TData'.
'TData' could be instantiated with an arbitrary type which could be unrelated to '(TQueryData & ({} | null)) | (TData & ({} | null))'.

543 data = replaceData(prevResult?.data, placeholderData, options) as TData
~~~~~~~~~~~~~~~


Found 1 error in node_modules/@tanstack/query-core/src/queryObserver.ts:543

error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
$ tsc
node_modules/@tanstack/query-core/src/queryObserver.ts:543:46 - error TS2345: Argument of type '(TQueryData & ({} | null)) | (TData & ({} | null))' is not assignable to parameter of type 'TData'.
'TData' could be instantiated with an arbitrary type which could be unrelated to '(TQueryData & ({} | null)) | (TData & ({} | null))'.

543 data = replaceData(prevResult?.data, placeholderData, options) as TData
~~~~~~~~~~~~~~~


Found 1 error in node_modules/@tanstack/query-core/src/queryObserver.ts:543

error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
4 Replies
stormy-gold
stormy-goldOP3y ago
Maybe its something wrong with my tsconfig? tsconfig:
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"paths": {
"@*": ["./src/features/*"],
"~/*": ["./src/*"]
}
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"paths": {
"@*": ["./src/features/*"],
"~/*": ["./src/*"]
}
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}
tsconfig.node
{
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}
{
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}
conscious-sapphire
conscious-sapphire3y ago
@JVictorV Could you please let me know how did you manage to solve this issue? Even i get the same error. Thank you
stormy-gold
stormy-goldOP3y ago
Unfortunately I didn’t find a proper solution I just used patch package to add a ts ignore on that line
conscious-sapphire
conscious-sapphire3y ago
ah ok. Thank you for you response. In my case, I just figured out that I was importing a type tht was not needed. After removing it, the error is gone.

Did you find this page helpful?