Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Types unavailable #22

Open
jaydenseric opened this issue Jun 28, 2022 · 0 comments
Open

Types unavailable #22

jaydenseric opened this issue Jun 28, 2022 · 0 comments

Comments

@jaydenseric
Copy link

With recent versions of TypeScript (currently v4.7.4) and with project TypeScript config compilerOptions.module set to nodenext, the types for this package are not available when importing from within an ESM module:

// @ts-check

import { countryCodeEmoji } from "country-code-emoji";

The hover intellisense doesn't include the right types (cc arg should be type string):

Screen Shot 2022-06-28 at 5 57 57 pm

If you CMD + click the import, it opens the country-code-emoji/lib/index.mjs module instead of the country-code-emoji/lib/index.d.ts file you would expect if the types were working.

I think the reason is because the package exports field incorrectly doesn't start with a types property:

"exports": {
"import": "./lib/index.mjs",
"require": "./lib/index.js"
},

    "exports": {
+     "types": "./lib/index.d.ts",
      "import": "./lib/index.mjs",
      "require": "./lib/index.js"
    },

See:

https://www.typescriptlang.org/docs/handbook/esm-node.html#packagejson-exports-imports-and-self-referencing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant