DenoDDeno
Powered by
scarfS
Denoβ€’2y ago
scarf

type checking `.js` files using `d.ts` files

would it be possible to type check javascript files using
d.ts
d.ts
files?
// add.js
/// <reference types="./add.d.ts" />
const add = (a) => a + 1
// add.js
/// <reference types="./add.d.ts" />
const add = (a) => a + 1

// add.d.ts
export declare const add: (a: number) => number
// add.d.ts
export declare const add: (a: number) => number

importing
add
add
from
add.js
add.js
from consumer will type check but
Deno banner
DenoJoin
Chat about Deno, a modern runtime for JavaScript and TypeScript.
20,944Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

Can I disable type checking for specific files or folders?
MoomooMMoomoo / help
4y ago
how do I use `@ts-self-types` without `.d.ts` files appearing in docs?
Samual 🦒SSamual 🦒 / help
14mo ago
Type checking with tanstack router
Steve ASSteve A / help
7mo ago