superstruct
superstruct copied to clipboard
Compatibility with moduleResolution: "Node16" is broken.
Sadly superstruct isn't compatible with the new module resolution algo. Should be fixed to be compatible in the future.
I spent some time looking into this issue, and I think it's caused by the missing .js
extension on the generated index.d.ts
type definitions file.
Here are the current contents of index.d.ts
:
export * from './error';
export * from './struct';
export * from './structs/coercions';
export * from './structs/refinements';
export * from './structs/types';
export * from './structs/utilities';
//# sourceMappingURL=index.d.ts.map
If I modify the file to look like this, then the issue is resolved.
export * from './error.js';
export * from './struct.js';
export * from './structs/coercions.js';
export * from './structs/refinements.js';
export * from './structs/types.js';
export * from './structs/utilities.js';
//# sourceMappingURL=index.d.ts.map
@ianstormtaylor, is there a way we can configure the build process so that it includes the .js
extension?
One solution is to change the tsconfig to use "moduleResolution": "node16"
in tsconfig.json
and then fix the import paths. This is pretty easy to do and I did this locally...
But... (isn't there always a but)... the tool babel/register
which is used by npm run test
does not support moduleResolution: node16
because it cannot find the file index.js
. This all makes sense. I think another tool needs to be used for the test.
Closing in this favour of #1200 (it is currently my priority to fix this).