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

Commit f22a4c4

Browse files
authored
Update to 4.0, deprecate 2.8 (#287)
* Update to 4.0, deprecate 2.8 Also switch from definitelytyped-header-parser to @definitelytyped/header-parser, @definitelytyped/typescript-versions, @definitelytyped/utils. This brings a couple of updates, principally a new way of tracking which TS versions have shipped under the "latest" tag vs shipped under the "next" tag. dtslint tests *only* versions that have shipped under "latest", plus whatever is *currently* shipping under "next". It doesn't test any betas or RCs. Note that the new dependencies are currently closed source. We're waiting on the MS open source legal office to OK the new repos. * make range handle latest correctly * reindent tsconfig
1 parent a6974eb commit f22a4c4

File tree

10 files changed

+879
-129
lines changed

10 files changed

+879
-129
lines changed

package-lock.json

Lines changed: 832 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
"prepublishOnly": "npm run build && npm run test && npm run lint"
2828
},
2929
"dependencies": {
30-
"definitelytyped-header-parser": "3.9.0",
30+
"@definitelytyped/header-parser": "0.0.29",
31+
"@definitelytyped/typescript-versions": "0.0.29",
32+
"@definitelytyped/utils": "0.0.29",
3133
"dts-critic": "^3.0.2",
3234
"fs-extra": "^6.0.1",
3335
"json-stable-stringify": "^1.0.1",

src/checks.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import assert = require("assert");
2-
import { makeTypesVersionsForPackageJson, TypeScriptVersion } from "definitelytyped-header-parser";
2+
import { makeTypesVersionsForPackageJson } from "@definitelytyped/header-parser";
3+
import { TypeScriptVersion } from "@definitelytyped/typescript-versions";
34
import { pathExists } from "fs-extra";
45
import { join as joinPaths } from "path";
56

src/index.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
#!/usr/bin/env node
22

3-
import {
4-
AllTypeScriptVersion,
5-
isTypeScriptVersion,
6-
parseTypeScriptVersionLine,
7-
TypeScriptVersion,
8-
} from "definitelytyped-header-parser";
3+
import { AllTypeScriptVersion, TypeScriptVersion } from "@definitelytyped/typescript-versions";
4+
import { parseTypeScriptVersionLine, } from "@definitelytyped/header-parser";
95
import { readdir, readFile, stat } from "fs-extra";
106
import { basename, dirname, join as joinPaths, resolve } from "path";
117

128
import { checkPackageJson, checkTsconfig } from "./checks";
13-
import { cleanInstalls, installAll, installNext } from "./installer";
9+
import { installAllTypeScriptVersions, installTypeScriptNext, cleanTypeScriptInstalls } from "@definitelytyped/utils";
1410
import { checkTslintJson, lint, TsVersion } from "./lint";
1511
import { assertDefined, last, mapDefinedAsync, withoutPrefix } from "./util";
1612

@@ -36,8 +32,8 @@ async function main(): Promise<void> {
3632
case "--installAll":
3733
console.log("Cleaning old installs and installing for all TypeScript versions...");
3834
console.log("Working...");
39-
await cleanInstalls();
40-
await installAll();
35+
await cleanTypeScriptInstalls();
36+
await installAllTypeScriptVersions();
4137
return;
4238
case "--localTs":
4339
lookingForTsLocal = true;
@@ -79,14 +75,14 @@ async function main(): Promise<void> {
7975
listen(dirPath, tsLocal);
8076
// Do this *after* to ensure messages sent during installation aren't dropped.
8177
if (!tsLocal) {
82-
await installAll();
78+
await installAllTypeScriptVersions();
8379
}
8480
} else {
8581
if (!tsLocal) {
8682
if (onlyTestTsNext) {
87-
await installNext();
83+
await installTypeScriptNext();
8884
} else {
89-
await installAll();
85+
await installAllTypeScriptVersions();
9086
}
9187
}
9288
await runTests(dirPath, onlyTestTsNext, expectOnly, tsLocal);
@@ -140,7 +136,7 @@ async function runTests(
140136
const version = withoutPrefix(name, "ts");
141137
if (version === undefined || !(await stat(joinPaths(dirPath, name))).isDirectory()) { return undefined; }
142138

143-
if (!isTypeScriptVersion(version)) {
139+
if (!TypeScriptVersion.isTypeScriptVersion(version)) {
144140
throw new Error(`There is an entry named ${name}, but ${version} is not a valid TypeScript version.`);
145141
}
146142
if (!TypeScriptVersion.isRedirectable(version)) {

src/installer.ts

Lines changed: 0 additions & 84 deletions
This file was deleted.

src/lint.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import assert = require("assert");
2-
import { TypeScriptVersion } from "definitelytyped-header-parser";
2+
import { TypeScriptVersion } from "@definitelytyped/typescript-versions";
3+
import { typeScriptPath } from "@definitelytyped/utils";
34
import { pathExists } from "fs-extra";
45
import { join as joinPaths, normalize } from "path";
56
import { Configuration, ILinterOptions, Linter } from "tslint";
@@ -9,7 +10,6 @@ type IConfigurationFile = Configuration.IConfigurationFile;
910

1011
import { getProgram, Options as ExpectOptions } from "./rules/expectRule";
1112

12-
import { typeScriptPath } from "./installer";
1313
import { readJson, withoutPrefix } from "./util";
1414

1515
export async function lint(
@@ -186,15 +186,20 @@ function range(minVersion: TsVersion, maxVersion: TsVersion): ReadonlyArray<TsVe
186186
assert(maxVersion === "local");
187187
return ["local"];
188188
}
189+
if (minVersion === TypeScriptVersion.latest) {
190+
assert(maxVersion === TypeScriptVersion.latest);
191+
return [TypeScriptVersion.latest];
192+
}
189193
assert(maxVersion !== "local");
190194

191-
// The last item of TypeScriptVersion is the unreleased version of Typescript,
192-
// which is called 'next' on npm, so replace it with 'next'.
193-
const minIdx = TypeScriptVersion.supported.indexOf(minVersion);
195+
const minIdx = TypeScriptVersion.shipped.indexOf(minVersion);
194196
assert(minIdx >= 0);
195-
const maxIdx = TypeScriptVersion.supported.indexOf(maxVersion as TypeScriptVersion);
197+
if (maxVersion === TypeScriptVersion.latest) {
198+
return [...TypeScriptVersion.shipped.slice(minIdx), TypeScriptVersion.latest];
199+
}
200+
const maxIdx = TypeScriptVersion.shipped.indexOf(maxVersion as TypeScriptVersion);
196201
assert(maxIdx >= minIdx);
197-
return TypeScriptVersion.supported.slice(minIdx, maxIdx + 1);
202+
return TypeScriptVersion.shipped.slice(minIdx, maxIdx + 1);
198203
}
199204

200205
export type TsVersion = TypeScriptVersion | "local";

src/rules/dtHeaderRule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { renderExpected, validate } from "definitelytyped-header-parser";
1+
import { renderExpected, validate } from "@definitelytyped/header-parser";
22
import * as Lint from "tslint";
33
import * as ts from "typescript";
44
import { failure, isMainFile } from "../util";
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Type definitions for dt-header 1.0
22
// Project: https://github.com/bobby-headers/dt-header
33
// Definitions by: Jane Doe <https://github.com/jane doe>
4-
~ [Error parsing header. Expected: /\<https\:\/\/github\.com\/([a-zA-Z\d\-]+)\>/. See: https://github.com/Microsoft/dtslint/blob/master/docs/dt-header.md]
4+
~ [Error parsing header. Expected: /\<https\:\/\/github\.com\/([a-zA-Z\d\-]+)\/?\>/. See: https://github.com/Microsoft/dtslint/blob/master/docs/dt-header.md]
55
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Type definitions for dt-header 1.0
22
// Project: https://github.com/bobby-headers/dt-header
33
// Definitions by: Jane Doe <https://github.org/janedoe>
4-
~ [Error parsing header. Expected: /\<https\:\/\/github\.com\/([a-zA-Z\d\-]+)\>/. See: https://github.com/Microsoft/dtslint/blob/master/docs/dt-header.md]
4+
~ [Error parsing header. Expected: /\<https\:\/\/github\.com\/([a-zA-Z\d\-]+)\/?\>/. See: https://github.com/Microsoft/dtslint/blob/master/docs/dt-header.md]
55
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

tsconfig.json

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
{
2-
"compilerOptions": {
3-
"module": "commonjs",
4-
"target": "es6",
5-
"lib": ["es2017"],
6-
"outDir": "bin",
7-
"sourceMap": true,
8-
"newLine": "lf",
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"target": "es6",
5+
"lib": ["es2017"],
6+
"outDir": "bin",
7+
"sourceMap": true,
8+
"newLine": "lf",
99

10-
"noFallthroughCasesInSwitch": true,
11-
"noImplicitAny": true,
12-
"noImplicitReturns": true,
13-
"noImplicitThis": true,
14-
"noUnusedLocals": true,
15-
"noUnusedParameters": true,
16-
"strictNullChecks": true
17-
},
18-
"include": ["src"]
19-
}
10+
"noFallthroughCasesInSwitch": true,
11+
"noImplicitAny": true,
12+
"noImplicitReturns": true,
13+
"noImplicitThis": true,
14+
"noUnusedLocals": true,
15+
"noUnusedParameters": true,
16+
"strictNullChecks": true,
17+
"esModuleInterop": true
18+
},
19+
"include": ["src"]
20+
}

0 commit comments

Comments
 (0)