-
-
Notifications
You must be signed in to change notification settings - Fork 155
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
typescript with ts-node and ESM support #47
Comments
Thanks. Time permitting I'll send a pull request with a sample. Till then, I'm subscribed to this thread and can answer questions. |
I'm looking for a solution on this as well |
FWIW, here's a configuration for Mocha, TypeScript, and ESM that finally worked for me:
|
@jordansexton Thank you so much, that worked for me! package.json{
"type": "module"
} tsconfig.json{
"compilerOptions": {
"module": "esnext",
"moduleResolution": "node",
}
} .mocharc.json{
"node-option": [
"experimental-specifier-resolution=node",
"loader=ts-node/esm"
]
} |
Thanks to all of you here, it helped me a lot :-) I would simply add that one requirement is to use
|
Also added a sanity test! Many thanks to the posters at: - https://dev.to/daniel_werner/testing-typescript-with-mocha-and-chai-5cl8 - https://gist.github.com/jordansexton/2a0c3c360aa700cc9528e89620e82c3d - mochajs/mocha-examples#47
mocha + sinon + chai. ESM + typescript is hard :-/ Editor TS, build TS and spec TS don't want to agree on module imports. On top of that — Jakefile can not be ESM yet. So src/ and /spec are modules, and project is not. --watch won't work unless ran with --parallel mochajs/mocha#4374 mochajs/mocha-examples#47 https://gist.github.com/jordansexton/2a0c3c360aa700cc9528e89620e82c3d
mocha + sinon + chai. ESM + typescript is hard :-/ Editor TS, build TS and spec TS don't want to agree on module imports. On top of that — Jakefile can not be ESM yet. So src/ and /spec are modules, and project is not. --watch won't work unless ran with --parallel mochajs/mocha#4374 mochajs/mocha-examples#47 https://gist.github.com/jordansexton/2a0c3c360aa700cc9528e89620e82c3d
Hi everyone else from search results. This only works on node 16, Newer nodes don't like, and don't need(?) the |
I'm unable to find an example like this: I can't import from chai:
|
Add a typescript sample using ts-node and node's native ESM support.
Note: ts-node uses Node's loader-hooks which are still experimental.
You can find info: ts-node/1007
and a working sample: ts-node/discussion
The text was updated successfully, but these errors were encountered: