diff --git a/packages/definitions-parser/package.json b/packages/definitions-parser/package.json index 9f421e6cd6..bb0ccb4caf 100644 --- a/packages/definitions-parser/package.json +++ b/packages/definitions-parser/package.json @@ -20,6 +20,7 @@ }, "dependencies": { "@definitelytyped/header-parser": "^0.0.23-next.0", + "@definitelytyped/typescript-versions": "0.0.23-next.0", "@definitelytyped/utils": "^0.0.23-next.0", "@types/node": "^12.12.29", "fs-extra": "^8.1.0", diff --git a/packages/definitions-parser/src/lib/definition-parser.ts b/packages/definitions-parser/src/lib/definition-parser.ts index 381779e89d..6de84eb76a 100644 --- a/packages/definitions-parser/src/lib/definition-parser.ts +++ b/packages/definitions-parser/src/lib/definition-parser.ts @@ -24,9 +24,9 @@ import { join, flatMap, unique, - unmangleScopedPackage, - TypeScriptVersion + unmangleScopedPackage } from "@definitelytyped/utils"; +import { TypeScriptVersion } from "@definitelytyped/typescript-versions"; function matchesVersion(typingsDataRaw: TypingsDataRaw, version: TypingVersion, considerLibraryMinorVersion: boolean) { return ( diff --git a/packages/definitions-parser/src/packages.ts b/packages/definitions-parser/src/packages.ts index a0d405c3a5..079c62a362 100644 --- a/packages/definitions-parser/src/packages.ts +++ b/packages/definitions-parser/src/packages.ts @@ -1,14 +1,7 @@ import assert = require("assert"); import { Author } from "@definitelytyped/header-parser"; -import { - FS, - mapValues, - assertSorted, - unmangleScopedPackage, - Semver, - TypeScriptVersion, - AllTypeScriptVersion -} from "@definitelytyped/utils"; +import { FS, mapValues, assertSorted, unmangleScopedPackage, Semver } from "@definitelytyped/utils"; +import { AllTypeScriptVersion, TypeScriptVersion } from "@definitelytyped/typescript-versions"; import { readDataFile } from "./data-file"; import { scopeName, typesDirectoryName } from "./lib/settings"; import { parseVersionFromDirectoryName } from "./parse-definitions"; diff --git a/packages/header-parser/package.json b/packages/header-parser/package.json index b01a0cb844..ea251b3cef 100644 --- a/packages/header-parser/package.json +++ b/packages/header-parser/package.json @@ -20,7 +20,7 @@ "url": "https://github.com/DefinitelyTyped/tools/issues" }, "dependencies": { - "@definitelytyped/utils": "^0.0.23-next.0", + "@definitelytyped/typescript-versions": "0.0.23-next.0", "@types/parsimmon": "^1.10.1", "parsimmon": "^1.13.0" }, diff --git a/packages/header-parser/src/index.ts b/packages/header-parser/src/index.ts index ae68af4c1e..55467a978c 100644 --- a/packages/header-parser/src/index.ts +++ b/packages/header-parser/src/index.ts @@ -1,5 +1,5 @@ import pm = require("parsimmon"); -import { AllTypeScriptVersion, TypeScriptVersion } from "@definitelytyped/utils"; +import { AllTypeScriptVersion, TypeScriptVersion } from "@definitelytyped/typescript-versions"; /* @@ -36,10 +36,6 @@ export interface ParseError { readonly expected: readonly string[]; } -export function isTypeScriptVersion(str: string): str is TypeScriptVersion { - return TypeScriptVersion.all.includes(str as TypeScriptVersion); -} - export function makeTypesVersionsForPackageJson(typesVersions: readonly TypeScriptVersion[]): unknown { if (typesVersions.length === 0) { return undefined; diff --git a/packages/publisher/package-lock.json b/packages/publisher/package-lock.json index b4ce4f20bd..cea1277fd3 100644 --- a/packages/publisher/package-lock.json +++ b/packages/publisher/package-lock.json @@ -663,7 +663,7 @@ "json-stable-stringify": "^1.0.1", "strip-json-comments": "^2.0.1", "tslint": "5.14.0", - "typescript": "^3.9.0-dev.20200413", + "typescript": "^3.9.0-dev.20200414", "yargs": "^15.1.0" }, "dependencies": { @@ -5083,9 +5083,9 @@ "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=" }, "typescript": { - "version": "3.9.0-dev.20200413", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.0-dev.20200413.tgz", - "integrity": "sha512-wpPljcRc3uLTVpQ8mtKTkS42ipVnW1E7lU5iII+JSKaUDH1ymeo3duvMz8o2sCRUDoZR0SE0SLcinaZ1q4gD7A==" + "version": "3.9.0-dev.20200414", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.0-dev.20200414.tgz", + "integrity": "sha512-wqAPcJUX4SPnySVpP58Vh09b4ncxxHdwP9HaPP9YTaOGHS3PyychJcbvMBqlKVXdvBvhHoacVDSB0Agn2zu4hA==" }, "underscore": { "version": "1.10.2", diff --git a/packages/publisher/package.json b/packages/publisher/package.json index 351c3d6612..faeff7b7f7 100644 --- a/packages/publisher/package.json +++ b/packages/publisher/package.json @@ -8,6 +8,7 @@ "dependencies": { "@definitelytyped/definitions-parser": "^0.0.23-next.0", "@definitelytyped/header-parser": "^0.0.23-next.0", + "@definitelytyped/typescript-versions": "0.0.23-next.0", "@definitelytyped/utils": "^0.0.23-next.0", "@octokit/rest": "^16.1.0", "adal-node": "^0.1.22", diff --git a/packages/publisher/src/lib/package-publisher.ts b/packages/publisher/src/lib/package-publisher.ts index 68aac3a693..5e73b69af8 100644 --- a/packages/publisher/src/lib/package-publisher.ts +++ b/packages/publisher/src/lib/package-publisher.ts @@ -1,12 +1,5 @@ import assert = require("assert"); -import { - Logger, - joinPaths, - readFileAndWarn, - TypeScriptVersion, - NpmPublishClient, - Registry -} from "@definitelytyped/utils"; +import { Logger, joinPaths, readFileAndWarn, NpmPublishClient, Registry } from "@definitelytyped/utils"; import { NotNeededPackage, AnyPackage } from "@definitelytyped/definitions-parser"; import { ChangedTyping } from "./versions"; import { outputDirectory } from "../util/util"; diff --git a/packages/typescript-versions/README.md b/packages/typescript-versions/README.md new file mode 100644 index 0000000000..6828729237 --- /dev/null +++ b/packages/typescript-versions/README.md @@ -0,0 +1,3 @@ +# @definitelytyped/typescript-versions + +List of supported TypeScript versions. diff --git a/packages/typescript-versions/package.json b/packages/typescript-versions/package.json new file mode 100644 index 0000000000..14510fd5d8 --- /dev/null +++ b/packages/typescript-versions/package.json @@ -0,0 +1,19 @@ +{ + "name": "@definitelytyped/typescript-versions", + "version": "0.0.23-next.0", + "description": "List of supported TypeScript versions", + "author": "Andrew Branch ", + "homepage": "https://github.com/microsoft/DefinitelyTyped-tools#readme", + "license": "MIT", + "main": "dist/index.js", + "publishConfig": { + "access": "public" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/microsoft/DefinitelyTyped-tools.git" + }, + "bugs": { + "url": "https://github.com/microsoft/DefinitelyTyped-tools/issues" + } +} diff --git a/packages/typescript-versions/src/index.ts b/packages/typescript-versions/src/index.ts new file mode 100644 index 0000000000..1a8652ae78 --- /dev/null +++ b/packages/typescript-versions/src/index.ts @@ -0,0 +1,126 @@ +import assert from "assert"; + +/* + + # How to add new version of Typescript # + + For the RC: + + 1. Add a new version to the end of `supportedTags`. + 2. Update failing tests. + 3. Publish and update dependents. + + For the release: + + 1. Add new versions to the end of `TypeScriptVersion` and `supported`. + 2. Update failing tests. + 3. Publish and update dependents. + + # How to deprecate versions on Definitely Typed # + + 1. Move versions from `TypeScriptVersion` to `UnsupportedTypeScriptVersion`. + 2. Move versions from `supported` to `unsupported`. + 3. Remove entry from `supportedTags`. + 4. Update failing tests. + 5. Publish and update dependents. + +*/ + +/** Parseable but unsupported TypeScript versions. */ +export type UnsupportedTypeScriptVersion = "2.0" | "2.1" | "2.2" | "2.3" | "2.4" | "2.5" | "2.6" | "2.7"; +/** + * Parseable and supported TypeScript versions. + * Only add to this list if we will support this version on DefinitelyTyped. + */ +export type TypeScriptVersion = + | "2.8" + | "2.9" + | "3.0" + | "3.1" + | "3.2" + | "3.3" + | "3.4" + | "3.5" + | "3.6" + | "3.7" + | "3.8" + | "3.9"; + +export type AllTypeScriptVersion = UnsupportedTypeScriptVersion | TypeScriptVersion; + +export namespace TypeScriptVersion { + export const supported: readonly TypeScriptVersion[] = [ + "2.8", + "2.9", + "3.0", + "3.1", + "3.2", + "3.3", + "3.4", + "3.5", + "3.6", + "3.7", + "3.8", + "3.9" + ]; + export const unsupported: readonly UnsupportedTypeScriptVersion[] = [ + "2.0", + "2.1", + "2.2", + "2.3", + "2.4", + "2.5", + "2.6", + "2.7" + ]; + export const all: readonly AllTypeScriptVersion[] = [...unsupported, ...supported]; + export const lowest = supported[0]; + /** Latest version that may be specified in a `// TypeScript Version:` header. */ + export const latest = supported[supported.length - 1]; + + /** @deprecated */ + export function isPrerelease(_version: TypeScriptVersion): boolean { + return false; + } + + export function isSupported(v: AllTypeScriptVersion): v is TypeScriptVersion { + return supported.indexOf(v as TypeScriptVersion) > -1; + } + + export function range(min: TypeScriptVersion): readonly TypeScriptVersion[] { + return supported.filter(v => v >= min); + } + + const supportedTags: readonly string[] = [ + "ts2.8", + "ts2.9", + "ts3.0", + "ts3.1", + "ts3.2", + "ts3.3", + "ts3.4", + "ts3.5", + "ts3.6", + "ts3.7", + "ts3.8", + "ts3.9", + "latest" + ]; + + /** List of NPM tags that should be changed to point to the latest version. */ + export function tagsToUpdate(v: TypeScriptVersion): readonly string[] { + const idx = supportedTags.indexOf(`ts${v}`); + assert(idx !== -1); + return supportedTags.slice(idx); + } + + export function previous(v: TypeScriptVersion): TypeScriptVersion | undefined { + const index = supported.indexOf(v); + assert(index !== -1); + return index === 0 ? undefined : supported[index - 1]; + } + + export function isRedirectable(v: TypeScriptVersion): boolean { + return all.indexOf(v) >= all.indexOf("3.1"); + } +} diff --git a/packages/typescript-versions/tsconfig.json b/packages/typescript-versions/tsconfig.json new file mode 100644 index 0000000000..5285d28af2 --- /dev/null +++ b/packages/typescript-versions/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "dist" + }, + "include": ["src"] +} diff --git a/packages/utils/package.json b/packages/utils/package.json index 2c4257b55d..f74da5aee7 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -19,6 +19,7 @@ "url": "https://github.com/DefinitelyTyped/tools/issues" }, "dependencies": { + "@definitelytyped/typescript-versions": "0.0.23-next.0", "@types/node": "^12.12.29", "charm": "^1.0.2", "fs-extra": "^8.1.0", diff --git a/packages/utils/src/typescript-installer.ts b/packages/utils/src/typescript-installer.ts index 84180be2b4..5a1e16ca1f 100644 --- a/packages/utils/src/typescript-installer.ts +++ b/packages/utils/src/typescript-installer.ts @@ -3,135 +3,11 @@ import { exec } from "child_process"; import * as fs from "fs-extra"; import * as os from "os"; import * as path from "path"; - -/* - - # How to add new version of Typescript # - - For the RC: - - 1. Add a new version to the end of `supportedTags`. - 2. Update failing tests. - 3. Publish and update dependents. - - For the release: - - 1. Add new versions to the end of `TypeScriptVersion` and `supported`. - 2. Update failing tests. - 3. Publish and update dependents. - - # How to deprecate versions on Definitely Typed # - - 1. Move versions from `TypeScriptVersion` to `UnsupportedTypeScriptVersion`. - 2. Move versions from `supported` to `unsupported`. - 3. Remove entry from `supportedTags`. - 4. Update failing tests. - 5. Publish and update dependents. - -*/ - -const installsDir = path.join(os.homedir(), ".dts", "typescript-installs"); - -/** Parseable but unsupported TypeScript versions. */ -export type UnsupportedTypeScriptVersion = "2.0" | "2.1" | "2.2" | "2.3" | "2.4" | "2.5" | "2.6" | "2.7"; -/** - * Parseable and supported TypeScript versions. - * Only add to this list if we will support this version on DefinitelyTyped. - */ -export type TypeScriptVersion = - | "2.8" - | "2.9" - | "3.0" - | "3.1" - | "3.2" - | "3.3" - | "3.4" - | "3.5" - | "3.6" - | "3.7" - | "3.8" - | "3.9"; - -export type AllTypeScriptVersion = UnsupportedTypeScriptVersion | TypeScriptVersion; +import { TypeScriptVersion } from "@definitelytyped/typescript-versions"; export type TsVersion = TypeScriptVersion | "next" | "local"; -export namespace TypeScriptVersion { - export const supported: readonly TypeScriptVersion[] = [ - "2.8", - "2.9", - "3.0", - "3.1", - "3.2", - "3.3", - "3.4", - "3.5", - "3.6", - "3.7", - "3.8", - "3.9" - ]; - export const unsupported: readonly UnsupportedTypeScriptVersion[] = [ - "2.0", - "2.1", - "2.2", - "2.3", - "2.4", - "2.5", - "2.6", - "2.7" - ]; - export const all: readonly AllTypeScriptVersion[] = [...unsupported, ...supported]; - export const lowest = supported[0]; - /** Latest version that may be specified in a `// TypeScript Version:` header. */ - export const latest = supported[supported.length - 1]; - - /** @deprecated */ - export function isPrerelease(_version: TypeScriptVersion): boolean { - return false; - } - - export function isSupported(v: AllTypeScriptVersion): v is TypeScriptVersion { - return supported.indexOf(v as TypeScriptVersion) > -1; - } - - export function range(min: TypeScriptVersion): readonly TypeScriptVersion[] { - return supported.filter(v => v >= min); - } - - const supportedTags: readonly string[] = [ - "ts2.8", - "ts2.9", - "ts3.0", - "ts3.1", - "ts3.2", - "ts3.3", - "ts3.4", - "ts3.5", - "ts3.6", - "ts3.7", - "ts3.8", - "ts3.9", - "latest" - ]; - - /** List of NPM tags that should be changed to point to the latest version. */ - export function tagsToUpdate(v: TypeScriptVersion): readonly string[] { - const idx = supportedTags.indexOf(`ts${v}`); - assert(idx !== -1); - return supportedTags.slice(idx); - } - - export function previous(v: TypeScriptVersion): TypeScriptVersion | undefined { - const index = supported.indexOf(v); - assert(index !== -1); - return index === 0 ? undefined : supported[index - 1]; - } - - export function isRedirectable(v: TypeScriptVersion): boolean { - return all.indexOf(v) >= all.indexOf("3.1"); - } -} +const installsDir = path.join(os.homedir(), ".dts", "typescript-installs"); export async function installAllTypeScriptVersions() { for (const v of TypeScriptVersion.supported) { diff --git a/packages/utils/tsconfig.json b/packages/utils/tsconfig.json index 5285d28af2..fe02a862fd 100644 --- a/packages/utils/tsconfig.json +++ b/packages/utils/tsconfig.json @@ -4,5 +4,8 @@ "rootDir": "src", "outDir": "dist" }, - "include": ["src"] + "include": ["src"], + "references": [ + { "path": "../typescript-versions" } + ] } diff --git a/tsconfig.all.json b/tsconfig.all.json index 46893de0aa..c56181b9f6 100644 --- a/tsconfig.all.json +++ b/tsconfig.all.json @@ -6,6 +6,7 @@ { "path": "packages/header-parser" }, { "path": "packages/perf" }, { "path": "packages/publisher" }, + { "path": "packages/typescript-versions" }, { "path": "packages/utils" } ] } \ No newline at end of file