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

chore(common): add restructure .d.ts for esm #8945

Closed
mcdurdin opened this issue Jun 7, 2023 · 1 comment · Fixed by keymanapp/dependency-restructure#2
Closed

chore(common): add restructure .d.ts for esm #8945

mcdurdin opened this issue Jun 7, 2023 · 1 comment · Fixed by keymanapp/dependency-restructure#2

Comments

@mcdurdin
Copy link
Member

mcdurdin commented Jun 7, 2023

Transitive deps get the following error on tsc -b, e.g. kmc-package depends on common-types which depends on restructure:

../../../node_modules/@keymanapp/common-types/src/kmx/kmx.ts:1:20 - error TS7016: Could not find a declaration file for module 'restructure'. 'C:/Projects/keyman/app/node_modules/restructure/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/restructure` if it exists or add a new declaration (.d.ts) file containing `declare module 'restructure';`
1 import * as r from 'restructure';
                     ~~~~~~~~~~~~~

../../../node_modules/@keymanapp/common-types/src/kmx/kmx-file-reader.ts:2:20 - error TS7016: Could not find a declaration file for module 'restructure'. 'C:/Projects/keyman/app/node_modules/restructure/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/restructure` if it exists or add a new declaration (.d.ts) file containing `declare module 'restructure';`
2 import * as r from 'restructure';
                     ~~~~~~~~~~~~~

Discussed at microsoft/TypeScript#50223, fix is to add the appropriate types to exports key in package.json for restructure, something like this:

"exports": {
    ".": {
      "import": {
        "types": "./src/restructure-esm.d.ts",
        "default": "./dist/index.js"
      },
    }
  },
"types": "./src/restructure.d.ts",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant