|
|
|
|
|
by uup
1344 days 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] }
|
|
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?