I have a problem with interface import. When I have interface with non import dependencies in separate files like:
/src/app/something/something.interface.ts
interface ISomething {
a: String[];
}
I can use it in another file in the same directory without import it, fo example:
/src/app/someting/something.tsx
class Something extends React.Component<ISomething, any> {
}
But when I have interface like this:
import Page from '../components/page';
interface ISomething {
a: String[];
b: Page;
}
I get an error from compilation process:
[2] ERROR in src/app/something/something.tsx(9,40): error TS2304: Cannot find name 'ISomething'.
I try to use export interface ISomething ...
and import them in something.tsx
but this get an error
[2] ERROR in src/app/application/education/react/renderer/renderer.tsx(8,9): error TS2305: Module '"/Users/xxx/Projects/react/src/app/something/something.interface"' has no exported member 'ISomething'.
When I put my ISomething
interface in something.tsx
file it work, but I want to keep it clean in separate file.
Do you have any idea why?
EDIT: tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}
tsconfig.app.json
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../dist/out-tsc/app",
"module": "es2015",
"types": [
"node"
]
},
"exclude": [
"src/test.ts",
"**/*.spec.ts"
],
"angularCompilerOptions": {
"preserveWhitespaces": true
}
}