|
fs.writeFileSync( |
|
path.resolve(dir, 'code-points.js'), |
|
`module.exports=${ codePointsExports }` |
|
); |
|
fs.writeFileSync( |
|
path.resolve(dir, 'code-points.d.ts'), |
|
`declare const codePoints: number[];\nexport default codePoints;` |
|
); |
module.exports = must be annotated with export = type declaration.
See https://www.typescriptlang.org/docs/handbook/modules/appendices/esm-cjs-interop.html#library-code-needs-special-considerations:
... libraries that need to ship as CommonJS should use export = for modules that have a single main export ...
See https://github.com/DefinitelyTyped/DefinitelyTyped#arethetypeswrongcli-attw-checks:
When the implementation package uses module.exports = ..., the DefinitelyTyped package should use export =, not export default.
Reproduction:
// index.ts
import idStart from '@unicode/unicode-16.0.0/Binary_Property/ID_Start/code-points.js'
export const foo: number[] = idStart.default
export const bar: number[] = idStart
$ npm exec tsc -- --noEmit
index.ts:5:14 - error TS2740: Type 'typeof import("/tmp/repro/node_modules/@unicode/unicode-16.0.0/Binary_Property/ID_Start/code-points")' is missing the following properties from type 'number[]': length, pop, push, concat, and 29 more.
5 export const bar: number[] = idStart
~~~
Found 1 error in index.ts:5
Reproduction on TS Playground:
https://www.typescriptlang.org/play/?target=99&moduleResolution=99&module=100#code/JYWwDg9gTgLgBMAJgZRgQ1nAZlCI4DkAAgK4B2wAxhIgKYD05VNtAtAIwBsAdAAx-0AQsDIYAngH0ACrjC1YY+gEkAIhNQYY9anVaQRMAM7cAVoYIAoC7QAekTNTKH4WCBABccMiRAAjeQDaALpwALwIKOiw3HRYaCQANjBWtvbwjs5wvhie3n6BIeFIGrBAA
(for some reason TS playground refuses to accept compiler options passed through URL query string parameters, so it's required to open "TS Config" tab and select "Module" as Node16, Node18 or NodeNext.
node-unicode-data/scripts/utils.js
Lines 202 to 209 in 9d1e61d
module.exports =must be annotated withexport =type declaration.See https://www.typescriptlang.org/docs/handbook/modules/appendices/esm-cjs-interop.html#library-code-needs-special-considerations:
See https://github.com/DefinitelyTyped/DefinitelyTyped#arethetypeswrongcli-attw-checks:
Reproduction:
Reproduction on TS Playground:
https://www.typescriptlang.org/play/?target=99&moduleResolution=99&module=100#code/JYWwDg9gTgLgBMAJgZRgQ1nAZlCI4DkAAgK4B2wAxhIgKYD05VNtAtAIwBsAdAAx-0AQsDIYAngH0ACrjC1YY+gEkAIhNQYY9anVaQRMAM7cAVoYIAoC7QAekTNTKH4WCBABccMiRAAjeQDaALpwALwIKOiw3HRYaCQANjBWtvbwjs5wvhie3n6BIeFIGrBAA
(for some reason TS playground refuses to accept compiler options passed through URL query string parameters, so it's required to open "TS Config" tab and select "Module" as
Node16,Node18orNodeNext.