- VSCode Version: 1.47.3 (system setup)
- OS Version: Windows_NT x64 10.0.19041
Here’s a contrived directory structure of a React app:
.
└── src
└── Components
└── Foo
├── Bar
│ ├── Bar.js
│ └── Bar.d.ts
└── Foo.js
// React component `Foo` imports a component `Bar`:
import { Bar } from './Bar/Bar'
export function Foo() {
//
}
// And gets full intellisense via `Bar.d.ts`:
type Props = {
/** ... */
}
export declare function Bar(
props: Props
): React.FunctionComponent
But Bar.js itself doesn’t get intellisense from its own Bar.d.ts file—it’s like the .d.ts doesn’t exist—am I doing something wrong, or is it how it’s supposed to work in the current version of VSCode? I tried the triple-slash directive (/// <reference path="Bar.d.ts"/>), but it didn’t help. Some JSDoc helped, but it’s rather pointless to have a dedicated declaration file and still use JSDoc:
export function Bar(
// When `type Props` is exported from the `.d.ts`:
/** @type {import("./Bar").Props} */ props
) {
I tried the Insiders build—same thing. I also prepared a repository representing the example above in case you want to check something yourself. Initially, I asked it as a StackOverflow question (link), but didn’t get an answer, so if you think this is a usage question, please leave an answer there.
Here’s a contrived directory structure of a React app:
But
Bar.jsitself doesn’t get intellisense from its ownBar.d.tsfile—it’s like the.d.tsdoesn’t exist—am I doing something wrong, or is it how it’s supposed to work in the current version of VSCode? I tried the triple-slash directive (/// <reference path="Bar.d.ts"/>), but it didn’t help. Some JSDoc helped, but it’s rather pointless to have a dedicated declaration file and still use JSDoc:I tried the Insiders build—same thing. I also prepared a repository representing the example above in case you want to check something yourself. Initially, I asked it as a StackOverflow question (link), but didn’t get an answer, so if you think this is a usage question, please leave an answer there.