Directory Layout
frontend
| static
| ts
| react
|components
AnotherFile.d.ts
Index.d.ts
Situation
While implementing AnotherFile.d.ts and Index.d.ts, there are no errors flagged by IntelliJ for the following code:
Index.d.ts
interface myFuncType {
(n: number): void;
}
AnotherFile.d.ts
/// <reference path='./Index.d.ts'/>
interface AnotherType {
f: myFuncType
}
However, if Index.d.ts imports and uses a class as shown below, IntelliJ highlights 'myFuncType' in AnotherFile.d.ts with error
TS2304: Cannot find name 'myFuncType'
.
Index.d.ts
import {MyClass} from "static/ts/MyClass";
interface myFuncType {
(n: MyClass) : void;
}
AnotherFile.d.ts
/// <reference path='./Index.d.ts'/>
interface AnotherType {
f: myFuncType;
}
Observations
- Replacing the
<reference path.../>
line in AnotherFile.d.ts with
resolves the error, but the use ofimport {myFuncType} from "static/ts/react/components/Index";
<reference path.../>
is preferable. - Setting frontEnd as 'Resources Root' allows for relative paths in import statements (e.g.,
rather thanimport {myFuncType} from "./Index"
import {myFuncType} from "static/ts/react/components/Index";
Query
Is there a way to resolve the issue in the second scenario without adding an "import" statement in AnotherFile.d.ts.