Typings for the node test module? #43249
-
Hi, are there any Typescript typings available for the node test module? I understand that its still experimental, but I was hoping to try it out in a side project with Typescript. At the moment Typescript complains that the module has no type declarations. I do have the Cheers. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
The typings for the Node.js runtime and it's built-in modules are mainly provided by So if you're using TypeScript, it's better to either test out the module by ignoring the missing typings declaration errors by using a // @ts-ignore: typings declaration for the `node:test` built-in module is not yet available.
import test from 'node:test'; Or if you don't want to use the |
Beta Was this translation helpful? Give feedback.
-
Correct me if I'm wrong, but nodejs doesn't support TypeScript out-of-the-box (like Deno does) correct? For example, even if I write my test file in javascript, any TypeScript function I import to be tested will not work, because it needs to be compiled first. |
Beta Was this translation helpful? Give feedback.
The typings for the Node.js runtime and it's built-in modules are mainly provided by
@types/node
, the typings for experimental APIs (such as thenode:test
built-in module) are mostly not available until the aforementioned APIs becomes stable.So if you're using TypeScript, it's better to either test out the module by ignoring the missing typings declaration errors by using a
@ts-ignore
directive:Or if you don't want to use the
@ts-ignore
directive, there's nothing much you can do other than declaring the typings yourself or just using JavaScript instead of TypeScript…