How do I use the deno's node compatibility mode with definitely typed modules? I tried this but that didn't seem to work as intended.
/// <reference types='npm:@types/three' />
As of Deno v1.26.1
, TypeScript is not supported in Node compatibility mode. From the Node Compatibility Mode page in the manual:
TypeScript support
Currently, the compatibility mode does not support TypeScript.
In the upcoming releases we plan to add support for a
types
field inpackage.json
, to automatically lookup types and use them during type checking.In the long term, we'd like to provide ability to consume TypeScript code authored for the Node runtime.
If you just want the types from @types/three
in a normal Deno module, then simply import them like you normally would from a source which utilizes Deno's literal import specifier syntax (such as esm.sh):
import type { Vector3Tuple } from "https://esm.sh/@types/three/index.d.ts?pin=v96";
const triplet: Vector3Tuple = [2, 2, 2]; // ok
Or all of the types onto a namespace:
import type * as Three from "https://esm.sh/@types/three/index.d.ts?pin=v96";
const triplet: Three.Vector3Tuple = [2, 2, 2]; // ok