diff --git a/packages/definitions-parser/src/check-parse-results.ts b/packages/definitions-parser/src/check-parse-results.ts index 57a6cb38f9..b8a88f32ca 100644 --- a/packages/definitions-parser/src/check-parse-results.ts +++ b/packages/definitions-parser/src/check-parse-results.ts @@ -161,7 +161,7 @@ async function checkNpm( log(" yarn not-needed " + yarnargs.join(" ")); log(` git add --all && git commit -m "${name}: Provides its own types" && git push -u origin not-needed-${name}`); log(` And comment PR: This will deprecate \`@types/${name}\` in favor of just \`${name}\`. CC ${contributorUrls}`); - if (semver.gt(`${major}.${minor}.0`, firstTypedVersion)) { + if (semver.gte(`${major}.${minor}.0`, firstTypedVersion)) { log(" WARNING: our version is greater!"); } if (dependedOn.has(name)) { diff --git a/packages/definitions-parser/src/git.ts b/packages/definitions-parser/src/git.ts index 4c7bf9d177..a9a9ab177e 100644 --- a/packages/definitions-parser/src/git.ts +++ b/packages/definitions-parser/src/git.ts @@ -20,7 +20,6 @@ import { UncachedNpmInfoClient, NpmInfo, } from "@definitelytyped/utils"; -import * as semver from "semver"; import { getAffectedPackages } from "./get-affected-packages"; export interface GitDiff { @@ -130,8 +129,7 @@ export async function getAffectedPackagesFromDiff( /** * 1. libraryName must exist on npm (SKIPPED and preferably/optionally have been the libraryName in just-deleted header) - * 2. asOfVersion must be newer than `@types/name@latest` on npm - * 3. `name@asOfVersion` must exist on npm + * 2. `name@asOfVersion` must exist on npm */ export function checkNotNeededPackage( unneeded: NotNeededPackage, @@ -145,15 +143,6 @@ export function checkNotNeededPackage( Unneeded packages have to be replaced with a package on npm.` ); typings = assertDefined(typings, `Unexpected error: @types package not found for ${unneeded.fullNpmName}`); - const latestTypings = assertDefined( - typings.distTags.get("latest"), - `Unexpected error: ${unneeded.fullNpmName} is missing the "latest" tag.` - ); - assert( - semver.gt(unneeded.version, latestTypings), - `The specified version ${unneeded.version} of ${unneeded.libraryName} must be newer than the version -it is supposed to replace, ${latestTypings} of ${unneeded.fullNpmName}.` - ); assert( source.versions.has(String(unneeded.version)), `The specified version ${unneeded.version} of ${unneeded.libraryName} is not on npm.` diff --git a/packages/definitions-parser/test/git.test.ts b/packages/definitions-parser/test/git.test.ts index ce7974f2b1..48fcd3fe09 100644 --- a/packages/definitions-parser/test/git.test.ts +++ b/packages/definitions-parser/test/git.test.ts @@ -82,33 +82,6 @@ testo({ "@types package not found for @types/jest" ); }, - missingTypingsLatest() { - expect(() => checkNotNeededPackage(jestNotNeeded[0], empty, empty)).toThrow( - '@types/jest is missing the "latest" tag' - ); - }, - deprecatedSameVersion() { - expect(() => { - checkNotNeededPackage(jestNotNeeded[0], empty, { - homepage: "jest.com", - distTags: new Map([["latest", "100.0.0"]]), - versions: new Map(), - time: new Map([["modified", ""]]), - }); - }).toThrow(`The specified version 100.0.0 of jest must be newer than the version -it is supposed to replace, 100.0.0 of @types/jest.`); - }, - deprecatedOlderVersion() { - expect(() => { - checkNotNeededPackage(jestNotNeeded[0], empty, { - homepage: "jest.com", - distTags: new Map([["latest", "999.0.0"]]), - versions: new Map(), - time: new Map([["modified", ""]]), - }); - }).toThrow(`The specified version 100.0.0 of jest must be newer than the version -it is supposed to replace, 999.0.0 of @types/jest.`); - }, missingNpmVersion() { expect(() => { checkNotNeededPackage(jestNotNeeded[0], empty, { @@ -138,7 +111,7 @@ it is supposed to replace, 999.0.0 of @types/jest.`); ) ).toThrow("The specified version 100.0.0 of jest is not on npm."); }, - ok() { + deprecatedNewerVersion() { checkNotNeededPackage( jestNotNeeded[0], { @@ -155,4 +128,38 @@ it is supposed to replace, 999.0.0 of @types/jest.`); } ); }, + deprecatedOlderVersion() { + checkNotNeededPackage( + jestNotNeeded[0], + { + homepage: "jest.com", + distTags: new Map(), + versions: new Map([["100.0.0", {}]]), + time: new Map([["modified", ""]]), + }, + { + homepage: "jest.com", + distTags: new Map([["latest", "999.0.0"]]), + versions: new Map(), + time: new Map([["modified", ""]]), + } + ); + }, + deprecatedSameVersion() { + checkNotNeededPackage( + jestNotNeeded[0], + { + homepage: "jest.com", + distTags: new Map(), + versions: new Map([["100.0.0", {}]]), + time: new Map([["modified", ""]]), + }, + { + homepage: "jest.com", + distTags: new Map([["latest", "100.0.0"]]), + versions: new Map(), + time: new Map([["modified", ""]]), + } + ); + }, });