4 ms·
ts-node isn't an official part of the TypeScript project. It has notoriously bad module support. Try this: // tsconfig.json { "compilerOptions":
by uup 4y ago
ts-node isn't an official part of the TypeScript project. It has notoriously bad module support.
Try this:
// tsconfig.json
{
"compilerOptions": {
"outDir": "dist",
"module": "es2020",
"allowJs": true
},
"files": ["index.ts"]
}
// index.ts
import('./test.mjs').then(console.log)
> npx tsc && node ./dist/index.js
[Module: null prototype] { Foo: [Function: Foo] }
- kuramitropolis 4y agoI'm not even talking about the module support. (It just seems to have the default support of TypeScript.) Yes, it imports the module. No, it doesn't do even basic type inference (knowing that Foo is a class and consequently allowing it to be used as a type name) - which it would, if it was a superset of JS. Instead it seems to import everything as "any", which is... a start, I guess?