From b0ae67cfa9b5e6a501b7c263aed4f99fcd1837e0 Mon Sep 17 00:00:00 2001 From: Jack Bates Date: Mon, 19 Oct 2020 09:04:36 -0700 Subject: [PATCH] Warn when matching npm package is deprecated --- index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.ts b/index.ts index 05375c8..bc005ce 100644 --- a/index.ts +++ b/index.ts @@ -206,6 +206,7 @@ export function getNpmInfo(name: string): NpmInfo { } return { isNpm: true, + deprecated: info.deprecated, versions: info.versions as string[], tags: info["dist-tags"] as { [tag: string]: string | undefined } }; @@ -215,7 +216,7 @@ export function getNpmInfo(name: string): NpmInfo { * Checks DefinitelyTyped non-npm package. */ function checkNonNpm(name: string, npmInfo: NpmInfo): NonNpmError | undefined { - if (npmInfo.isNpm && !isExistingSquatter(name)) { + if (npmInfo.isNpm && !npmInfo.deprecated && !isExistingSquatter(name)) { return { kind: ErrorKind.NonNpmHasMatchingPackage, message: `The non-npm package '${name}' conflicts with the existing npm package '${dtToNpmName(name)}'. @@ -233,7 +234,7 @@ Try adding -browser to the end of the name to get * If all checks are successful, returns the npm version that matches the header. */ function checkNpm(name: string, npmInfo: NpmInfo, header: headerParser.Header | undefined): NpmError | string { - if (!npmInfo.isNpm) { + if (!npmInfo.isNpm || npmInfo.deprecated) { return { kind: ErrorKind.NoMatchingNpmPackage, message: `Declaration file must have a matching npm package. @@ -977,6 +978,7 @@ interface NonNpm { interface Npm { isNpm: true, + deprecated?: string, versions: string[], tags: { [tag: string]: string | undefined }, }