TypeScript intellisense doesn't seem to resolve default module in CJS context

29 Views Asked by At

Let's say I have the following basic CJS module:

module.exports = { foo: "bar" }

For which I've configured separately following TS typing:

declare const test: { foo: string };

export default test;

Having that when I try to import this typed module in TypeScript file, Intellisense works as expected:

TS intellisense

But when I try to require it in CJS module intellisense fails, as it suggests the .default property, on which then foo is suggested, which is not correct:

CJS intellisense

What I'm missing in TS setup to have intellisense in CJS working properly? Is it possible to make it right?

0

There are 0 best solutions below