From 1c95ea2bedf9e38c65be4c0601d0569dbc4f8675 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 10 Oct 2023 06:57:47 -0700 Subject: [PATCH] Cleanup and TODOs 1. Check pnpm overrides 2. Remove done TODOs, or long-term ones that are now recorded in https://github.com/microsoft/definitelytyped-tools/issues/751 3. Clean up some unused code. 4. Rename some properties to be shorter. --- .../src/lib/definition-parser.ts | 10 ++- .../definitions-parser/src/lib/module-info.ts | 11 +--- packages/definitions-parser/src/packages.ts | 22 +++---- .../test/definition-parser.test.ts | 6 +- .../test/module-info.test.ts | 48 +++++++++++++- .../definitions-parser/test/packages.test.ts | 4 +- packages/definitions-parser/test/utils.ts | 4 +- .../dtslint-runner/src/check-parse-results.ts | 2 +- packages/dtslint-runner/src/main.ts | 2 +- packages/header-parser/README.md | 3 +- packages/header-parser/src/index.ts | 64 +++++++++++-------- packages/header-parser/test/index.test.ts | 61 ++++++------------ packages/publisher/src/calculate-versions.ts | 2 +- packages/publisher/src/generate-packages.ts | 4 +- .../publisher/test/generate-packages.test.ts | 6 +- packages/typescript-versions/src/index.ts | 2 - .../typescript-versions/test/index.test.ts | 4 +- 17 files changed, 140 insertions(+), 115 deletions(-) diff --git a/packages/definitions-parser/src/lib/definition-parser.ts b/packages/definitions-parser/src/lib/definition-parser.ts index e2440942f3..6df3952d61 100644 --- a/packages/definitions-parser/src/lib/definition-parser.ts +++ b/packages/definitions-parser/src/lib/definition-parser.ts @@ -269,9 +269,8 @@ async function combineDataForAllTypesVersions( typesVersions, files, license, - packageJsonDependencies: packageJson.dependencies as Record, - packageJsonDevDependencies: packageJson.devDependencies as Record, - // TODO: Add devDependencies here (aka testDependencies) + dependencies: packageJson.dependencies as Record, + devDependencies: packageJson.devDependencies as Record, contentHash: hash( hasPackageJson ? [...files, packageJsonName] : files, mapDefined(allTypesVersions, (a) => a.tsconfigPathsForHash), @@ -289,7 +288,7 @@ function getAllUniqueValues(records: readonly Record, not Map const { types, tests } = allReferencedFiles( tsconfig.files ?? [], fs, @@ -332,7 +330,7 @@ function getTypingDataForSingleTypesVersion( compilerOptions ); const usedFiles = new Set( - [...types.keys(), ...tests.keys(), "tsconfig.json", "tslint.json"].map((f) => + [...types.keys(), ...tests, "tsconfig.json", "tslint.json"].map((f) => slicePrefixes(f, "node_modules/@types/" + packageName + "/") ) ); diff --git a/packages/definitions-parser/src/lib/module-info.ts b/packages/definitions-parser/src/lib/module-info.ts index 87103ec2ee..c1059ec5e5 100644 --- a/packages/definitions-parser/src/lib/module-info.ts +++ b/packages/definitions-parser/src/lib/module-info.ts @@ -5,11 +5,6 @@ import { FS, assertDefined, sort } from "@definitelytyped/utils"; import { readFileAndThrowOnBOM } from "./definition-parser"; import { getMangledNameForScopedPackage } from "../packages"; -const extensions: Map = new Map(); -extensions.set(".d.ts", ""); // TODO: Inaccurate? -extensions.set(".d.mts", ".mjs"); -extensions.set(".d.cts", ".cjs"); - export function getDeclaredGlobals(all: Map): string[] { const globals = new Set(); for (const sourceFile of all.values()) { @@ -87,10 +82,10 @@ export function allReferencedFiles( packageName: string, moduleResolutionHost: ts.ModuleResolutionHost, compilerOptions: ts.CompilerOptions -): { types: Map; tests: Map } { +): { types: Map; tests: Set } { const seenReferences = new Set(); const types = new Map(); - const tests = new Map(); + const tests = new Set(); // The directory where the tsconfig/index.d.ts is - i.e., may be a version within the package const baseDirectory = path.resolve("/", fs.debugPath()); // The root of the package and all versions, i.e., the direct subdirectory of types/ @@ -143,7 +138,7 @@ export function allReferencedFiles( ) { types.set(relativeFileName, src); } else { - tests.set(relativeFileName, src); + tests.add(relativeFileName); } const refs = findReferencedFiles(src, packageName); diff --git a/packages/definitions-parser/src/packages.ts b/packages/definitions-parser/src/packages.ts index 05ff5e79e1..edcdcb00c7 100644 --- a/packages/definitions-parser/src/packages.ts +++ b/packages/definitions-parser/src/packages.ts @@ -136,12 +136,9 @@ export class AllPackages { return this.notNeeded; } - /** Returns all of the dependences *that have typings*, ignoring others, and including test dependencies. - * I have NO idea why it's an iterator. Surely not for efficiency. */ + /** Returns all of the dependencies *that are typed on DT*, ignoring others, and including test dependencies. */ *allDependencyTypings(pkg: TypingsData): Iterable { for (const [name, version] of pkg.allPackageJsonDependencies()) { - // TODO: chart.js@3 has types; @types/chart.js@2.9 is the last version on DT. - // It shouldn't be an error to depend on chart.js@3 but it's currently ambiguous with @types/chart.js. if (!name.startsWith(`@${scopeName}/`)) continue; if (pkg.name === name) continue; const typesDirectoryName = removeTypesScope(name); @@ -336,12 +333,12 @@ export interface TypingsDataRaw { * Packages that provide definitions that this package depends on. * NOTE: Includes `@types/` packages. */ - readonly packageJsonDependencies: PackageJsonDependencies; + readonly dependencies: PackageJsonDependencies; /** * Packages that this package's tests or other development depends on. */ - readonly packageJsonDevDependencies: PackageJsonDependencies; + readonly devDependencies: PackageJsonDependencies; /** * The [older] version of the library that this definition package refers to, as represented *on-disk*. @@ -493,18 +490,17 @@ export class TypingsData extends PackageBase { get license(): License { return this.data.license; } - // TODO: Rename this back to dependencies/devDependencies - get packageJsonDependencies(): PackageJsonDependencies { - return this.data.packageJsonDependencies ?? {}; + get dependencies(): PackageJsonDependencies { + return this.data.dependencies ?? {}; } - get packageJsonDevDependencies(): PackageJsonDependencies { - return this.data.packageJsonDevDependencies ?? {}; + get devDependencies(): PackageJsonDependencies { + return this.data.devDependencies ?? {}; } *allPackageJsonDependencies(): Iterable<[string, string]> { - for (const [name, version] of Object.entries(this.packageJsonDependencies)) { + for (const [name, version] of Object.entries(this.dependencies)) { yield [name, version]; } - for (const [name, version] of Object.entries(this.packageJsonDevDependencies)) { + for (const [name, version] of Object.entries(this.devDependencies)) { yield [name, version]; } } diff --git a/packages/definitions-parser/test/definition-parser.test.ts b/packages/definitions-parser/test/definition-parser.test.ts index 7e0715a75b..07b3f877ca 100644 --- a/packages/definitions-parser/test/definition-parser.test.ts +++ b/packages/definitions-parser/test/definition-parser.test.ts @@ -196,7 +196,7 @@ export * from 'buffer'; throw new Error(info.join("\n")); } expect(info).toBeDefined(); - expect(info["1.0"].packageJsonDependencies).toEqual({ "@types/node": "*" }); + expect(info["1.0"].dependencies).toEqual({ "@types/node": "*" }); }); it("errors on arbitrary path mapping", () => {}); it("supports node_modules passthrough path mapping", async () => { @@ -359,7 +359,7 @@ import route = require('@ember/routing/route'); if (Array.isArray(info)) { throw new Error(info.join("\n")); } - expect(info["2.8"].packageJsonDevDependencies).toEqual({ "@types/ember": "workspace:." }); + expect(info["2.8"].devDependencies).toEqual({ "@types/ember": "workspace:." }); }); it("doesn't omit dependencies if only some deep modules are declared", async () => { @@ -370,7 +370,7 @@ import route = require('@ember/routing/route'); if (Array.isArray(info)) { throw new Error(info.join("\n")); } - expect(info["5.1"].packageJsonDependencies).toEqual({ "@types/styled-components": "*" }); + expect(info["5.1"].dependencies).toEqual({ "@types/styled-components": "*" }); }); it("rejects relative references to other packages", async () => { diff --git a/packages/definitions-parser/test/module-info.test.ts b/packages/definitions-parser/test/module-info.test.ts index feb61d5ba4..7d2d7e37be 100644 --- a/packages/definitions-parser/test/module-info.test.ts +++ b/packages/definitions-parser/test/module-info.test.ts @@ -2,7 +2,7 @@ import * as ts from "typescript"; import { createModuleResolutionHost } from "@definitelytyped/utils"; import { DTMock, createMockDT } from "../src/mocks"; import { testo } from "./utils"; -import { allReferencedFiles } from "../src/lib/module-info"; +import { allReferencedFiles, createSourceFile, getDeclaredGlobals } from "../src/lib/module-info"; const fs = createMockDT().fs; const moduleResolutionHost = createModuleResolutionHost(fs); @@ -140,3 +140,49 @@ testo({ expect(Array.from(tests.keys())).toEqual([]); }, }); +testo({ + getDeclaredGlobalsFindsExportAsNamespace() { + expect( + getDeclaredGlobals( + new Map([ + [ + "index.d.ts", + createSourceFile( + "index.d.ts", + "export type T = 1; export as namespace jQuery", + moduleResolutionHost, + compilerOptions + ), + ], + ]) + ) + ).toEqual(["jQuery"]); + }, + getDeclaredGlobalsFindsGlobalDeclarations() { + // non-modules: namespaces, vars, enum, class, function + // NOT for interface, type alias, import= + expect( + getDeclaredGlobals( + new Map([ + [ + "index.d.ts", + createSourceFile( + "index.d.ts", + ` + type T = 1; + interface I { i } + var i, j: I + enum E { e } + class C {} + function f() {} + namespace n { export type T = 1; export var value: "make sure n is a value namespace" } + `, + moduleResolutionHost, + compilerOptions + ), + ], + ]) + ) + ).toEqual(["C", "E", "f", "i", "j", "n"]); + }, +}); diff --git a/packages/definitions-parser/test/packages.test.ts b/packages/definitions-parser/test/packages.test.ts index 9e9d9b533e..a851c39ca4 100644 --- a/packages/definitions-parser/test/packages.test.ts +++ b/packages/definitions-parser/test/packages.test.ts @@ -152,10 +152,10 @@ describe(TypingsData, () => { expect(data.contentHash).toBe("11111111111111"); expect(data.projectName).toBe("zombo.com"); expect(data.globals).toEqual([]); - expect(data.packageJsonDependencies).toEqual({ + expect(data.dependencies).toEqual({ "dependency-1": "*", }); - expect(data.packageJsonDevDependencies).toEqual({ + expect(data.devDependencies).toEqual({ "@types/known": "workspace:.", }); expect(data.id).toEqual({ diff --git a/packages/definitions-parser/test/utils.ts b/packages/definitions-parser/test/utils.ts index f45007e6e9..211b465001 100644 --- a/packages/definitions-parser/test/utils.ts +++ b/packages/definitions-parser/test/utils.ts @@ -26,8 +26,8 @@ export function createTypingsVersionRaw( files: ["index.d.ts"], typesVersions: [], license: License.MIT, - packageJsonDependencies: dependencies, - packageJsonDevDependencies: devDependencies, + dependencies: dependencies, + devDependencies: devDependencies, contentHash: "11111111111111", globals: [], }, diff --git a/packages/dtslint-runner/src/check-parse-results.ts b/packages/dtslint-runner/src/check-parse-results.ts index 2ef7b154c0..805d7a0d06 100644 --- a/packages/dtslint-runner/src/check-parse-results.ts +++ b/packages/dtslint-runner/src/check-parse-results.ts @@ -18,5 +18,5 @@ export function checkParseResults(allPackages: AllPackages): string[] { } } } - return errors; + return errors } diff --git a/packages/dtslint-runner/src/main.ts b/packages/dtslint-runner/src/main.ts index 476f1146be..608b9204d4 100644 --- a/packages/dtslint-runner/src/main.ts +++ b/packages/dtslint-runner/src/main.ts @@ -153,7 +153,7 @@ export async function runDTSLint({ suggestionLines.push(`"${packageName}": [${suggestions.join(",")}]`); } } - // console.log(`{${suggestionLines.join(",")}}`); + console.log(`{${suggestionLines.join(",")}}`); logPerformance(); diff --git a/packages/header-parser/README.md b/packages/header-parser/README.md index d48243a55a..39f840add3 100644 --- a/packages/header-parser/README.md +++ b/packages/header-parser/README.md @@ -1,6 +1,7 @@ # DefinitelyTyped Header Parser -This library parses headers of [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped) types. +This library parses package.jsons of [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped) types. +Its name is left over from when package information was stored in textual headers. # Contributing diff --git a/packages/header-parser/src/index.ts b/packages/header-parser/src/index.ts index c4091887d7..6ab87e18f8 100644 --- a/packages/header-parser/src/index.ts +++ b/packages/header-parser/src/index.ts @@ -2,22 +2,6 @@ import { AllTypeScriptVersion, TypeScriptVersion } from "@definitelytyped/typesc import assert = require("assert"); import { deepEquals, parsePackageSemver } from "@definitelytyped/utils"; -// TODO: -// 1. Convert this package into a packageJson checker -// 2. Move checks from dt-header into dtslint/checks.ts and remove the rule. -// 4. Add test for header in dtslint that forbids it. -// 5. Update dts-gen and DT README and ??? -- rest of ecosystem. -/* - - # Example header format # - - // Type definitions for foo 1.2 - // Project: https://github.com/foo/foo, https://foo.com - // Definitions by: My Self , Some Other Guy - // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - // TypeScript Version: 2.1 - -*/ // used in dts-critic export interface Header { readonly nonNpm: boolean; @@ -70,14 +54,6 @@ export function validatePackageJson( ): Header | string[] { const errors = []; const needsTypesVersions = typesVersions.length !== 0; - // NOTE: I had to install eslint-plugin-import in DT because DT-tools hasn't shipped a new version - // DONE: normal package: 3box - // DONE: scoped package: adeira__js - // DONE: old-version package: gulp/v3 - // DONE: old-TS-version package: har-format - // DONE: react - // DONE: node - // TODO: Some spelling correction would be nice here, especially for typeScriptVersion's case. for (const key in packageJson) { switch (key) { case "private": @@ -94,12 +70,10 @@ export function validatePackageJson( case "contributors": case "nonNpm": case "nonNpmDescription": + case "pnpm": // "dependencies" / "license" checked by types-publisher, // TODO: asserts for other fields in types-publisher break; - case "pnpm": - // TODO: write validation rules for pnpm property (should just be overrides, and those should probably be restricted somehow) - break; case "typesVersions": case "types": if (!needsTypesVersions) { @@ -163,6 +137,7 @@ export function validatePackageJson( const typeScriptVersionResult = validateTypeScriptVersion(); const projectsResult = validateProjects(); const contributorsResult = validateContributors(); + const pnpmResult = validatePnpm(); if (typeof nameResult === "object") { errors.push(...nameResult.errors); } else { @@ -194,6 +169,9 @@ export function validatePackageJson( } else { contributors = contributorsResult; } + if (typeof pnpmResult === "object") { + errors.push(...pnpmResult.errors); + } if (errors.length) { return errors; } else { @@ -320,6 +298,38 @@ export function validatePackageJson( } return { errors }; } + function validatePnpm(): undefined | { errors: string[] } { + const errors = []; + if (packageJson.pnpm) { + if (typeof packageJson.pnpm !== "object" || packageJson.pnpm === null) { + errors.push( + `${typesDirectoryName}'s package.json has bad "pnpm": must be an object like { "overrides": { "@types/react": "^16" } }` + ); + } else { + for (const key in packageJson.pnpm) { + if (key !== "overrides") { + errors.push( + `${typesDirectoryName}'s package.json has bad "pnpm": it should not include property "${key}", only "overrides".` + ); + } + } + const overrides = (packageJson.pnpm as Record).overrides; + if (overrides && typeof overrides === "object" && overrides !== null) { + for (const key in overrides) { + if (!key.startsWith("@types/")) { + errors.push(`${typesDirectoryName}'s package.json has bad "pnpm": pnpm overrides may only override @types/ packages.`); + } + } + } else { + errors.push(`${typesDirectoryName}'s package.json has bad "pnpm": it must contain an "overrides" object.`); + } + } + } + if (errors.length) { + return { errors }; + } + return undefined; + } } function checkPackageJsonContributors(packageName: string, packageJsonContributors: readonly unknown[]) { diff --git a/packages/header-parser/test/index.test.ts b/packages/header-parser/test/index.test.ts index 3b75198db6..b0f9ea4bd1 100644 --- a/packages/header-parser/test/index.test.ts +++ b/packages/header-parser/test/index.test.ts @@ -1,4 +1,3 @@ -import { TypeScriptVersion } from "@definitelytyped/typescript-versions"; import { validatePackageJson, makeTypesVersionsForPackageJson } from "../src"; describe("validatePackageJson", () => { @@ -40,6 +39,11 @@ describe("validatePackageJson", () => { }, ], }; + const header = { ...pkgJson, nonNpm: false, libraryMajorVersion: 18, libraryMinorVersion: 0 }; + delete (header as any).dependencies; + delete (header as any).devDependencies; + delete (header as any).private; + delete (header as any).version; it("requires private: true", () => { const pkg = { ...pkgJson }; delete pkg.private; @@ -94,48 +98,25 @@ describe("validatePackageJson", () => { it("works with old-version packages", () => { expect(Array.isArray(validatePackageJson("hapi", { ...pkgJson, version: "16.6.99999" }, []))).toBeFalsy(); }); -}); - -describe("isSupported", () => { - it("works", () => { - expect(TypeScriptVersion.isSupported("5.0")).toBeTruthy(); - }); - it("supports oldest", () => { - expect(TypeScriptVersion.isSupported("4.5")).toBeTruthy(); - }); - it("does not support just before oldest", () => { - expect(!TypeScriptVersion.isSupported("4.4")).toBeTruthy(); - }); -}); - -describe("isTypeScriptVersion", () => { - it("accepts in-range", () => { - expect(TypeScriptVersion.isTypeScriptVersion("5.0")).toBeTruthy(); - }); - it("rejects out-of-range", () => { - expect(TypeScriptVersion.isTypeScriptVersion("101.1")).toBeFalsy(); - }); - it("rejects garbage", () => { - expect(TypeScriptVersion.isTypeScriptVersion("it'sa me, luigi")).toBeFalsy(); - }); -}); - -describe("range", () => { - it("works", () => { - expect(TypeScriptVersion.range("4.9")).toEqual(["4.9", "5.0", "5.1", "5.2", "5.3"]); + it("requires pnpm to be an object", () => { + expect(validatePackageJson("hapi", { ...pkgJson, pnpm: "not an object" }, [])).toEqual([ + `hapi's package.json has bad "pnpm": must be an object like { "overrides": { "@types/react": "^16" } }`, + ]); }); - it("includes oldest and above", () => { - expect(TypeScriptVersion.range("4.5")).toEqual(TypeScriptVersion.supported); + it("requires pnpm to contain exactly overrides", () => { + expect(validatePackageJson("hapi", { ...pkgJson, pnpm: { unexpected: true } }, [])).toEqual([ + `hapi's package.json has bad "pnpm": it should not include property "unexpected", only "overrides".`, + `hapi's package.json has bad "pnpm": it must contain an "overrides" object.`, + ]); }); -}); - -describe("tagsToUpdate", () => { - it("works", () => { - expect(TypeScriptVersion.tagsToUpdate("5.0")).toEqual(["ts5.0", "ts5.1", "ts5.2", "ts5.3", "latest"]); + it("pnpm may only override types packages", () => { + expect(validatePackageJson("hapi", { ...pkgJson, pnpm: { overrides: { vinland: "^1" } } }, [])).toEqual([ + `hapi's package.json has bad "pnpm": pnpm overrides may only override @types/ packages.`, + ]); }); - it("allows 4.5 onwards", () => { - expect(TypeScriptVersion.tagsToUpdate("4.5")).toEqual( - TypeScriptVersion.supported.map((s) => "ts" + s).concat("latest") + it("pnpm overrides work", () => { + expect(validatePackageJson("hapi", { ...pkgJson, pnpm: { overrides: { "@types/react": "^16" } } }, [])).toEqual( + header ); }); }); diff --git a/packages/publisher/src/calculate-versions.ts b/packages/publisher/src/calculate-versions.ts index 96a6d63246..cf0628d2ca 100644 --- a/packages/publisher/src/calculate-versions.ts +++ b/packages/publisher/src/calculate-versions.ts @@ -56,7 +56,7 @@ async function computeChangedPackages(allPackages: AllPackages, log: LoggerWithE const { version, needsPublish } = await fetchTypesPackageVersionInfo(pkg, /*publish*/ true, log); if (needsPublish) { log.info(`Need to publish: ${pkg.desc}@${version}`); - for (const name of Object.keys(pkg.packageJsonDependencies)) { + for (const name of Object.keys(pkg.dependencies)) { // Assert that dependencies exist on npm. // Also checked when we install the dependencies, in dtslint-runner. await pacote.manifest(name, { cache: cacheDir }).catch((reason) => { diff --git a/packages/publisher/src/generate-packages.ts b/packages/publisher/src/generate-packages.ts index 13caeaf166..565cca52ba 100644 --- a/packages/publisher/src/generate-packages.ts +++ b/packages/publisher/src/generate-packages.ts @@ -135,7 +135,7 @@ export function createPackageJSON(typing: TypingsData, version: string): string directory: `types/${typing.typesDirectoryName}`, }, scripts: {}, - dependencies: typing.packageJsonDependencies, + dependencies: typing.dependencies, typesPublisherContentHash: typing.contentHash, typeScriptVersion: typing.minTypeScriptVersion, nonNpm: typing.nonNpm ? typing.nonNpm : undefined, @@ -192,7 +192,7 @@ export function createReadme(typing: TypingsData, packageFS: FS): string { lines.push(""); lines.push("### Additional Details"); lines.push(` * Last updated: ${new Date().toUTCString()}`); - const dependencies = Object.keys(typing.packageJsonDependencies).sort(); + const dependencies = Object.keys(typing.dependencies).sort(); lines.push( ` * Dependencies: ${ dependencies.length ? dependencies.map((d) => `[${d}](https://npmjs.com/package/${d})`).join(", ") : "none" diff --git a/packages/publisher/test/generate-packages.test.ts b/packages/publisher/test/generate-packages.test.ts index b78b2c58f4..e4404d0056 100644 --- a/packages/publisher/test/generate-packages.test.ts +++ b/packages/publisher/test/generate-packages.test.ts @@ -22,8 +22,8 @@ function createRawPackage(license: License): TypingsDataRaw { typesVersions: [], files: ["index.d.ts", "jquery.test.ts"], license, - packageJsonDependencies: { "@types/madeira": "^1", balzac: "~3" }, - packageJsonDevDependencies: { "@types/jquery": "workspace:." }, + dependencies: { "@types/madeira": "^1", balzac: "~3" }, + devDependencies: { "@types/jquery": "workspace:." }, contentHash: "11", globals: [], }; @@ -76,7 +76,7 @@ testo({ }, readmeMultipleDependencies() { const typing = new TypingsData(createRawPackage(License.Apache20), /*isLatest*/ true); - typing.packageJsonDependencies["@types/example"] = "*"; + typing.dependencies["@types/example"] = "*"; expect(createReadme(typing, defaultFS())).toEqual( expect.stringContaining( "Dependencies: [@types/example](https://npmjs.com/package/@types/example), [@types/madeira](https://npmjs.com/package/@types/madeira)" diff --git a/packages/typescript-versions/src/index.ts b/packages/typescript-versions/src/index.ts index 01620c2a15..efd683359d 100644 --- a/packages/typescript-versions/src/index.ts +++ b/packages/typescript-versions/src/index.ts @@ -95,8 +95,6 @@ export namespace TypeScriptVersion { "4.3", "4.4", ]; - // TODO: All the tests for this are in header-parser, but should be here - // because I'm going to delete header-parser export const all: readonly AllTypeScriptVersion[] = [...unsupported, ...supported]; export const lowest = supported[0]; /** Latest version that may be specified in a `// TypeScript Version:` header. */ diff --git a/packages/typescript-versions/test/index.test.ts b/packages/typescript-versions/test/index.test.ts index 176d6358e3..8a8ff024cb 100644 --- a/packages/typescript-versions/test/index.test.ts +++ b/packages/typescript-versions/test/index.test.ts @@ -30,7 +30,7 @@ describe("isSupported", () => { describe("isTypeScriptVersion", () => { it("accepts in-range", () => { - expect(TypeScriptVersion.isTypeScriptVersion("4.5")).toBeTruthy(); + expect(TypeScriptVersion.isTypeScriptVersion("5.0")).toBeTruthy(); }); it("rejects out-of-range", () => { expect(TypeScriptVersion.isTypeScriptVersion("101.1")).toBeFalsy(); @@ -42,7 +42,7 @@ describe("isTypeScriptVersion", () => { describe("range", () => { it("works", () => { - expect(TypeScriptVersion.range("4.7")).toEqual(["4.7", "4.8", "4.9", "5.0", "5.1", "5.2", "5.3"]); + expect(TypeScriptVersion.range("4.9")).toEqual(["4.9", "5.0", "5.1", "5.2", "5.3"]); }); it("includes 4.5 onwards", () => { expect(TypeScriptVersion.range("4.5")).toEqual(TypeScriptVersion.supported);