Typescript's Declaration Merging Not Working As Expected Using Ts-node
Solution 1:
LATEST UPDATE (08-MAY-2021)
When running the typescript program by using ts-node
, even typeRoots
are specified in tsconfig.json, it cannot recognise the custom .d.ts and prompt Property 'x
does not exist on type y` error.
According to https://github.com/TypeStrong/ts-node/issues/1132#issuecomment-716642560
One of the contributors of ts-node
suggested multiple ways to solve it.
Here is one of it:
Specifying file: true
flag in tsconfig.json
to inform ts-node
to load files
, include
and exclude
options from tsconfig.json
on startup
{
"ts-node": {
"files": true
},
"exclude": [...],
"compilerOptions": {
...
}
OLD: (07-MAY-2021)
There is no need to use include
in tsconfig.json
and the paths are not correct. The compiler can search the ts file in the directory and sub-directories
Try to remove it. and restart TS server.
If you are using VSCode, try Cmd + Shift + P or Ctrl + Shift + P and search Restart TS server
and see if the user type error still exist
{"exclude":["node_modules"],"compilerOptions":{"lib":["esnext","esnext.asynciterable"],"baseUrl":".","skipLibCheck":true,"module":"commonjs","esModuleInterop":true,"target":"es6","moduleResolution":"node","outDir":"build","experimentalDecorators":true,"emitDecoratorMetadata":true,"allowSyntheticDefaultImports":true,"strict":true,"strictPropertyInitialization":false,},}
Post a Comment for "Typescript's Declaration Merging Not Working As Expected Using Ts-node"