#Import d.ts in JSDoc with same name possible?

5 messages · Page 1 of 1 (latest)

elfin violet
#

I have a file called test.d.ts with this declaration:

export type Person = {
  name: string
}

and a test.js file with this content:

/** @type {import('./test').Person} */
let person;

person = {
  name2: "sdf",
};

And it doesn't work. VSCode properly displays the Person type when I hover it, but the (wrong) assignment doesn't trigger an error.

What am I doing wrong?

Putting the type in a file with a different name (e.g.: foo.d.ts) and importing from there, works properly.

rain drift
#

ts check is enabled?

elfin violet
#

Yup

unkempt hawk
#

This seems very strange. If you see the correct type for "Person" when you hover ".Person" in vscode, then it means intellisense has properly picked up the type definition. So that code should absolutely work. Did you try restarting the TS Server?

#

(or I mean it "should absolutely give an error")