How the types from d.ts
files are resolved?
As per my understanding types from d.ts
files should be automatically available, without having to explicitly import them, but they are not.
These 2 files are side by side in the same folder:
foo.d.ts
export type Foo = {
bar: string
}
foo.ts
const getFoo = (): Foo => {
return {
bar: 'Foo'
}
}
However, having an error TS2304: Cannot find name 'Foo'.
My tsconfig.json
{
"compilerOptions": {
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": false,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true,
"esModuleInterop": true,
"declaration": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react",
"typeRoots": [ "./types", "./node_modules/@types"],
},
"include": ["src/**/*", "types/*"],
"exclude": ["node_modules", "typings"]
}