Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
Drop support for 2.0 2.7 (#264)
Browse files Browse the repository at this point in the history
* Switch to supported versions of Typescript

I still need to update package-lock.json when I install the shipping
version of definitelytyped-header-parser.

* Upgrade definitelytyped-header-parser

Also fix some lint
  • Loading branch information
sandersn authored Nov 7, 2019
1 parent 2db27af commit 411f043
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"prepublishOnly": "npm run build && npm run test && npm run lint"
},
"dependencies": {
"definitelytyped-header-parser": "3.8.0",
"definitelytyped-header-parser": "3.8.1",
"dts-critic": "^2.2.0",
"fs-extra": "^6.0.1",
"request": "^2.88.0",
Expand Down
13 changes: 10 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#!/usr/bin/env node

import { isTypeScriptVersion, parseTypeScriptVersionLine, TypeScriptVersion } from "definitelytyped-header-parser";
import {
AllTypeScriptVersion,
isTypeScriptVersion,
parseTypeScriptVersionLine,
TypeScriptVersion,
} from "definitelytyped-header-parser";
import { readdir, readFile, stat } from "fs-extra";
import { basename, dirname, join as joinPaths, resolve } from "path";

Expand Down Expand Up @@ -192,7 +197,9 @@ async function testTypesVersion(
if (minVersionFromComment !== undefined && inTypesVersionDirectory) {
throw new Error(`Already in the \`ts${lowVersion}\` directory, don't need \`// TypeScript Version\`.`);
}
const minVersion = lowVersion || minVersionFromComment || TypeScriptVersion.lowest;
const minVersion = lowVersion
|| minVersionFromComment && TypeScriptVersion.isSupported(minVersionFromComment) && minVersionFromComment
|| TypeScriptVersion.lowest;

await checkTslintJson(dirPath, dt);
await checkTsconfig(dirPath, dt
Expand Down Expand Up @@ -230,7 +237,7 @@ function assertPathIsNotBanned(dirPath: string) {
}
}

function getTypeScriptVersionFromComment(text: string): TypeScriptVersion | undefined {
function getTypeScriptVersionFromComment(text: string): AllTypeScriptVersion | undefined {
const searchString = "// TypeScript Version: ";
const x = text.indexOf(searchString);
if (x === -1) {
Expand Down
6 changes: 3 additions & 3 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import { TsVersion } from "./lint";
const installsDir = path.join(os.homedir(), ".dts", "typescript-installs");

export async function installAll() {
for (const v of TypeScriptVersion.all) {
// manually instead typescript@next outside the loop
if (v === TypeScriptVersion.all[TypeScriptVersion.all.length - 1]) { continue; }
for (const v of TypeScriptVersion.supported) {
// manually install typescript@next outside the loop
if (v === TypeScriptVersion.supported[TypeScriptVersion.supported.length - 1]) { continue; }
await install(v);
}
await installNext();
Expand Down
2 changes: 1 addition & 1 deletion src/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ function range(minVersion: TsVersion, maxVersion: TsVersion): ReadonlyArray<TsVe

// The last item of TypeScriptVersion is the unreleased version of Typescript,
// which is called 'next' on npm, so replace it with 'next'.
const allReleased: TsVersion[] = [...TypeScriptVersion.all];
const allReleased: TsVersion[] = [...TypeScriptVersion.supported];
allReleased[allReleased.length - 1] = "next";
const minIdx = allReleased.indexOf(minVersion);
assert(minIdx >= 0);
Expand Down

0 comments on commit 411f043

Please sign in to comment.