From 37c33f43696526db33470825c3614c783db1bebb Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Tue, 28 Aug 2018 17:24:02 -0700 Subject: [PATCH] Use semver ranges --- Gulpfile.js | 65 +++++++++---- package.json | 1 + scripts/build/cancellation.js | 71 -------------- scripts/build/countdown.js | 62 ------------- scripts/build/exec.js | 14 ++- scripts/build/project.js | 92 +++++++++++-------- scripts/build/tests.js | 3 +- src/compiler/moduleNameResolver.ts | 26 ++---- .../reference/typesVersions.ambientModules.js | 2 +- .../typesVersions.ambientModules.trace.json | 6 +- .../reference/typesVersions.multiFile.js | 2 +- .../typesVersions.multiFile.trace.json | 4 +- .../typesVersionsDeclarationEmit.ambient.js | 2 +- ...VersionsDeclarationEmit.ambient.trace.json | 6 +- .../typesVersionsDeclarationEmit.multiFile.js | 2 +- ...rsionsDeclarationEmit.multiFile.trace.json | 4 +- ...it.multiFileBackReferenceToSelf.errors.txt | 2 +- ...rationEmit.multiFileBackReferenceToSelf.js | 2 +- ...it.multiFileBackReferenceToSelf.trace.json | 6 +- ...onEmit.multiFileBackReferenceToUnmapped.js | 2 +- ...ultiFileBackReferenceToUnmapped.trace.json | 4 +- .../typesVersionsDeclarationEmit.ambient.ts | 2 +- .../typesVersionsDeclarationEmit.multiFile.ts | 2 +- ...rationEmit.multiFileBackReferenceToSelf.ts | 2 +- ...onEmit.multiFileBackReferenceToUnmapped.ts | 2 +- .../typesVersions.ambientModules.ts | 2 +- .../typesVersions.multiFile.ts | 2 +- 27 files changed, 146 insertions(+), 244 deletions(-) delete mode 100644 scripts/build/cancellation.js delete mode 100644 scripts/build/countdown.js diff --git a/Gulpfile.js b/Gulpfile.js index b2fb584d4a2..6dc78d1e5ee 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -24,10 +24,9 @@ const baselineAccept = require("./scripts/build/baselineAccept"); const cmdLineOptions = require("./scripts/build/options"); const exec = require("./scripts/build/exec"); const browserify = require("./scripts/build/browserify"); -const debounce = require("./scripts/build/debounce"); const prepend = require("./scripts/build/prepend"); const { removeSourceMaps } = require("./scripts/build/sourcemaps"); -const { CancelSource, CancelError } = require("./scripts/build/cancellation"); +const { CancellationTokenSource, CancelError, delay, Semaphore } = require("prex"); const { libraryTargets, generateLibs } = require("./scripts/build/lib"); const { runConsoleTests, cleanTestDirs, writeTestConfigFile, refBaseline, localBaseline, refRwcBaseline, localRwcBaseline } = require("./scripts/build/tests"); @@ -556,35 +555,61 @@ gulp.task( "Watches for changes to the build inputs for built/local/run.js, then executes runtests-parallel.", ["build-rules", "watch-runner", "watch-services", "watch-lssl"], () => { - /** @type {CancelSource | undefined} */ - let runTestsSource; + const runTestsSemaphore = new Semaphore(1); + const fn = async () => { + try { + // Ensure only one instance of the test runner is running at any given time. + if (runTestsSemaphore.count > 0) { + await runTestsSemaphore.wait(); + try { + // Wait for any concurrent recompilations to complete... + try { + await delay(100); + while (project.hasRemainingWork()) { + await project.waitForWorkToComplete(); + await delay(500); + } + } + catch (e) { + if (e instanceof CancelError) return; + throw e; + } - const fn = debounce(() => { - runTests().catch(error => { - if (error instanceof CancelError) { + // cancel any pending or active test run if a new recompilation is triggered + const runTestsSource = new CancellationTokenSource(); + project.waitForWorkToStart().then(() => { + runTestsSource.cancel(); + }); + + if (cmdLineOptions.tests || cmdLineOptions.failed) { + await runConsoleTests(runJs, "mocha-fivemat-progress-reporter", /*runInParallel*/ false, /*watchMode*/ true, runTestsSource.token); + } + else { + await runConsoleTests(runJs, "min", /*runInParallel*/ true, /*watchMode*/ true, runTestsSource.token); + } + } + finally { + runTestsSemaphore.release(); + } + } + } + catch (e) { + if (e instanceof CancelError) { log.warn("Operation was canceled"); } else { - log.error(error); + log.error(e); } - }); - }, /*timeout*/ 100, { max: 500 }); + } + }; - gulp.watch(watchPatterns, () => project.wait(runTestsSource && runTestsSource.token).then(fn)); + gulp.watch(watchPatterns, (e) => fn()); // NOTE: gulp.watch is far too slow when watching tests/cases/**/* as it first enumerates *every* file const testFilePattern = /(\.ts|[\\/]tsconfig\.json)$/; fs.watch("tests/cases", { recursive: true }, (_, file) => { - if (testFilePattern.test(file)) project.wait(runTestsSource && runTestsSource.token).then(fn); + if (testFilePattern.test(file)) fn(); }); - - function runTests() { - if (runTestsSource) runTestsSource.cancel(); - runTestsSource = new CancelSource(); - return cmdLineOptions.tests || cmdLineOptions.failed - ? runConsoleTests(runJs, "mocha-fivemat-progress-reporter", /*runInParallel*/ false, /*watchMode*/ true, runTestsSource.token) - : runConsoleTests(runJs, "min", /*runInParallel*/ true, /*watchMode*/ true, runTestsSource.token); - } }); gulp.task("clean-built", /*help*/ false, [`clean:${diagnosticInformationMapTs}`], () => del(["built"])); diff --git a/package.json b/package.json index 510d3aab53b..55acc40268d 100644 --- a/package.json +++ b/package.json @@ -81,6 +81,7 @@ "mocha": "latest", "mocha-fivemat-progress-reporter": "latest", "plugin-error": "latest", + "prex": "^0.4.3", "q": "latest", "remove-internal": "^2.9.2", "run-sequence": "latest", diff --git a/scripts/build/cancellation.js b/scripts/build/cancellation.js deleted file mode 100644 index 793aaf19d86..00000000000 --- a/scripts/build/cancellation.js +++ /dev/null @@ -1,71 +0,0 @@ -// @ts-check -const symSource = Symbol("CancelToken.source"); -const symToken = Symbol("CancelSource.token"); -const symCancellationRequested = Symbol("CancelSource.cancellationRequested"); -const symCancellationCallbacks = Symbol("CancelSource.cancellationCallbacks"); - -class CancelSource { - constructor() { - this[symCancellationRequested] = false; - this[symCancellationCallbacks] = []; - } - - /** @type {CancelToken} */ - get token() { - return this[symToken] || (this[symToken] = new CancelToken(this)); - } - - cancel() { - if (!this[symCancellationRequested]) { - this[symCancellationRequested] = true; - for (const callback of this[symCancellationCallbacks]) { - callback(); - } - } - } -} -exports.CancelSource = CancelSource; - -class CancelToken { - /** - * @param {CancelSource} source - */ - constructor(source) { - if (source[symToken]) return source[symToken]; - this[symSource] = source; - } - - /** @type {boolean} */ - get cancellationRequested() { - return this[symSource][symCancellationRequested]; - } - - /** - * @param {() => void} callback - */ - subscribe(callback) { - const source = this[symSource]; - if (source[symCancellationRequested]) { - callback(); - return; - } - - source[symCancellationCallbacks].push(callback); - - return { - unsubscribe() { - const index = source[symCancellationCallbacks].indexOf(callback); - if (index !== -1) source[symCancellationCallbacks].splice(index, 1); - } - }; - } -} -exports.CancelToken = CancelToken; - -class CancelError extends Error { - constructor(message = "Operation was canceled") { - super(message); - this.name = "CancelError"; - } -} -exports.CancelError = CancelError; \ No newline at end of file diff --git a/scripts/build/countdown.js b/scripts/build/countdown.js deleted file mode 100644 index dda05352d28..00000000000 --- a/scripts/build/countdown.js +++ /dev/null @@ -1,62 +0,0 @@ -// @ts-check -const { CancelToken } = require("./cancellation"); - -class Countdown { - constructor(initialCount = 0) { - if (initialCount < 0) throw new Error(); - this._remainingCount = initialCount; - this._promise = undefined; - this._resolve = undefined; - } - - get remainingCount() { - return this._remainingCount; - } - - add(count = 1) { - if (count < 1 || !isFinite(count) || Math.trunc(count) !== count) throw new Error(); - if (this._remainingCount === 0) { - this._promise = undefined; - this._resolve = undefined; - } - - this._remainingCount += count; - } - - signal(count = 1) { - if (count < 1 || !isFinite(count) || Math.trunc(count) !== count) throw new Error(); - if (this._remainingCount - count < 0) throw new Error(); - this._remainingCount -= count; - if (this._remainingCount == 0) { - if (this._resolve) { - this._resolve(); - } - return true; - } - return false; - } - - /** @param {CancelToken} [token] */ - wait(token) { - if (!this._promise) { - this._promise = new Promise(resolve => { this._resolve = resolve; }); - } - if (this._remainingCount === 0) { - this._resolve(); - } - if (!token) return this._promise; - return new Promise((resolve, reject) => { - const subscription = token.subscribe(reject); - this._promise.then( - value => { - subscription.unsubscribe(); - resolve(value); - }, - error => { - subscription.unsubscribe(); - reject(error); - }); - }); - } -} -exports.Countdown = Countdown; \ No newline at end of file diff --git a/scripts/build/exec.js b/scripts/build/exec.js index 068bf33b9e9..024cb6d3b5b 100644 --- a/scripts/build/exec.js +++ b/scripts/build/exec.js @@ -3,7 +3,7 @@ const cp = require("child_process"); const log = require("fancy-log"); // was `require("gulp-util").log (see https://github.com/gulpjs/gulp-util) const isWin = /^win/.test(process.platform); const chalk = require("./chalk"); -const { CancelToken, CancelError } = require("./cancellation"); +const { CancelError } = require("prex"); module.exports = exec; @@ -15,16 +15,20 @@ module.exports = exec; * * @typedef ExecOptions * @property {boolean} [ignoreExitCode] - * @property {CancelToken} [cancelToken] + * @property {import("prex").CancellationToken} [cancelToken] */ function exec(cmd, args, options = {}) { return /**@type {Promise<{exitCode: number}>}*/(new Promise((resolve, reject) => { + if (options.cancelToken) { + options.cancelToken.throwIfCancellationRequested(); + } + log(`> ${chalk.green(cmd)} ${args.join(" ")}`); // TODO (weswig): Update child_process types to add windowsVerbatimArguments to the type definition const subshellFlag = isWin ? "/c" : "-c"; const command = isWin ? [possiblyQuote(cmd), ...args] : [`${cmd} ${args.join(" ")}`]; const ex = cp.spawn(isWin ? "cmd" : "/bin/sh", [subshellFlag, ...command], { stdio: "inherit", windowsVerbatimArguments: true }); - const subscription = options.cancelToken && options.cancelToken.subscribe(() => { + const subscription = options.cancelToken && options.cancelToken.register(() => { log(`${chalk.red("killing")} '${chalk.green(cmd)} ${args.join(" ")}'...`); ex.kill("SIGINT"); ex.kill("SIGTERM"); @@ -32,7 +36,7 @@ function exec(cmd, args, options = {}) { reject(new CancelError()); }); ex.on("exit", exitCode => { - subscription && subscription.unsubscribe(); + if (subscription) subscription.unregister(); if (exitCode === 0 || options.ignoreExitCode) { resolve({ exitCode }); } @@ -41,7 +45,7 @@ function exec(cmd, args, options = {}) { } }); ex.on("error", error => { - subscription && subscription.unsubscribe(); + if (subscription) subscription.unregister(); reject(error); }); })); diff --git a/scripts/build/project.js b/scripts/build/project.js index 8519e4c71ec..bd41926a204 100644 --- a/scripts/build/project.js +++ b/scripts/build/project.js @@ -3,6 +3,8 @@ const path = require("path"); const fs = require("fs"); const gulp = require("./gulp"); const gulpif = require("gulp-if"); +const log = require("fancy-log"); // was `require("gulp-util").log (see https://github.com/gulpjs/gulp-util) +const chalk = require("./chalk"); const sourcemaps = require("gulp-sourcemaps"); const merge2 = require("merge2"); const tsc = require("gulp-typescript"); @@ -12,42 +14,51 @@ const ts = require("../../lib/typescript"); const del = require("del"); const needsUpdate = require("./needsUpdate"); const mkdirp = require("./mkdirp"); +const prettyTime = require("pretty-hrtime"); const { reportDiagnostics } = require("./diagnostics"); -const { Countdown } = require("./countdown"); -const { CancelToken } = require("./cancellation"); +const { CountdownEvent, Pulsar } = require("prex"); -const countdown = new Countdown(); +const workStartedEvent = new Pulsar(); +const countdown = new CountdownEvent(0); class CompilationGulp extends gulp.Gulp { - constructor() { - super(); - this.on("start", () => { - const onDone = () => { - this.removeListener("stop", onDone); - this.removeListener("err", onDone); - countdown.signal(); - }; - - this.on("stop", onDone); - this.on("err", onDone); - countdown.add(); - }); - } - /** * @param {boolean} [verbose] */ fork(verbose) { const child = new ForkedGulp(this.tasks); - if (verbose) { - child.on("task_start", e => gulp.emit("task_start", e)); - child.on("task_stop", e => gulp.emit("task_stop", e)); - child.on("task_err", e => gulp.emit("task_err", e)); - child.on("task_not_found", e => gulp.emit("task_not_found", e)); - child.on("task_recursion", e => gulp.emit("task_recursion", e)); - } + child.on("task_start", e => { + if (countdown.remainingCount === 0) { + countdown.reset(1); + workStartedEvent.pulseAll(); + } + else { + countdown.add(); + } + if (verbose) { + log('Starting', `'${chalk.cyan(e.task)}' ${chalk.gray(`(${countdown.remainingCount} remaining)`)}...`); + } + }); + child.on("task_stop", e => { + countdown.signal(); + if (verbose) { + log('Finished', `'${chalk.cyan(e.task)}' after ${chalk.magenta(prettyTime(/** @type {*}*/(e).hrDuration))} ${chalk.gray(`(${countdown.remainingCount} remaining)`)}`); + } + }); + child.on("task_err", e => { + countdown.signal(); + if (verbose) { + log(`'${chalk.cyan(e.task)}' ${chalk.red("errored after")} ${chalk.magenta(prettyTime(/** @type {*}*/(e).hrDuration))} ${chalk.gray(`(${countdown.remainingCount} remaining)`)}`); + log(e.err ? e.err.stack : e.message); + } + }); return child; } + + // @ts-ignore + start() { + throw new Error("Not supported, use fork."); + } } class ForkedGulp extends gulp.Gulp { @@ -57,17 +68,6 @@ class ForkedGulp extends gulp.Gulp { constructor(tasks) { super(); this.tasks = tasks; - this.on("start", () => { - const onDone = () => { - this.removeListener("stop", onDone); - this.removeListener("err", onDone); - countdown.signal(); - }; - - this.on("stop", onDone); - this.on("err", onDone); - countdown.add(); - }); } // Do not reset tasks @@ -241,12 +241,26 @@ exports.flatten = flatten; /** * Returns a Promise that resolves when all pending build tasks have completed - * @param {CancelToken} [token] + * @param {import("prex").CancellationToken} [token] */ -function wait(token) { +function waitForWorkToComplete(token) { return countdown.wait(token); } -exports.wait = wait; +exports.waitForWorkToComplete = waitForWorkToComplete; + +/** + * Returns a Promise that resolves when all pending build tasks have completed + * @param {import("prex").CancellationToken} [token] + */ +function waitForWorkToStart(token) { + return workStartedEvent.wait(token); +} +exports.waitForWorkToStart = waitForWorkToStart; + +function getRemainingWork() { + return countdown.remainingCount > 0; +} +exports.hasRemainingWork = getRemainingWork; /** * Resolve a TypeScript specifier into a fully-qualified module specifier and any requisite dependencies. diff --git a/scripts/build/tests.js b/scripts/build/tests.js index d631f1e35ac..3fd65b2c859 100644 --- a/scripts/build/tests.js +++ b/scripts/build/tests.js @@ -21,7 +21,7 @@ exports.localTest262Baseline = "internal/baselines/test262/local"; * @param {string} defaultReporter * @param {boolean} runInParallel * @param {boolean} watchMode - * @param {InstanceType} [cancelToken] + * @param {import("prex").CancellationToken} [cancelToken] */ async function runConsoleTests(runJs, defaultReporter, runInParallel, watchMode, cancelToken) { let testTimeout = cmdLineOptions.timeout; @@ -37,6 +37,7 @@ async function runConsoleTests(runJs, defaultReporter, runInParallel, watchMode, const keepFailed = cmdLineOptions.keepFailed; if (!cmdLineOptions.dirty) { await cleanTestDirs(); + if (cancelToken) cancelToken.throwIfCancellationRequested(); } if (fs.existsSync(testConfigFile)) { diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 6545ce353e6..0c2d35f19a8 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -188,31 +188,21 @@ namespace ts { /* @internal */ export function getPackageJsonTypesVersionsPaths(typesVersions: MapLike>) { - if (!typeScriptVersion) typeScriptVersion = new Version(versionMajorMinor); + if (!typeScriptVersion) typeScriptVersion = new Version(version); - let bestVersion: Version | undefined; - let bestVersionKey: string | undefined; for (const key in typesVersions) { if (!hasProperty(typesVersions, key)) continue; - const keyVersion = Version.tryParse(key); - if (keyVersion === undefined) { + const keyRange = VersionRange.tryParse(key); + if (keyRange === undefined) { continue; } - // match the greatest version less than the current TypeScript version - if (keyVersion.compareTo(bestVersion) > 0 && - keyVersion.compareTo(typeScriptVersion) <= 0) { - bestVersion = keyVersion; - bestVersionKey = key; + // return the first entry whose range matches the current compiler version. + if (keyRange.test(typeScriptVersion)) { + return { version: key, paths: typesVersions[key] }; } } - - if (!bestVersionKey) { - return; - } - - return { version: bestVersionKey, paths: typesVersions[bestVersionKey] }; } export function getEffectiveTypeRoots(options: CompilerOptions, host: GetEffectiveTypeRootsHost): string[] | undefined { @@ -1132,7 +1122,7 @@ namespace ts { if (versionPaths && containsPath(candidate, file)) { const moduleName = getRelativePathFromDirectory(candidate, file, /*ignoreCase*/ false); if (state.traceEnabled) { - trace(state.host, Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, versionPaths.version, versionMajorMinor, moduleName); + trace(state.host, Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, versionPaths.version, version, moduleName); } const result = tryLoadModuleUsingPaths(extensions, moduleName, candidate, versionPaths.paths, loader, onlyRecordFailures, state); if (result) { @@ -1255,7 +1245,7 @@ namespace ts { if (packageInfo) ({ packageId, versionPaths } = packageInfo); if (versionPaths) { if (state.traceEnabled) { - trace(state.host, Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, versionPaths.version, versionMajorMinor, rest); + trace(state.host, Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, versionPaths.version, version, rest); } const packageDirectoryExists = nodeModulesDirectoryExists && directoryProbablyExists(packageDirectory, state.host); const fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, versionPaths.paths, loader, !packageDirectoryExists, state); diff --git a/tests/baselines/reference/typesVersions.ambientModules.js b/tests/baselines/reference/typesVersions.ambientModules.js index 1d7e3f04ec3..7dee6e9e3fd 100644 --- a/tests/baselines/reference/typesVersions.ambientModules.js +++ b/tests/baselines/reference/typesVersions.ambientModules.js @@ -6,7 +6,7 @@ "version": "1.0.0", "types": "index", "typesVersions": { - "3.1": { "*" : ["ts3.1/*"] } + ">=3.1.0-0": { "*" : ["ts3.1/*"] } } } diff --git a/tests/baselines/reference/typesVersions.ambientModules.trace.json b/tests/baselines/reference/typesVersions.ambientModules.trace.json index 7a442ce5048..8e4d2ecba2d 100644 --- a/tests/baselines/reference/typesVersions.ambientModules.trace.json +++ b/tests/baselines/reference/typesVersions.ambientModules.trace.json @@ -11,7 +11,7 @@ "File 'tests/cases/conformance/moduleResolution/node_modules/ext.d.ts' does not exist.", "'package.json' does not have a 'typings' field.", "'package.json' has 'types' field 'index' that references 'tests/cases/conformance/moduleResolution/node_modules/ext/index'.", - "'package.json' has a 'typesVersions' entry '3.1' that matches compiler version '3.1', looking for a pattern to match module name 'index'.", + "'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'index'.", "Module name 'index', matched pattern '*'.", "Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/index'.", "File 'tests/cases/conformance/moduleResolution/node_modules/ext/ts3.1/index' does not exist.", @@ -26,7 +26,7 @@ "Loading module 'ext/other' from 'node_modules' folder, target file type 'TypeScript'.", "'package.json' has a 'typesVersions' field with version-specific path mappings.", "Found 'package.json' at 'tests/cases/conformance/moduleResolution/node_modules/ext/package.json'. Package ID is 'ext/other/index.d.ts@1.0.0'.", - "'package.json' has a 'typesVersions' entry '3.1' that matches compiler version '3.1', looking for a pattern to match module name 'other'.", + "'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'other'.", "Module name 'other', matched pattern '*'.", "Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/other'.", "File 'tests/cases/conformance/moduleResolution/node_modules/ext/ts3.1/other.ts' does not exist.", @@ -41,7 +41,7 @@ "Loading module 'ext/other' from 'node_modules' folder, target file type 'JavaScript'.", "'package.json' has a 'typesVersions' field with version-specific path mappings.", "Found 'package.json' at 'tests/cases/conformance/moduleResolution/node_modules/ext/package.json'. Package ID is 'ext/other/index.d.ts@1.0.0'.", - "'package.json' has a 'typesVersions' entry '3.1' that matches compiler version '3.1', looking for a pattern to match module name 'other'.", + "'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'other'.", "Module name 'other', matched pattern '*'.", "Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/other'.", "File 'tests/cases/conformance/moduleResolution/node_modules/ext/ts3.1/other.js' does not exist.", diff --git a/tests/baselines/reference/typesVersions.multiFile.js b/tests/baselines/reference/typesVersions.multiFile.js index 14f7fd8aaf4..cca708988c6 100644 --- a/tests/baselines/reference/typesVersions.multiFile.js +++ b/tests/baselines/reference/typesVersions.multiFile.js @@ -6,7 +6,7 @@ "version": "1.0.0", "types": "index", "typesVersions": { - "3.1": { "*" : ["ts3.1/*"] } + ">=3.1.0-0": { "*" : ["ts3.1/*"] } } } diff --git a/tests/baselines/reference/typesVersions.multiFile.trace.json b/tests/baselines/reference/typesVersions.multiFile.trace.json index e7245fa5765..d52db48acfe 100644 --- a/tests/baselines/reference/typesVersions.multiFile.trace.json +++ b/tests/baselines/reference/typesVersions.multiFile.trace.json @@ -11,7 +11,7 @@ "File 'tests/cases/conformance/moduleResolution/node_modules/ext.d.ts' does not exist.", "'package.json' does not have a 'typings' field.", "'package.json' has 'types' field 'index' that references 'tests/cases/conformance/moduleResolution/node_modules/ext/index'.", - "'package.json' has a 'typesVersions' entry '3.1' that matches compiler version '3.1', looking for a pattern to match module name 'index'.", + "'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'index'.", "Module name 'index', matched pattern '*'.", "Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/index'.", "File 'tests/cases/conformance/moduleResolution/node_modules/ext/ts3.1/index' does not exist.", @@ -26,7 +26,7 @@ "Loading module 'ext/other' from 'node_modules' folder, target file type 'TypeScript'.", "'package.json' has a 'typesVersions' field with version-specific path mappings.", "Found 'package.json' at 'tests/cases/conformance/moduleResolution/node_modules/ext/package.json'. Package ID is 'ext/other/index.d.ts@1.0.0'.", - "'package.json' has a 'typesVersions' entry '3.1' that matches compiler version '3.1', looking for a pattern to match module name 'other'.", + "'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'other'.", "Module name 'other', matched pattern '*'.", "Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/other'.", "File 'tests/cases/conformance/moduleResolution/node_modules/ext/ts3.1/other.ts' does not exist.", diff --git a/tests/baselines/reference/typesVersionsDeclarationEmit.ambient.js b/tests/baselines/reference/typesVersionsDeclarationEmit.ambient.js index b1af852940b..ddd2f8b0ef5 100644 --- a/tests/baselines/reference/typesVersionsDeclarationEmit.ambient.js +++ b/tests/baselines/reference/typesVersionsDeclarationEmit.ambient.js @@ -6,7 +6,7 @@ "version": "1.0.0", "types": "index", "typesVersions": { - "3.1": { "*" : ["ts3.1/*"] } + ">=3.1.0-0": { "*" : ["ts3.1/*"] } } } diff --git a/tests/baselines/reference/typesVersionsDeclarationEmit.ambient.trace.json b/tests/baselines/reference/typesVersionsDeclarationEmit.ambient.trace.json index c3b0e232748..f1db86cc283 100644 --- a/tests/baselines/reference/typesVersionsDeclarationEmit.ambient.trace.json +++ b/tests/baselines/reference/typesVersionsDeclarationEmit.ambient.trace.json @@ -11,7 +11,7 @@ "File 'tests/cases/conformance/declarationEmit/node_modules/ext.d.ts' does not exist.", "'package.json' does not have a 'typings' field.", "'package.json' has 'types' field 'index' that references 'tests/cases/conformance/declarationEmit/node_modules/ext/index'.", - "'package.json' has a 'typesVersions' entry '3.1' that matches compiler version '3.1', looking for a pattern to match module name 'index'.", + "'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'index'.", "Module name 'index', matched pattern '*'.", "Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/index'.", "File 'tests/cases/conformance/declarationEmit/node_modules/ext/ts3.1/index' does not exist.", @@ -26,7 +26,7 @@ "Loading module 'ext/other' from 'node_modules' folder, target file type 'TypeScript'.", "'package.json' has a 'typesVersions' field with version-specific path mappings.", "Found 'package.json' at 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json'. Package ID is 'ext/other/index.d.ts@1.0.0'.", - "'package.json' has a 'typesVersions' entry '3.1' that matches compiler version '3.1', looking for a pattern to match module name 'other'.", + "'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'other'.", "Module name 'other', matched pattern '*'.", "Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/other'.", "File 'tests/cases/conformance/declarationEmit/node_modules/ext/ts3.1/other.ts' does not exist.", @@ -41,7 +41,7 @@ "Loading module 'ext/other' from 'node_modules' folder, target file type 'JavaScript'.", "'package.json' has a 'typesVersions' field with version-specific path mappings.", "Found 'package.json' at 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json'. Package ID is 'ext/other/index.d.ts@1.0.0'.", - "'package.json' has a 'typesVersions' entry '3.1' that matches compiler version '3.1', looking for a pattern to match module name 'other'.", + "'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'other'.", "Module name 'other', matched pattern '*'.", "Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/other'.", "File 'tests/cases/conformance/declarationEmit/node_modules/ext/ts3.1/other.js' does not exist.", diff --git a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFile.js b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFile.js index 22cdb0087ef..5fd7da959ea 100644 --- a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFile.js +++ b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFile.js @@ -6,7 +6,7 @@ "version": "1.0.0", "types": "index", "typesVersions": { - "3.1": { "*" : ["ts3.1/*"] } + ">=3.1.0-0": { "*" : ["ts3.1/*"] } } } diff --git a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFile.trace.json b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFile.trace.json index 532e80feac7..eee9622037b 100644 --- a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFile.trace.json +++ b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFile.trace.json @@ -11,7 +11,7 @@ "File 'tests/cases/conformance/declarationEmit/node_modules/ext.d.ts' does not exist.", "'package.json' does not have a 'typings' field.", "'package.json' has 'types' field 'index' that references 'tests/cases/conformance/declarationEmit/node_modules/ext/index'.", - "'package.json' has a 'typesVersions' entry '3.1' that matches compiler version '3.1', looking for a pattern to match module name 'index'.", + "'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'index'.", "Module name 'index', matched pattern '*'.", "Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/index'.", "File 'tests/cases/conformance/declarationEmit/node_modules/ext/ts3.1/index' does not exist.", @@ -26,7 +26,7 @@ "Loading module 'ext/other' from 'node_modules' folder, target file type 'TypeScript'.", "'package.json' has a 'typesVersions' field with version-specific path mappings.", "Found 'package.json' at 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json'. Package ID is 'ext/other/index.d.ts@1.0.0'.", - "'package.json' has a 'typesVersions' entry '3.1' that matches compiler version '3.1', looking for a pattern to match module name 'other'.", + "'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'other'.", "Module name 'other', matched pattern '*'.", "Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/other'.", "File 'tests/cases/conformance/declarationEmit/node_modules/ext/ts3.1/other.ts' does not exist.", diff --git a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.errors.txt b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.errors.txt index 66624634d9f..540dd917fa0 100644 --- a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.errors.txt +++ b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.errors.txt @@ -9,7 +9,7 @@ tests/cases/conformance/declarationEmit/main.ts(1,10): error TS2305: Module '"te "version": "1.0.0", "types": "index", "typesVersions": { - "3.1": { "*" : ["ts3.1/*"] } + ">=3.1.0-0": { "*" : ["ts3.1/*"] } } } diff --git a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.js b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.js index c7b885d5e9e..ab415ca2b61 100644 --- a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.js +++ b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.js @@ -6,7 +6,7 @@ "version": "1.0.0", "types": "index", "typesVersions": { - "3.1": { "*" : ["ts3.1/*"] } + ">=3.1.0-0": { "*" : ["ts3.1/*"] } } } diff --git a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.trace.json b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.trace.json index 33d5a0e3177..cf08a29478f 100644 --- a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.trace.json +++ b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.trace.json @@ -9,7 +9,7 @@ "'package.json' has a 'typesVersions' field with version-specific path mappings.", "'package.json' does not have a 'typings' field.", "'package.json' has 'types' field 'index' that references 'tests/cases/conformance/declarationEmit/node_modules/ext/index'.", - "'package.json' has a 'typesVersions' entry '3.1' that matches compiler version '3.1', looking for a pattern to match module name 'index'.", + "'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'index'.", "Module name 'index', matched pattern '*'.", "Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/index'.", "File 'tests/cases/conformance/declarationEmit/node_modules/ext/ts3.1/index' does not exist.", @@ -39,7 +39,7 @@ "File 'tests/cases/conformance/declarationEmit/node_modules/ext.d.ts' does not exist.", "'package.json' does not have a 'typings' field.", "'package.json' has 'types' field 'index' that references 'tests/cases/conformance/declarationEmit/node_modules/ext/index'.", - "'package.json' has a 'typesVersions' entry '3.1' that matches compiler version '3.1', looking for a pattern to match module name 'index'.", + "'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'index'.", "Module name 'index', matched pattern '*'.", "Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/index'.", "File 'tests/cases/conformance/declarationEmit/node_modules/ext/ts3.1/index' does not exist.", @@ -54,7 +54,7 @@ "Loading module 'ext/other' from 'node_modules' folder, target file type 'TypeScript'.", "'package.json' has a 'typesVersions' field with version-specific path mappings.", "Found 'package.json' at 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json'. Package ID is 'ext/other/index.d.ts@1.0.0'.", - "'package.json' has a 'typesVersions' entry '3.1' that matches compiler version '3.1', looking for a pattern to match module name 'other'.", + "'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'other'.", "Module name 'other', matched pattern '*'.", "Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/other'.", "File 'tests/cases/conformance/declarationEmit/node_modules/ext/ts3.1/other.ts' does not exist.", diff --git a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.js b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.js index 86a621161f6..fb7dfd74b2d 100644 --- a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.js +++ b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.js @@ -6,7 +6,7 @@ "version": "1.0.0", "types": "index", "typesVersions": { - "3.1": { + ">=3.1.0-0": { "index" : ["ts3.1/index"] } } diff --git a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.trace.json b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.trace.json index d31c0730fd9..fe65b605283 100644 --- a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.trace.json +++ b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.trace.json @@ -20,7 +20,7 @@ "File 'tests/cases/conformance/declarationEmit/node_modules/ext.d.ts' does not exist.", "'package.json' does not have a 'typings' field.", "'package.json' has 'types' field 'index' that references 'tests/cases/conformance/declarationEmit/node_modules/ext/index'.", - "'package.json' has a 'typesVersions' entry '3.1' that matches compiler version '3.1', looking for a pattern to match module name 'index'.", + "'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'index'.", "Module name 'index', matched pattern 'index'.", "Trying substitution 'ts3.1/index', candidate module location: 'ts3.1/index'.", "File 'tests/cases/conformance/declarationEmit/node_modules/ext/ts3.1/index' does not exist.", @@ -35,7 +35,7 @@ "Loading module 'ext/other' from 'node_modules' folder, target file type 'TypeScript'.", "'package.json' has a 'typesVersions' field with version-specific path mappings.", "Found 'package.json' at 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json'. Package ID is 'ext/other/index.d.ts@1.0.0'.", - "'package.json' has a 'typesVersions' entry '3.1' that matches compiler version '3.1', looking for a pattern to match module name 'other'.", + "'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'other'.", "File 'tests/cases/conformance/declarationEmit/node_modules/ext/other.ts' does not exist.", "File 'tests/cases/conformance/declarationEmit/node_modules/ext/other.tsx' does not exist.", "File 'tests/cases/conformance/declarationEmit/node_modules/ext/other.d.ts' exist - use it as a name resolution result.", diff --git a/tests/cases/conformance/declarationEmit/typesVersionsDeclarationEmit.ambient.ts b/tests/cases/conformance/declarationEmit/typesVersionsDeclarationEmit.ambient.ts index 447f3aaa82a..b03c1eea078 100644 --- a/tests/cases/conformance/declarationEmit/typesVersionsDeclarationEmit.ambient.ts +++ b/tests/cases/conformance/declarationEmit/typesVersionsDeclarationEmit.ambient.ts @@ -9,7 +9,7 @@ "version": "1.0.0", "types": "index", "typesVersions": { - "3.1": { "*" : ["ts3.1/*"] } + ">=3.1.0-0": { "*" : ["ts3.1/*"] } } } diff --git a/tests/cases/conformance/declarationEmit/typesVersionsDeclarationEmit.multiFile.ts b/tests/cases/conformance/declarationEmit/typesVersionsDeclarationEmit.multiFile.ts index 57ae6c1d631..01adfac0480 100644 --- a/tests/cases/conformance/declarationEmit/typesVersionsDeclarationEmit.multiFile.ts +++ b/tests/cases/conformance/declarationEmit/typesVersionsDeclarationEmit.multiFile.ts @@ -8,7 +8,7 @@ "version": "1.0.0", "types": "index", "typesVersions": { - "3.1": { "*" : ["ts3.1/*"] } + ">=3.1.0-0": { "*" : ["ts3.1/*"] } } } diff --git a/tests/cases/conformance/declarationEmit/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.ts b/tests/cases/conformance/declarationEmit/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.ts index 3391361225d..ee37f436302 100644 --- a/tests/cases/conformance/declarationEmit/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.ts +++ b/tests/cases/conformance/declarationEmit/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.ts @@ -8,7 +8,7 @@ "version": "1.0.0", "types": "index", "typesVersions": { - "3.1": { "*" : ["ts3.1/*"] } + ">=3.1.0-0": { "*" : ["ts3.1/*"] } } } diff --git a/tests/cases/conformance/declarationEmit/typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.ts b/tests/cases/conformance/declarationEmit/typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.ts index 15072d2a7ed..7ef6adcce52 100644 --- a/tests/cases/conformance/declarationEmit/typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.ts +++ b/tests/cases/conformance/declarationEmit/typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.ts @@ -8,7 +8,7 @@ "version": "1.0.0", "types": "index", "typesVersions": { - "3.1": { + ">=3.1.0-0": { "index" : ["ts3.1/index"] } } diff --git a/tests/cases/conformance/moduleResolution/typesVersions.ambientModules.ts b/tests/cases/conformance/moduleResolution/typesVersions.ambientModules.ts index 2de5f470473..870a1a1308d 100644 --- a/tests/cases/conformance/moduleResolution/typesVersions.ambientModules.ts +++ b/tests/cases/conformance/moduleResolution/typesVersions.ambientModules.ts @@ -8,7 +8,7 @@ "version": "1.0.0", "types": "index", "typesVersions": { - "3.1": { "*" : ["ts3.1/*"] } + ">=3.1.0-0": { "*" : ["ts3.1/*"] } } } diff --git a/tests/cases/conformance/moduleResolution/typesVersions.multiFile.ts b/tests/cases/conformance/moduleResolution/typesVersions.multiFile.ts index 8d57630af21..14a05118b65 100644 --- a/tests/cases/conformance/moduleResolution/typesVersions.multiFile.ts +++ b/tests/cases/conformance/moduleResolution/typesVersions.multiFile.ts @@ -7,7 +7,7 @@ "version": "1.0.0", "types": "index", "typesVersions": { - "3.1": { "*" : ["ts3.1/*"] } + ">=3.1.0-0": { "*" : ["ts3.1/*"] } } }