How to prevent duplicate auto-suggestions import

Viewed 141

Suppose i have some source code like this

// index.js
import xxx from "./lib/xxx"
export { xxx }
// lib/xxx.js
export default function() {}

After tsc compile will generate two files

// index.d.ts
import xxx from "./lib/xxx"
export { xxx }
// lib/xxx.d.ts
export default function(): void;

And then suppose i publish this package and named ex, when i install ex, using in code will get auto-suggestions of import, but i just need one auto-suggestions of import, Can someone tell me how to do it ?

enter image description here

enter image description here

1 Answers

You probably want "internal modules" from Typescript's earlier days, which use the module keyword to wrap stuff. See here: https://fizzylogic.nl/2016/02/07/typescript-internal-vs-external-modules/

From the article:

Internal modules are really namespaces, which is model that is most often applied in the browser. There's a big need for namespaces in a web application since everything naturally gets loaded into the window scope. The window scope can turn into a massive pile of variables if you don't manage your scripts carefully. This is where internal modules or namespaces really shine.

Typescript's module keyword pre-dates actual ECMAscript modules.

Related