I'm trying to have only one file to have most of the type definitions athat are going to be used in the whole application, i've created a folder called @types and a index.d.ts file exporting every single interface/type i want.
Updated my tsconfig.json to include that folder:
{
"compilerOptions": {
"outDir": "./built",
"allowJs": true,
"target": "es5",
"jsx": "react",
"allowSyntheticDefaultImports": true,
"lib": [
"es2015"
],
"typeRoots": [
"./@types"
],
},
"include": [
"./client/**/*",
"./@types/**/*"
],
"awesomeTypescriptLoaderOptions": {
"silent": true,
"errorsAsWarnings": true
}
}
Even though, when in the code (inside client/...) i reference one of the interfaces present on index.d.ts, vscode throws a "Could not find name".
Is there a better way to fix this?
Interface definition present inside @types/index.d.ts.
export interface Agent {
name: string;
...
}
Usage:
interface Props extends RouteComponentProps<any> {
agent?: types.Agent;
}