Skip to content

Commit 840a7ca

Browse files
committed
Add warning when TypeScript version is out of sync
1 parent 35806fd commit 840a7ca

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

packages/types/extract-dom-types.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77
import { DenoDir } from '@deno/cache-dir';
88
import { join } from '@std/path';
9+
import { lessThan, parse } from '@std/semver';
910
// n.b. ts-morph is a sibling devDependency of typescript, so that the module
1011
// loader will resolve our project's typescript package, not the transient
1112
// dependency of ts-morph. We only want to reference our typescript dependency
@@ -21,6 +22,18 @@ import {
2122
} from 'ts-morph';
2223
import { version as npmVersion } from 'typescript';
2324

25+
// Warn if the NPM "typescript" package is behind Deno's bundled TypeScript
26+
const denoTSVersion = Deno.version.typescript;
27+
const npmTS = parse(npmVersion);
28+
const denoTS = parse(denoTSVersion);
29+
30+
// Compare only major.minor (ignore patch) by zeroing it out before comparing
31+
if (lessThan({ ...npmTS, patch: 0 }, { ...denoTS, patch: 0 })) {
32+
console.warn(
33+
`⚠️ Types Mismatch: Extracting types from TypeScript ${npmVersion}, but Deno v${Deno.version.deno} is using TypeScript ${denoTSVersion}`,
34+
);
35+
}
36+
2437
// List of types we directly reference from the dom lib. Only interface and type
2538
// alias identifiers are valid, since other syntax types (class, function, var)
2639
// are implementations, which will not be available outside of the browser.

0 commit comments

Comments
 (0)