From fa2691164713d454e0ae2756cbf4780cf0b052fa Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Tue, 31 May 2022 11:00:25 -0700 Subject: [PATCH] Get codebase building pre bundling This isn't totally complete, but enough to get everything building and tests running manually. The next commit will make the build work fully. --- Gulpfile.mjs | 22 +- src/cancellationToken/cancellationToken.ts | 2 - src/cancellationToken/tsconfig.json | 14 +- src/compiler/sys.ts | 9 +- src/compiler/tsconfig.json | 80 +----- src/compiler/tsconfig.release.json | 10 - src/debug/tsconfig.json | 11 +- src/deprecatedCompat/tsconfig.json | 18 +- src/dynamicImportCompat/tsconfig.json | 9 +- src/executeCommandLine/tsconfig.json | 7 +- src/executeCommandLine/tsconfig.release.json | 11 - src/harness/tsconfig.json | 42 +-- src/jsTyping/tsconfig.json | 11 +- src/loggedIO/tsconfig.json | 10 +- src/server/_namespaces/ts.server.ts | 4 +- src/server/tsconfig.json | 22 +- src/services/tsconfig.json | 165 +----------- src/testRunner/_namespaces/FourSlash.ts | 1 - src/testRunner/_namespaces/Harness.ts | 11 +- src/testRunner/_namespaces/Playback.ts | 1 - src/testRunner/_namespaces/Utils.ts | 1 - src/testRunner/_namespaces/compiler.ts | 1 - src/testRunner/_namespaces/documents.ts | 1 - src/testRunner/_namespaces/evaluator.ts | 1 - src/testRunner/_namespaces/fakes.ts | 1 - .../_namespaces/ts.projectSystem.ts | 66 ----- src/testRunner/_namespaces/ts.server.ts | 1 - src/testRunner/_namespaces/ts.textStorage.ts | 3 - src/testRunner/_namespaces/ts.ts | 86 +----- src/testRunner/_namespaces/ts.tscWatch.ts | 25 -- src/testRunner/_namespaces/vfs.ts | 1 - src/testRunner/_namespaces/vpath.ts | 1 - src/testRunner/compilerRef.ts | 2 - src/testRunner/documentsRef.ts | 2 - src/testRunner/evaluatorRef.ts | 2 - src/testRunner/fakesRef.ts | 2 - src/testRunner/fourslashRef.ts | 2 - src/testRunner/parallel/host.ts | 2 +- src/testRunner/playbackRef.ts | 2 - src/testRunner/runner.ts | 8 + src/testRunner/tests.ts | 188 +++++++++++++ src/testRunner/tsconfig.json | 248 +----------------- src/testRunner/unittests/helpers.ts | 241 +++++++++++++++++ src/testRunner/unittests/moduleResolution.ts | 30 +-- .../unittests/reuseProgramStructure.ts | 211 +-------------- .../unittests/tsserver/dynamicFiles.ts | 6 +- src/testRunner/unittests/tsserver/helpers.ts | 12 + .../unittests/tsserver/projectReferences.ts | 8 +- src/testRunner/utilsRef.ts | 2 - src/testRunner/vfsRef.ts | 2 - src/testRunner/vpathRef.ts | 2 - src/tsc/_namespaces/ts.ts | 1 - src/tsc/tsconfig.json | 11 +- src/tsc/tsconfig.release.json | 17 -- src/tsconfig-base.json | 6 +- src/tsconfig-library-base.json | 10 - src/tsconfig-noncomposite-base.json | 9 - src/tsconfig.json | 20 +- src/tsserver/nodeServer.ts | 3 +- src/tsserver/tsconfig.json | 14 +- src/tsserverlibrary/_namespaces/ts.server.ts | 1 - src/tsserverlibrary/tsconfig.json | 12 +- src/tsserverlibrary/tsserverlibrary.ts | 6 +- src/typescript/_namespaces/ts.ts | 6 + src/typescript/tsconfig.json | 13 + src/typescript/typescript.ts | 21 ++ src/typingsInstaller/tsconfig.json | 12 +- src/typingsInstallerCore/tsconfig.json | 9 +- src/watchGuard/tsconfig.json | 10 +- src/webServer/tsconfig.json | 10 +- tests/cases/fourslash/fourslash.ts | 3 +- 71 files changed, 613 insertions(+), 1201 deletions(-) delete mode 100644 src/compiler/tsconfig.release.json delete mode 100644 src/executeCommandLine/tsconfig.release.json delete mode 100644 src/testRunner/_namespaces/ts.textStorage.ts delete mode 100644 src/testRunner/compilerRef.ts delete mode 100644 src/testRunner/documentsRef.ts delete mode 100644 src/testRunner/evaluatorRef.ts delete mode 100644 src/testRunner/fakesRef.ts delete mode 100644 src/testRunner/fourslashRef.ts delete mode 100644 src/testRunner/playbackRef.ts create mode 100644 src/testRunner/tests.ts create mode 100644 src/testRunner/unittests/helpers.ts delete mode 100644 src/testRunner/utilsRef.ts delete mode 100644 src/testRunner/vfsRef.ts delete mode 100644 src/testRunner/vpathRef.ts delete mode 100644 src/tsc/tsconfig.release.json delete mode 100644 src/tsconfig-library-base.json delete mode 100644 src/tsconfig-noncomposite-base.json create mode 100644 src/typescript/_namespaces/ts.ts create mode 100644 src/typescript/tsconfig.json create mode 100644 src/typescript/typescript.ts diff --git a/Gulpfile.mjs b/Gulpfile.mjs index f5dc5b189f09c..7a257b2fd4cc4 100644 --- a/Gulpfile.mjs +++ b/Gulpfile.mjs @@ -21,6 +21,8 @@ const { src, dest, task, parallel, series, watch } = gulp; const copyright = "CopyrightNotice.txt"; const cleanTasks = []; +const testRunner = "./built/local/testRunner/runner.js"; + const buildScripts = () => buildProject("scripts"); task("scripts", buildScripts); task("scripts").description = "Builds files in the 'scripts' folder."; @@ -91,6 +93,14 @@ const localize = async () => { } }; +const preSrc = parallel(generateLibs, series(buildScripts, generateDiagnostics, localize)); +const buildSrc = () => buildProject("src"); + +task("build-src", series(preSrc, buildSrc)); + +const cleanSrc = () => cleanProject("src"); +task("clean-src", cleanSrc); + const buildDebugTools = () => buildProject("src/debug"); const cleanDebugTools = () => cleanProject("src/debug"); cleanTasks.push(cleanDebugTools); @@ -405,8 +415,8 @@ task("watch-local").flags = { const preTest = parallel(buildTsc, buildTests, buildServices, buildLssl); preTest.displayName = "preTest"; -const runTests = () => runConsoleTests("built/local/run.js", "mocha-fivemat-progress-reporter", /*runInParallel*/ false, /*watchMode*/ false); -task("runtests", series(preBuild, preTest, runTests)); +const runTests = () => runConsoleTests(testRunner, "mocha-fivemat-progress-reporter", /*runInParallel*/ false, /*watchMode*/ false); +task("runtests", series(/*preBuild, preTest,*/ task("build-src"), runTests)); // TODO(jakebailey): fix this for modules task("runtests").description = "Runs the tests using the built run.js file."; task("runtests").flags = { "-t --tests=": "Pattern for tests to run.", @@ -424,8 +434,8 @@ task("runtests").flags = { " --shardId": "1-based ID of this shard (default: 1)", }; -const runTestsParallel = () => runConsoleTests("built/local/run.js", "min", /*runInParallel*/ cmdLineOptions.workers > 1, /*watchMode*/ false); -task("runtests-parallel", series(preBuild, preTest, runTestsParallel)); +const runTestsParallel = () => runConsoleTests(testRunner, "min", /*runInParallel*/ cmdLineOptions.workers > 1, /*watchMode*/ false); +task("runtests-parallel", series(/*preBuild, preTest,*/ task("build-src"), runTestsParallel)); // TODO(jakebailey): fix this for modules task("runtests-parallel").description = "Runs all the tests in parallel using the built run.js file."; task("runtests-parallel").flags = { " --light": "Run tests in light mode (fewer verifications, but tests run faster).", @@ -550,10 +560,10 @@ task("publish-nightly").description = "Runs `npm publish --tag next` to create a // write some kind of trigger file that indicates build completion that we could listen for instead. const watchRuntests = () => watch(["built/local/*.js", "tests/cases/**/*.ts", "tests/cases/**/tsconfig.json"], { delay: 5000 }, async () => { if (cmdLineOptions.tests || cmdLineOptions.failed) { - await runConsoleTests("built/local/run.js", "mocha-fivemat-progress-reporter", /*runInParallel*/ false, /*watchMode*/ true); + await runConsoleTests(testRunner, "mocha-fivemat-progress-reporter", /*runInParallel*/ false, /*watchMode*/ true); } else { - await runConsoleTests("built/local/run.js", "min", /*runInParallel*/ true, /*watchMode*/ true); + await runConsoleTests(testRunner, "min", /*runInParallel*/ true, /*watchMode*/ true); } }); task("watch", series(preBuild, preTest, parallel(watchLib, watchDiagnostics, watchServices, watchLssl, watchTests, watchRuntests))); diff --git a/src/cancellationToken/cancellationToken.ts b/src/cancellationToken/cancellationToken.ts index 57c82e7522fa6..7f1b3998210e1 100644 --- a/src/cancellationToken/cancellationToken.ts +++ b/src/cancellationToken/cancellationToken.ts @@ -1,5 +1,3 @@ -/// - import * as fs from "fs"; interface ServerCancellationToken { diff --git a/src/cancellationToken/tsconfig.json b/src/cancellationToken/tsconfig.json index 6d27fe45cf37f..ca3cf90c100d5 100644 --- a/src/cancellationToken/tsconfig.json +++ b/src/cancellationToken/tsconfig.json @@ -1,13 +1,7 @@ { - "extends": "../tsconfig-noncomposite-base", + "extends": "../tsconfig-base", "compilerOptions": { - "outDir": "../../built/local/", - "rootDir": ".", - "composite": false, - "declaration": false, - "declarationMap": false, - "removeComments": true, - "incremental": false, + "outDir": "../../built/local/cancellationToken", "module": "commonjs", "types": [ "node" @@ -16,7 +10,5 @@ "es6" ] }, - "files": [ - "cancellationToken.ts" - ] + "include": ["**/*"] } diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 01b48505c84be..ffacb3f1fd721 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -1521,7 +1521,14 @@ export let sys: System = (() => { } }, getExecutingFilePath() { - return __filename; + // This function previously returned a path like `built/local/tsc.js`. + // Now, with a module output, this file is now `built/local/compiler/sys.js`. + // We want to return a file that looks like the old one, so that callers + // can locate other assets like the lib.d.ts files. + // + // TODO(jakebailey): replace this function with one that returns the path + // to the lib folder (or package path)?. + return _path.join(_path.dirname(__dirname), "fake.js"); }, getCurrentDirectory, getDirectories, diff --git a/src/compiler/tsconfig.json b/src/compiler/tsconfig.json index df2979bb397c3..fdffb214503cc 100644 --- a/src/compiler/tsconfig.json +++ b/src/compiler/tsconfig.json @@ -1,88 +1,12 @@ { "extends": "../tsconfig-base", "compilerOptions": { - "outDir": "../../built/local", + "outDir": "../../built/local/compiler", "types": ["node"] }, "references": [ ], - "files": [ - "corePublic.ts", - "core.ts", - "debug.ts", - "semver.ts", - "performanceCore.ts", - "performance.ts", - "perfLogger.ts", - "tracing.ts", - - "types.ts", - "sys.ts", - "path.ts", - "diagnosticInformationMap.generated.ts", - "scanner.ts", - "utilitiesPublic.ts", - "utilities.ts", - "factory/baseNodeFactory.ts", - "factory/parenthesizerRules.ts", - "factory/nodeConverters.ts", - "factory/nodeFactory.ts", - "factory/emitNode.ts", - "factory/emitHelpers.ts", - "factory/nodeTests.ts", - "factory/utilities.ts", - "factory/utilitiesPublic.ts", - "parser.ts", - "commandLineParser.ts", - "moduleNameResolver.ts", - - "binder.ts", - "symbolWalker.ts", - "checker.ts", - "visitorPublic.ts", - "sourcemap.ts", - "transformers/utilities.ts", - "transformers/destructuring.ts", - "transformers/taggedTemplate.ts", - "transformers/ts.ts", - "transformers/classFields.ts", - "transformers/typeSerializer.ts", - "transformers/legacyDecorators.ts", - "transformers/es2017.ts", - "transformers/es2018.ts", - "transformers/es2019.ts", - "transformers/es2020.ts", - "transformers/es2021.ts", - "transformers/esnext.ts", - "transformers/jsx.ts", - "transformers/es2016.ts", - "transformers/es2015.ts", - "transformers/es5.ts", - "transformers/generators.ts", - "transformers/module/module.ts", - "transformers/module/system.ts", - "transformers/module/esnextAnd2015.ts", - "transformers/module/node.ts", - "transformers/declarations/diagnostics.ts", - "transformers/declarations.ts", - "transformer.ts", - "emitter.ts", - "watchUtilities.ts", - "program.ts", - "builderStatePublic.ts", - "builderState.ts", - "builder.ts", - "builderPublic.ts", - "resolutionCache.ts", - "moduleSpecifiers.ts", - "watch.ts", - "watchPublic.ts", - "tsbuild.ts", - "tsbuildPublic.ts", - "_namespaces/ts.ts", - "_namespaces/ts.moduleSpecifiers.ts", - "_namespaces/ts.performance.ts" - ] + "include": ["**/*"] } diff --git a/src/compiler/tsconfig.release.json b/src/compiler/tsconfig.release.json deleted file mode 100644 index ecbc53d780375..0000000000000 --- a/src/compiler/tsconfig.release.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../built/local/release", - "removeComments": true, - "preserveConstEnums": false - }, - "references": [ - ] -} diff --git a/src/debug/tsconfig.json b/src/debug/tsconfig.json index 45353e055756e..06b94b3b2cbb5 100644 --- a/src/debug/tsconfig.json +++ b/src/debug/tsconfig.json @@ -1,14 +1,9 @@ { - "extends": "../tsconfig-library-base", + "extends": "../tsconfig-base", "compilerOptions": { "target": "es2019", "lib": ["es2019"], - "outDir": "../../built/local", - "declaration": false, - "sourceMap": true + "outDir": "../../built/local/debug" }, - "files": [ - "dbg.ts", - "_namespaces/Debug.ts" - ] + "include": ["**/*"] } diff --git a/src/deprecatedCompat/tsconfig.json b/src/deprecatedCompat/tsconfig.json index 5eecec15a02dc..571628bf16b3f 100644 --- a/src/deprecatedCompat/tsconfig.json +++ b/src/deprecatedCompat/tsconfig.json @@ -1,22 +1,10 @@ { "extends": "../tsconfig-base", "compilerOptions": { - "outDir": "../../built/local", - "experimentalDecorators": true + "outDir": "../../built/local/deprecatedCompat" }, "references": [ { "path": "../compiler" } ], - "files": [ - "deprecations.ts", - "4.0/nodeFactoryTopLevelExports.ts", - "4.0/renamedNodeTests.ts", - "4.0/renamedMapInterfaces.ts", - "4.2/renamedNodeTests.ts", - "4.2/abstractConstructorTypes.ts", - "4.6/importTypeAssertions.ts", - "4.7/typeParameterModifiers.ts", - "4.8/mergeDecoratorsAndModifiers.ts", - "_namespaces/ts.ts" - ] -} \ No newline at end of file + "include": ["**/*"] +} diff --git a/src/dynamicImportCompat/tsconfig.json b/src/dynamicImportCompat/tsconfig.json index 5ae4980fdaade..3abacb2133d0a 100644 --- a/src/dynamicImportCompat/tsconfig.json +++ b/src/dynamicImportCompat/tsconfig.json @@ -1,14 +1,11 @@ { - "extends": "../tsconfig-library-base", + "extends": "../tsconfig-base", "compilerOptions": { - "outDir": "../../built/local", + "outDir": "../../built/local/dynamicImportCompat", "rootDir": ".", "target": "esnext", "module": "esnext", - "lib": ["esnext"], - "declaration": false, - "sourceMap": true, - "tsBuildInfoFile": "../../built/local/dynamicImportCompat.tsbuildinfo" + "lib": ["esnext"] }, "files": [ "dynamicImportCompat.ts", diff --git a/src/executeCommandLine/tsconfig.json b/src/executeCommandLine/tsconfig.json index 88eed2c43f87c..103bd54a282c2 100644 --- a/src/executeCommandLine/tsconfig.json +++ b/src/executeCommandLine/tsconfig.json @@ -1,15 +1,12 @@ { "extends": "../tsconfig-base", "compilerOptions": { - "outDir": "../../built/local" + "outDir": "../../built/local/executeCommandLine" }, "references": [ { "path": "../compiler" } ], - "files": [ - "executeCommandLine.ts", - "_namespaces/ts.ts" - ] + "include": ["**/*"] } diff --git a/src/executeCommandLine/tsconfig.release.json b/src/executeCommandLine/tsconfig.release.json deleted file mode 100644 index 57ae0adbf56e3..0000000000000 --- a/src/executeCommandLine/tsconfig.release.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../built/local/release", - "removeComments": true, - "preserveConstEnums": false - }, - "references": [ - { "path": "../compiler/tsconfig.release.json" } - ] -} diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index 55091a17fbe52..dea8d57947f7a 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../tsconfig-base", "compilerOptions": { - "outDir": "../../built/local", + "outDir": "../../built/local/harness", "types": [ "node", "mocha", "chai" ], @@ -19,43 +19,5 @@ { "path": "../deprecatedCompat" }, ], - "files": [ - "collectionsImpl.ts", - "util.ts", - "documentsUtil.ts", - "vpathUtil.ts", - "vfsUtil.ts", - "compilerImpl.ts", - "evaluatorImpl.ts", - "fakesHosts.ts", - "client.ts", - "findUpDir.ts", - - "runnerbase.ts", - "sourceMapRecorder.ts", - "harnessGlobals.ts", - "harnessUtils.ts", - "harnessIO.ts", - "harnessLanguageService.ts", - "virtualFileSystemWithWatch.ts", - "fourslashImpl.ts", - "fourslashInterfaceImpl.ts", - "typeWriter.ts", - "_namespaces/ts.server.ts", - "_namespaces/ts.ts", - "_namespaces/collections.ts", - "_namespaces/compiler.ts", - "_namespaces/documents.ts", - "_namespaces/evaluator.ts", - "_namespaces/fakes.ts", - "_namespaces/Utils.ts", - "_namespaces/FourSlash.ts", - "_namespaces/FourSlashInterface.ts", - "_namespaces/Harness.ts", - "_namespaces/Harness.LanguageService.ts", - "_namespaces/Harness.SourceMapRecorder.ts", - "_namespaces/vfs.ts", - "_namespaces/ts.TestFSWithWatch.ts", - "_namespaces/vpath.ts" - ] + "include": ["**/*"] } diff --git a/src/jsTyping/tsconfig.json b/src/jsTyping/tsconfig.json index 9d360f086afae..e987ba35de5d9 100644 --- a/src/jsTyping/tsconfig.json +++ b/src/jsTyping/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../tsconfig-base", "compilerOptions": { - "outDir": "../../built/local", + "outDir": "../../built/local/jsTyping", "types": [ "node" ], @@ -13,12 +13,5 @@ "references": [ { "path": "../compiler" } ], - "files": [ - "shared.ts", - "types.ts", - "jsTyping.ts", - "_namespaces/ts.JsTyping.ts", - "_namespaces/ts.ts", - "_namespaces/ts.server.ts" - ] + "include": ["**/*"] } diff --git a/src/loggedIO/tsconfig.json b/src/loggedIO/tsconfig.json index 78c7a1ae483c1..8d51cd6926594 100644 --- a/src/loggedIO/tsconfig.json +++ b/src/loggedIO/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../tsconfig-base", "compilerOptions": { - "outDir": "../../built/local", + "outDir": "../../built/local/loggedIO", "types": [ ], "lib": [ @@ -18,11 +18,5 @@ { "path": "../harness" }, ], - "files": [ - "loggedIO.ts", - "_namespaces/Playback.ts", - "_namespaces/ts.server.ts", - "_namespaces/ts.ts", - "_namespaces/Harness.ts" - ] + "include": ["**/*"] } diff --git a/src/server/_namespaces/ts.server.ts b/src/server/_namespaces/ts.server.ts index 66e9ce997b7f3..91d9a909ae7f8 100644 --- a/src/server/_namespaces/ts.server.ts +++ b/src/server/_namespaces/ts.server.ts @@ -4,6 +4,8 @@ export * from "../../jsTyping/_namespaces/ts.server"; export * from "../types"; export * from "../utilitiesPublic"; export * from "../utilities"; +import * as protocol from "./ts.server.protocol"; +export { protocol }; export * from "../scriptInfo"; export * from "../typingsCache"; export * from "../project"; @@ -12,5 +14,3 @@ export * from "../moduleSpecifierCache"; export * from "../packageJsonCache"; export * from "../session"; export * from "../scriptVersionCache"; -import * as protocol from "./ts.server.protocol"; -export { protocol }; diff --git a/src/server/tsconfig.json b/src/server/tsconfig.json index 8fac9006b09f0..340768af8e2fb 100644 --- a/src/server/tsconfig.json +++ b/src/server/tsconfig.json @@ -1,9 +1,7 @@ { "extends": "../tsconfig-base", "compilerOptions": { - "removeComments": false, - "outDir": "../../built/local", - "preserveConstEnums": true, + "outDir": "../../built/local/server", "types": [ "node" ] @@ -13,21 +11,5 @@ { "path": "../jsTyping" }, { "path": "../services" } ], - "files": [ - "types.ts", - "utilitiesPublic.ts", - "utilities.ts", - "protocol.ts", - "scriptInfo.ts", - "typingsCache.ts", - "project.ts", - "editorServices.ts", - "moduleSpecifierCache.ts", - "packageJsonCache.ts", - "session.ts", - "scriptVersionCache.ts", - "_namespaces/ts.server.ts", - "_namespaces/ts.ts", - "_namespaces/ts.server.protocol.ts" - ] + "include": ["**/*"] } diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index f87f896dabb0e..3bab5eb0b81c1 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -1,172 +1,11 @@ { "extends": "../tsconfig-base", "compilerOptions": { - "outDir": "../../built/local" + "outDir": "../../built/local/services" }, "references": [ { "path": "../compiler" }, { "path": "../jsTyping" } ], - "files": [ - "types.ts", - "utilities.ts", - "exportInfoMap.ts", - "classifier.ts", - "classifier2020.ts", - "stringCompletions.ts", - "completions.ts", - "documentHighlights.ts", - "documentRegistry.ts", - "importTracker.ts", - "findAllReferences.ts", - "callHierarchy.ts", - "getEditsForFileRename.ts", - "goToDefinition.ts", - "jsDoc.ts", - "navigateTo.ts", - "navigationBar.ts", - "organizeImports.ts", - "getEditsForFileRename.ts", - "outliningElementsCollector.ts", - "patternMatcher.ts", - "preProcess.ts", - "rename.ts", - "smartSelection.ts", - "signatureHelp.ts", - "inlayHints.ts", - "sourcemaps.ts", - "suggestionDiagnostics.ts", - "symbolDisplay.ts", - "transpile.ts", - "formatting/formattingContext.ts", - "formatting/formattingScanner.ts", - "formatting/rule.ts", - "formatting/rules.ts", - "formatting/rulesMap.ts", - "formatting/formatting.ts", - "formatting/smartIndenter.ts", - "textChanges.ts", - "codeFixProvider.ts", - "refactorProvider.ts", - "codefixes/addConvertToUnknownForNonOverlappingTypes.ts", - "codefixes/addEmptyExportDeclaration.ts", - "codefixes/addMissingAsync.ts", - "codefixes/addMissingAwait.ts", - "codefixes/addMissingConst.ts", - "codefixes/addMissingDeclareProperty.ts", - "codefixes/addMissingInvocationForDecorator.ts", - "codefixes/addNameToNamelessParameter.ts", - "codefixes/addOptionalPropertyUndefined.ts", - "codefixes/annotateWithTypeFromJSDoc.ts", - "codefixes/convertFunctionToEs6Class.ts", - "codefixes/convertToAsyncFunction.ts", - "codefixes/convertToEsModule.ts", - "codefixes/correctQualifiedNameToIndexedAccessType.ts", - "codefixes/convertToTypeOnlyExport.ts", - "codefixes/convertToTypeOnlyImport.ts", - "codefixes/convertLiteralTypeToMappedType.ts", - "codefixes/fixClassIncorrectlyImplementsInterface.ts", - "codefixes/importFixes.ts", - "codefixes/fixAddMissingConstraint.ts", - "codefixes/fixOverrideModifier.ts", - "codefixes/fixNoPropertyAccessFromIndexSignature.ts", - "codefixes/fixImplicitThis.ts", - "codefixes/fixImportNonExportedMember.ts", - "codefixes/fixIncorrectNamedTupleSyntax.ts", - "codefixes/fixSpelling.ts", - "codefixes/returnValueCorrect.ts", - "codefixes/fixAddMissingMember.ts", - "codefixes/fixAddMissingNewOperator.ts", - "codefixes/fixCannotFindModule.ts", - "codefixes/fixClassDoesntImplementInheritedAbstractMember.ts", - "codefixes/fixClassSuperMustPrecedeThisAccess.ts", - "codefixes/fixConstructorForDerivedNeedSuperCall.ts", - "codefixes/fixEnableExperimentalDecorators.ts", - "codefixes/fixEnableJsxFlag.ts", - "codefixes/fixNaNEquality.ts", - "codefixes/fixModuleAndTargetOptions.ts", - "codefixes/fixPropertyAssignment.ts", - "codefixes/fixExtendsInterfaceBecomesImplements.ts", - "codefixes/fixForgottenThisPropertyAccess.ts", - "codefixes/fixInvalidJsxCharacters.ts", - "codefixes/fixUnmatchedParameter.ts", - "codefixes/fixUnreferenceableDecoratorMetadata.ts", - "codefixes/fixUnusedIdentifier.ts", - "codefixes/fixUnreachableCode.ts", - "codefixes/fixUnusedLabel.ts", - "codefixes/fixJSDocTypes.ts", - "codefixes/fixMissingCallParentheses.ts", - "codefixes/fixAwaitInSyncFunction.ts", - "codefixes/fixPropertyOverrideAccessor.ts", - "codefixes/inferFromUsage.ts", - "codefixes/fixReturnTypeInAsyncFunction.ts", - "codefixes/disableJsDiagnostics.ts", - "codefixes/helpers.ts", - "codefixes/generateAccessors.ts", - "codefixes/fixInvalidImportSyntax.ts", - "codefixes/fixStrictClassInitialization.ts", - "codefixes/requireInTs.ts", - "codefixes/useDefaultImport.ts", - "codefixes/useBigintLiteral.ts", - "codefixes/fixAddModuleReferTypeMissingTypeof.ts", - "codefixes/wrapJsxInFragment.ts", - "codefixes/convertToMappedObjectType.ts", - "codefixes/removeAccidentalCallParentheses.ts", - "codefixes/removeUnnecessaryAwait.ts", - "codefixes/splitTypeOnlyImport.ts", - "codefixes/convertConstToLet.ts", - "codefixes/fixExpectedComma.ts", - "codefixes/fixAddVoidToPromise.ts", - "refactors/convertExport.ts", - "refactors/convertImport.ts", - "refactors/convertToOptionalChainExpression.ts", - "refactors/convertOverloadListToSingleSignature.ts", - "refactors/extractSymbol.ts", - "refactors/extractType.ts", - "refactors/generateGetAccessorAndSetAccessor.ts", - "refactors/helpers.ts", - "refactors/moveToNewFile.ts", - "refactors/addOrRemoveBracesToArrowFunction.ts", - "refactors/convertParamsToDestructuredObject.ts", - "refactors/convertStringOrTemplateLiteral.ts", - "refactors/convertArrowFunctionOrFunctionExpression.ts", - "refactors/inferFunctionReturnType.ts", - "services.ts", - "breakpoints.ts", - "transform.ts", - "shims.ts", - "globalThisShim.ts", - "exportAsModule.ts", - "_namespaces/ts.BreakpointResolver.ts", - "_namespaces/ts.ts", - "_namespaces/ts.CallHierarchy.ts", - "_namespaces/ts.classifier.v2020.ts", - "_namespaces/ts.classifier.ts", - "_namespaces/ts.codefix.ts", - "_namespaces/ts.Completions.ts", - "_namespaces/ts.FindAllReferences.ts", - "_namespaces/ts.GoToDefinition.ts", - "_namespaces/ts.InlayHints.ts", - "_namespaces/ts.JsDoc.ts", - "_namespaces/ts.NavigateTo.ts", - "_namespaces/ts.NavigationBar.ts", - "_namespaces/ts.OrganizeImports.ts", - "_namespaces/ts.OutliningElementsCollector.ts", - "_namespaces/ts.refactor.ts", - "_namespaces/ts.Rename.ts", - "_namespaces/ts.SignatureHelp.ts", - "_namespaces/ts.SmartSelectionRange.ts", - "_namespaces/ts.Completions.StringCompletions.ts", - "_namespaces/ts.SymbolDisplay.ts", - "_namespaces/ts.textChanges.ts", - "_namespaces/ts.formatting.ts", - "_namespaces/ts.refactor.addOrRemoveBracesToArrowFunction.ts", - "_namespaces/ts.refactor.convertArrowFunctionOrFunctionExpression.ts", - "_namespaces/ts.refactor.convertParamsToDestructuredObject.ts", - "_namespaces/ts.refactor.convertStringOrTemplateLiteral.ts", - "_namespaces/ts.refactor.convertToOptionalChainExpression.ts", - "_namespaces/ts.refactor.extractSymbol.ts", - "_namespaces/ts.refactor.generateGetAccessorAndSetAccessor.ts", - "_namespaces/ts.refactor.inferFunctionReturnType.ts" - ] + "include": ["**/*"] } diff --git a/src/testRunner/_namespaces/FourSlash.ts b/src/testRunner/_namespaces/FourSlash.ts index b314d7d2e24bf..b81535c48ffd8 100644 --- a/src/testRunner/_namespaces/FourSlash.ts +++ b/src/testRunner/_namespaces/FourSlash.ts @@ -1,4 +1,3 @@ /* Generated file to emulate the FourSlash namespace. */ export * from "../../harness/_namespaces/FourSlash"; -export * from "../fourslashRef"; diff --git a/src/testRunner/_namespaces/Harness.ts b/src/testRunner/_namespaces/Harness.ts index eeef44fbd754b..a5b5cb5ab35b1 100644 --- a/src/testRunner/_namespaces/Harness.ts +++ b/src/testRunner/_namespaces/Harness.ts @@ -2,10 +2,17 @@ export * from "../../harness/_namespaces/Harness"; export * from "../../loggedIO/_namespaces/Harness"; + +import * as Parallel from "./Harness.Parallel"; +export { Parallel }; + export * from "../fourslashRunner"; export * from "../compilerRunner"; export * from "../externalCompileRunner"; export * from "../test262Runner"; export * from "../runner"; -import * as Parallel from "./Harness.Parallel"; -export { Parallel }; + +// If running bundled, we want this to be here so that esbuild places the tests after runner.ts. +if (!__filename.endsWith("Harness.js")) { + require("../tests"); +} diff --git a/src/testRunner/_namespaces/Playback.ts b/src/testRunner/_namespaces/Playback.ts index 756f8f0e4eddc..90e7eae5f16b9 100644 --- a/src/testRunner/_namespaces/Playback.ts +++ b/src/testRunner/_namespaces/Playback.ts @@ -1,4 +1,3 @@ /* Generated file to emulate the Playback namespace. */ export * from "../../loggedIO/_namespaces/Playback"; -export * from "../playbackRef"; diff --git a/src/testRunner/_namespaces/Utils.ts b/src/testRunner/_namespaces/Utils.ts index 69e9f1e29d042..f7bd754263d74 100644 --- a/src/testRunner/_namespaces/Utils.ts +++ b/src/testRunner/_namespaces/Utils.ts @@ -1,4 +1,3 @@ /* Generated file to emulate the Utils namespace. */ export * from "../../harness/_namespaces/Utils"; -export * from "../utilsRef"; diff --git a/src/testRunner/_namespaces/compiler.ts b/src/testRunner/_namespaces/compiler.ts index b0836c2749afc..62e194d59712a 100644 --- a/src/testRunner/_namespaces/compiler.ts +++ b/src/testRunner/_namespaces/compiler.ts @@ -1,4 +1,3 @@ /* Generated file to emulate the compiler namespace. */ export * from "../../harness/_namespaces/compiler"; -export * from "../compilerRef"; diff --git a/src/testRunner/_namespaces/documents.ts b/src/testRunner/_namespaces/documents.ts index ceeb38f29c6b9..bf76b1332fc47 100644 --- a/src/testRunner/_namespaces/documents.ts +++ b/src/testRunner/_namespaces/documents.ts @@ -1,4 +1,3 @@ /* Generated file to emulate the documents namespace. */ export * from "../../harness/_namespaces/documents"; -export * from "../documentsRef"; diff --git a/src/testRunner/_namespaces/evaluator.ts b/src/testRunner/_namespaces/evaluator.ts index 26676e38c3e55..9710863c9b2ec 100644 --- a/src/testRunner/_namespaces/evaluator.ts +++ b/src/testRunner/_namespaces/evaluator.ts @@ -1,4 +1,3 @@ /* Generated file to emulate the evaluator namespace. */ export * from "../../harness/_namespaces/evaluator"; -export * from "../evaluatorRef"; diff --git a/src/testRunner/_namespaces/fakes.ts b/src/testRunner/_namespaces/fakes.ts index f783f8f72b1dc..1b6c51d409411 100644 --- a/src/testRunner/_namespaces/fakes.ts +++ b/src/testRunner/_namespaces/fakes.ts @@ -1,4 +1,3 @@ /* Generated file to emulate the fakes namespace. */ export * from "../../harness/_namespaces/fakes"; -export * from "../fakesRef"; diff --git a/src/testRunner/_namespaces/ts.projectSystem.ts b/src/testRunner/_namespaces/ts.projectSystem.ts index 48038443996c7..2723fee96d7bc 100644 --- a/src/testRunner/_namespaces/ts.projectSystem.ts +++ b/src/testRunner/_namespaces/ts.projectSystem.ts @@ -1,69 +1,3 @@ /* Generated file to emulate the ts.projectSystem namespace. */ export * from "../unittests/tsserver/helpers"; -export * from "../unittests/tsserver/applyChangesToOpenFiles"; -export * from "../unittests/tsserver/autoImportProvider"; -export * from "../unittests/tsserver/auxiliaryProject"; -export * from "../unittests/tsserver/cachingFileSystemInformation"; -export * from "../unittests/tsserver/cancellationToken"; -export * from "../unittests/tsserver/compileOnSave"; -export * from "../unittests/tsserver/completions"; -export * from "../unittests/tsserver/completionsIncomplete"; -export * from "../unittests/tsserver/configFileSearch"; -export * from "../unittests/tsserver/configuredProjects"; -export * from "../unittests/tsserver/declarationFileMaps"; -export * from "../unittests/tsserver/documentRegistry"; -export * from "../unittests/tsserver/duplicatePackages"; -export * from "../unittests/tsserver/dynamicFiles"; -export * from "../unittests/tsserver/events/largeFileReferenced"; -export * from "../unittests/tsserver/events/projectLanguageServiceState"; -export * from "../unittests/tsserver/events/projectLoading"; -export * from "../unittests/tsserver/events/projectUpdatedInBackground"; -export * from "../unittests/tsserver/exportMapCache"; -export * from "../unittests/tsserver/externalProjects"; -export * from "../unittests/tsserver/forceConsistentCasingInFileNames"; -export * from "../unittests/tsserver/formatSettings"; -export * from "../unittests/tsserver/getApplicableRefactors"; -export * from "../unittests/tsserver/getEditsForFileRename"; -export * from "../unittests/tsserver/getExportReferences"; -export * from "../unittests/tsserver/getFileReferences"; -export * from "../unittests/tsserver/importHelpers"; -export * from "../unittests/tsserver/inlayHints"; -export * from "../unittests/tsserver/inferredProjects"; -export * from "../unittests/tsserver/jsdocTag"; -export * from "../unittests/tsserver/languageService"; -export * from "../unittests/tsserver/maxNodeModuleJsDepth"; -export * from "../unittests/tsserver/metadataInResponse"; -export * from "../unittests/tsserver/moduleResolution"; -export * from "../unittests/tsserver/moduleSpecifierCache"; -export * from "../unittests/tsserver/navTo"; -export * from "../unittests/tsserver/occurences"; -export * from "../unittests/tsserver/openFile"; -export * from "../unittests/tsserver/packageJsonInfo"; -export * from "../unittests/tsserver/partialSemanticServer"; -export * from "../unittests/tsserver/plugins"; -export * from "../unittests/tsserver/projectErrors"; -export * from "../unittests/tsserver/projectReferenceCompileOnSave"; -export * from "../unittests/tsserver/projectReferenceErrors"; -export * from "../unittests/tsserver/projectReferences"; -export * from "../unittests/tsserver/projectReferencesSourcemap"; -export * from "../unittests/tsserver/projects"; -export * from "../unittests/tsserver/projectsWithReferences"; -export * from "../unittests/tsserver/refactors"; -export * from "../unittests/tsserver/reload"; -export * from "../unittests/tsserver/reloadProjects"; -export * from "../unittests/tsserver/rename"; -export * from "../unittests/tsserver/resolutionCache"; -export * from "../unittests/tsserver/skipLibCheck"; -export * from "../unittests/tsserver/smartSelection"; -export * from "../unittests/tsserver/symlinkCache"; -export * from "../unittests/tsserver/symLinks"; -export * from "../unittests/tsserver/syntacticServer"; -export * from "../unittests/tsserver/syntaxOperations"; -export * from "../unittests/tsserver/telemetry"; -export * from "../unittests/tsserver/typeAquisition"; -export * from "../unittests/tsserver/typeOnlyImportChains"; -export * from "../unittests/tsserver/typeReferenceDirectives"; -export * from "../unittests/tsserver/typingsInstaller"; -export * from "../unittests/tsserver/watchEnvironment"; -export * from "../unittests/tsserver/webServer"; diff --git a/src/testRunner/_namespaces/ts.server.ts b/src/testRunner/_namespaces/ts.server.ts index 55f4afed9df57..225d9d4e6aa24 100644 --- a/src/testRunner/_namespaces/ts.server.ts +++ b/src/testRunner/_namespaces/ts.server.ts @@ -6,4 +6,3 @@ export * from "../../webServer/_namespaces/ts.server"; export * from "../../typingsInstallerCore/_namespaces/ts.server"; export * from "../../harness/_namespaces/ts.server"; export * from "../../loggedIO/_namespaces/ts.server"; -export * from "../unittests/tsserver/session"; diff --git a/src/testRunner/_namespaces/ts.textStorage.ts b/src/testRunner/_namespaces/ts.textStorage.ts deleted file mode 100644 index 1243be98aed05..0000000000000 --- a/src/testRunner/_namespaces/ts.textStorage.ts +++ /dev/null @@ -1,3 +0,0 @@ -/* Generated file to emulate the ts.textStorage namespace. */ - -export * from "../unittests/tsserver/textStorage"; diff --git a/src/testRunner/_namespaces/ts.ts b/src/testRunner/_namespaces/ts.ts index 04425918ecbd6..d763d9b8291a2 100644 --- a/src/testRunner/_namespaces/ts.ts +++ b/src/testRunner/_namespaces/ts.ts @@ -10,87 +10,13 @@ export * from "../../typingsInstallerCore/_namespaces/ts"; export * from "../../deprecatedCompat/_namespaces/ts"; export * from "../../harness/_namespaces/ts"; export * from "../../loggedIO/_namespaces/ts"; -export * from "../unittests/services/extract/helpers"; -export * from "../unittests/tsbuild/helpers"; -export * from "../unittests/tsc/helpers"; -export * from "../unittests/asserts"; -export * from "../unittests/base64"; -export * from "../unittests/builder"; -export * from "../unittests/comments"; -export * from "../unittests/compilerCore"; -export * from "../unittests/convertToBase64"; -export * from "../unittests/customTransforms"; -export * from "../unittests/factory"; -export * from "../unittests/incrementalParser"; -export * from "../unittests/jsDocParsing"; -export * from "../unittests/jsonParserRecovery"; -export * from "../unittests/moduleResolution"; -export * from "../unittests/parsePseudoBigInt"; -export * from "../unittests/printer"; -export * from "../unittests/programApi"; -export * from "../unittests/reuseProgramStructure"; -export * from "../unittests/semver"; -export * from "../unittests/transform"; -export * from "../unittests/config/commandLineParsing"; -export * from "../unittests/config/configurationExtension"; -export * from "../unittests/config/convertCompilerOptionsFromJson"; -export * from "../unittests/config/convertTypeAcquisitionFromJson"; -export * from "../unittests/config/initializeTSConfig"; -export * from "../unittests/config/matchFiles"; -export * from "../unittests/config/projectReferences"; -export * from "../unittests/config/showConfig"; -export * from "../unittests/config/tsconfigParsing"; -export * from "../unittests/config/tsconfigParsingWatchOptions"; -export * from "../unittests/services/cancellableLanguageServiceOperations"; -export * from "../unittests/services/convertToAsyncFunction"; -export * from "../unittests/services/extract/constants"; -export * from "../unittests/services/extract/functions"; -export * from "../unittests/services/extract/symbolWalker"; -export * from "../unittests/services/extract/ranges"; -export * from "../unittests/services/hostNewLineSupport"; -export * from "../unittests/services/languageService"; -export * from "../unittests/services/organizeImports"; -export * from "../unittests/services/textChanges"; -export * from "../unittests/services/transpile"; -export * from "../unittests/tsbuild/amdModulesWithOut"; -export * from "../unittests/tsbuild/clean"; -export * from "../unittests/tsbuild/configFileErrors"; -export * from "../unittests/tsbuild/configFileExtends"; -export * from "../unittests/tsbuild/containerOnlyReferenced"; -export * from "../unittests/tsbuild/declarationEmit"; -export * from "../unittests/tsbuild/demo"; -export * from "../unittests/tsbuild/emitDeclarationOnly"; -export * from "../unittests/tsbuild/emptyFiles"; -export * from "../unittests/tsbuild/exitCodeOnBogusFile"; -export * from "../unittests/tsbuild/graphOrdering"; -export * from "../unittests/tsbuild/inferredTypeFromTransitiveModule"; -export * from "../unittests/tsbuild/javascriptProjectEmit"; -export * from "../unittests/tsbuild/lateBoundSymbol"; -export * from "../unittests/tsbuild/moduleSpecifiers"; -export * from "../unittests/tsbuild/noEmit"; -export * from "../unittests/tsbuild/noEmitOnError"; -export * from "../unittests/tsbuild/outFile"; -export * from "../unittests/tsbuild/outputPaths"; -export * from "../unittests/tsbuild/publicApi"; -export * from "../unittests/tsbuild/referencesWithRootDirInParent"; -export * from "../unittests/tsbuild/resolveJsonModule"; -export * from "../unittests/tsbuild/sample"; -export * from "../unittests/tsbuild/transitiveReferences"; -export * from "../unittests/tsc/composite"; -export * from "../unittests/tsc/declarationEmit"; -export * from "../unittests/tsc/forceConsistentCasingInFileNames"; -export * from "../unittests/tsc/incremental"; -export * from "../unittests/tsc/listFilesOnly"; -export * from "../unittests/tsc/projectReferences"; -export * from "../unittests/tsc/redirect"; -export * from "../unittests/tsc/runWithoutArgs"; -export * from "../unittests/tsserver/versionCache"; -export * from "../unittests/debugDeprecation"; import * as tscWatch from "./ts.tscWatch"; export { tscWatch }; -import * as projectSystem from "./ts.projectSystem"; -export { projectSystem }; import * as server from "./ts.server"; export { server }; -import * as textStorage from "./ts.textStorage"; -export { textStorage }; +import * as projectSystem from "./ts.projectSystem"; +export { projectSystem }; +export * from "../unittests/helpers"; +export * from "../unittests/services/extract/helpers"; +export * from "../unittests/tsbuild/helpers"; +export * from "../unittests/tsc/helpers"; diff --git a/src/testRunner/_namespaces/ts.tscWatch.ts b/src/testRunner/_namespaces/ts.tscWatch.ts index 3220ae1aa9239..aaa9390cb9e73 100644 --- a/src/testRunner/_namespaces/ts.tscWatch.ts +++ b/src/testRunner/_namespaces/ts.tscWatch.ts @@ -1,28 +1,3 @@ /* Generated file to emulate the ts.tscWatch namespace. */ export * from "../unittests/tscWatch/helpers"; -export * from "../unittests/tsbuild/moduleResolution"; -export * from "../unittests/tsbuildWatch/configFileErrors"; -export * from "../unittests/tsbuildWatch/demo"; -export * from "../unittests/tsbuildWatch/moduleResolution"; -export * from "../unittests/tsbuildWatch/noEmit"; -export * from "../unittests/tsbuildWatch/noEmitOnError"; -export * from "../unittests/tsbuildWatch/programUpdates"; -export * from "../unittests/tsbuildWatch/projectsBuilding"; -export * from "../unittests/tsbuildWatch/publicApi"; -export * from "../unittests/tsbuildWatch/reexport"; -export * from "../unittests/tsbuildWatch/watchEnvironment"; -export * from "../unittests/tsc/cancellationToken"; -export * from "../unittests/tscWatch/consoleClearing"; -export * from "../unittests/tscWatch/emit"; -export * from "../unittests/tscWatch/nodeNextWatch"; -export * from "../unittests/tscWatch/emitAndErrorUpdates"; -export * from "../unittests/tscWatch/forceConsistentCasingInFileNames"; -export * from "../unittests/tscWatch/incremental"; -export * from "../unittests/tscWatch/moduleResolution"; -export * from "../unittests/tscWatch/programUpdates"; -export * from "../unittests/tscWatch/projectsWithReferences"; -export * from "../unittests/tscWatch/resolutionCache"; -export * from "../unittests/tscWatch/sourceOfProjectReferenceRedirect"; -export * from "../unittests/tscWatch/watchApi"; -export * from "../unittests/tscWatch/watchEnvironment"; diff --git a/src/testRunner/_namespaces/vfs.ts b/src/testRunner/_namespaces/vfs.ts index 3a8b4f1e4acbe..5fe2e7d9362b5 100644 --- a/src/testRunner/_namespaces/vfs.ts +++ b/src/testRunner/_namespaces/vfs.ts @@ -1,4 +1,3 @@ /* Generated file to emulate the vfs namespace. */ export * from "../../harness/_namespaces/vfs"; -export * from "../vfsRef"; diff --git a/src/testRunner/_namespaces/vpath.ts b/src/testRunner/_namespaces/vpath.ts index 4b1fd139b3b5a..9ae8ad3777f57 100644 --- a/src/testRunner/_namespaces/vpath.ts +++ b/src/testRunner/_namespaces/vpath.ts @@ -1,4 +1,3 @@ /* Generated file to emulate the vpath namespace. */ export * from "../../harness/_namespaces/vpath"; -export * from "../vpathRef"; diff --git a/src/testRunner/compilerRef.ts b/src/testRunner/compilerRef.ts deleted file mode 100644 index c524071b842bd..0000000000000 --- a/src/testRunner/compilerRef.ts +++ /dev/null @@ -1,2 +0,0 @@ -// empty ref to compiler so it can be referenced by unittests -export { }; diff --git a/src/testRunner/documentsRef.ts b/src/testRunner/documentsRef.ts deleted file mode 100644 index e1abbfb2d9c6d..0000000000000 --- a/src/testRunner/documentsRef.ts +++ /dev/null @@ -1,2 +0,0 @@ -// empty ref to documents so it can be referenced by unittests -export { }; diff --git a/src/testRunner/evaluatorRef.ts b/src/testRunner/evaluatorRef.ts deleted file mode 100644 index 965acc02d95be..0000000000000 --- a/src/testRunner/evaluatorRef.ts +++ /dev/null @@ -1,2 +0,0 @@ -// empty ref to evaluator so it can be referenced by unittests -export { }; diff --git a/src/testRunner/fakesRef.ts b/src/testRunner/fakesRef.ts deleted file mode 100644 index ef7d690d5b64c..0000000000000 --- a/src/testRunner/fakesRef.ts +++ /dev/null @@ -1,2 +0,0 @@ -// empty ref to fakes so it can be referenced by unittests -export { }; diff --git a/src/testRunner/fourslashRef.ts b/src/testRunner/fourslashRef.ts deleted file mode 100644 index 7436f5ad2d7a2..0000000000000 --- a/src/testRunner/fourslashRef.ts +++ /dev/null @@ -1,2 +0,0 @@ -// empty ref to FourSlash so it can be referenced by unittests -export { }; diff --git a/src/testRunner/parallel/host.ts b/src/testRunner/parallel/host.ts index f38081ccabd13..c0e38a3eb2721 100644 --- a/src/testRunner/parallel/host.ts +++ b/src/testRunner/parallel/host.ts @@ -263,7 +263,7 @@ export function start() { const configPath = ts.combinePaths(taskConfigsFolder, `task-config${i}.json`); IO.writeFile(configPath, JSON.stringify(config)); const worker: Worker = { - process: fork(__filename, [`--config="${configPath}"`], { stdio: ["pipe", "pipe", "pipe", "ipc"] }), + process: fork(process.argv[1], [`--config="${configPath}"`], { stdio: ["pipe", "pipe", "pipe", "ipc"] }), accumulatedOutput: "", currentTasks: undefined, timer: undefined diff --git a/src/testRunner/playbackRef.ts b/src/testRunner/playbackRef.ts deleted file mode 100644 index 9a46d5740c446..0000000000000 --- a/src/testRunner/playbackRef.ts +++ /dev/null @@ -1,2 +0,0 @@ -// empty ref to Playback so it can be referenced by unittests -export { }; diff --git a/src/testRunner/runner.ts b/src/testRunner/runner.ts index ff59c4e75250b..05e3f4aea1e70 100644 --- a/src/testRunner/runner.ts +++ b/src/testRunner/runner.ts @@ -291,3 +291,11 @@ function startTestEnvironment() { } startTestEnvironment(); + +// This brings in all of the unittests. + +// If running as emitted CJS, we want to start the tests here after startTestEnvironment. +// If running bundled, we will do this in Harness.ts. +if (__filename.endsWith("runner.js")) { + require("./tests"); +} diff --git a/src/testRunner/tests.ts b/src/testRunner/tests.ts new file mode 100644 index 0000000000000..1bd84001cc584 --- /dev/null +++ b/src/testRunner/tests.ts @@ -0,0 +1,188 @@ +import "./unittests/asserts.ts"; +import "./unittests/base64.ts"; +import "./unittests/builder.ts"; +import "./unittests/comments.ts"; +import "./unittests/compilerCore.ts"; +import "./unittests/convertToBase64.ts"; +import "./unittests/customTransforms.ts"; +import "./unittests/factory.ts"; +import "./unittests/incrementalParser.ts"; +import "./unittests/jsDocParsing.ts"; +import "./unittests/jsonParserRecovery.ts"; +import "./unittests/moduleResolution.ts"; +import "./unittests/parsePseudoBigInt.ts"; +import "./unittests/paths.ts"; +import "./unittests/printer.ts"; +import "./unittests/programApi.ts"; +import "./unittests/publicApi.ts"; +import "./unittests/reuseProgramStructure.ts"; +import "./unittests/semver.ts"; +import "./unittests/transform.ts"; +import "./unittests/typeParameterIsPossiblyReferenced.ts"; +import "./unittests/config/commandLineParsing.ts"; +import "./unittests/config/configurationExtension.ts"; +import "./unittests/config/convertCompilerOptionsFromJson.ts"; +import "./unittests/config/convertTypeAcquisitionFromJson.ts"; +import "./unittests/config/initializeTSConfig.ts"; +import "./unittests/config/matchFiles.ts"; +import "./unittests/config/projectReferences.ts"; +import "./unittests/config/showConfig.ts"; +import "./unittests/config/tsconfigParsing.ts"; +import "./unittests/config/tsconfigParsingWatchOptions.ts"; +import "./unittests/evaluation/arraySpread.ts"; +import "./unittests/evaluation/asyncArrow.ts"; +import "./unittests/evaluation/asyncGenerator.ts"; +import "./unittests/evaluation/autoAccessors.ts"; +import "./unittests/evaluation/awaiter.ts"; +import "./unittests/evaluation/destructuring.ts"; +import "./unittests/evaluation/externalModules.ts"; +import "./unittests/evaluation/forAwaitOf.ts"; +import "./unittests/evaluation/forOf.ts"; +import "./unittests/evaluation/generator.ts"; +import "./unittests/evaluation/optionalCall.ts"; +import "./unittests/evaluation/objectRest.ts"; +import "./unittests/evaluation/superInStaticInitializer.ts"; +import "./unittests/evaluation/templateLiteral.ts"; +import "./unittests/evaluation/updateExpressionInModule.ts"; +import "./unittests/services/cancellableLanguageServiceOperations.ts"; +import "./unittests/services/colorization.ts"; +import "./unittests/services/convertToAsyncFunction.ts"; +import "./unittests/services/documentRegistry.ts"; +import "./unittests/services/extract/constants.ts"; +import "./unittests/services/extract/functions.ts"; +import "./unittests/services/extract/symbolWalker.ts"; +import "./unittests/services/extract/ranges.ts"; +import "./unittests/services/hostNewLineSupport.ts"; +import "./unittests/services/languageService.ts"; +import "./unittests/services/organizeImports.ts"; +import "./unittests/services/patternMatcher.ts"; +import "./unittests/services/preProcessFile.ts"; +import "./unittests/services/textChanges.ts"; +import "./unittests/services/transpile.ts"; +import "./unittests/tsbuild/amdModulesWithOut.ts"; +import "./unittests/tsbuild/clean.ts"; +import "./unittests/tsbuild/configFileErrors.ts"; +import "./unittests/tsbuild/configFileExtends.ts"; +import "./unittests/tsbuild/containerOnlyReferenced.ts"; +import "./unittests/tsbuild/declarationEmit.ts"; +import "./unittests/tsbuild/demo.ts"; +import "./unittests/tsbuild/emitDeclarationOnly.ts"; +import "./unittests/tsbuild/emptyFiles.ts"; +import "./unittests/tsbuild/exitCodeOnBogusFile.ts"; +import "./unittests/tsbuild/graphOrdering.ts"; +import "./unittests/tsbuild/inferredTypeFromTransitiveModule.ts"; +import "./unittests/tsbuild/javascriptProjectEmit.ts"; +import "./unittests/tsbuild/lateBoundSymbol.ts"; +import "./unittests/tsbuild/moduleResolution.ts"; +import "./unittests/tsbuild/moduleSpecifiers.ts"; +import "./unittests/tsbuild/noEmit.ts"; +import "./unittests/tsbuild/noEmitOnError.ts"; +import "./unittests/tsbuild/outFile.ts"; +import "./unittests/tsbuild/outputPaths.ts"; +import "./unittests/tsbuild/publicApi.ts"; +import "./unittests/tsbuild/referencesWithRootDirInParent.ts"; +import "./unittests/tsbuild/resolveJsonModule.ts"; +import "./unittests/tsbuild/sample.ts"; +import "./unittests/tsbuild/transitiveReferences.ts"; +import "./unittests/tsbuildWatch/configFileErrors.ts"; +import "./unittests/tsbuildWatch/demo.ts"; +import "./unittests/tsbuildWatch/moduleResolution.ts"; +import "./unittests/tsbuildWatch/noEmit.ts"; +import "./unittests/tsbuildWatch/noEmitOnError.ts"; +import "./unittests/tsbuildWatch/programUpdates.ts"; +import "./unittests/tsbuildWatch/projectsBuilding.ts"; +import "./unittests/tsbuildWatch/publicApi.ts"; +import "./unittests/tsbuildWatch/reexport.ts"; +import "./unittests/tsbuildWatch/watchEnvironment.ts"; +import "./unittests/tsc/cancellationToken.ts"; +import "./unittests/tsc/composite.ts"; +import "./unittests/tsc/declarationEmit.ts"; +import "./unittests/tsc/forceConsistentCasingInFileNames.ts"; +import "./unittests/tsc/incremental.ts"; +import "./unittests/tsc/listFilesOnly.ts"; +import "./unittests/tsc/projectReferences.ts"; +import "./unittests/tsc/redirect.ts"; +import "./unittests/tsc/runWithoutArgs.ts"; +import "./unittests/tscWatch/consoleClearing.ts"; +import "./unittests/tscWatch/emit.ts"; +import "./unittests/tscWatch/nodeNextWatch.ts"; +import "./unittests/tscWatch/emitAndErrorUpdates.ts"; +import "./unittests/tscWatch/forceConsistentCasingInFileNames.ts"; +import "./unittests/tscWatch/incremental.ts"; +import "./unittests/tscWatch/moduleResolution.ts"; +import "./unittests/tscWatch/programUpdates.ts"; +import "./unittests/tscWatch/projectsWithReferences.ts"; +import "./unittests/tscWatch/resolutionCache.ts"; +import "./unittests/tscWatch/sourceOfProjectReferenceRedirect.ts"; +import "./unittests/tscWatch/watchApi.ts"; +import "./unittests/tscWatch/watchEnvironment.ts"; +import "./unittests/tsserver/applyChangesToOpenFiles.ts"; +import "./unittests/tsserver/autoImportProvider.ts"; +import "./unittests/tsserver/auxiliaryProject.ts"; +import "./unittests/tsserver/cachingFileSystemInformation.ts"; +import "./unittests/tsserver/cancellationToken.ts"; +import "./unittests/tsserver/compileOnSave.ts"; +import "./unittests/tsserver/completions.ts"; +import "./unittests/tsserver/completionsIncomplete.ts"; +import "./unittests/tsserver/configFileSearch.ts"; +import "./unittests/tsserver/configuredProjects.ts"; +import "./unittests/tsserver/declarationFileMaps.ts"; +import "./unittests/tsserver/documentRegistry.ts"; +import "./unittests/tsserver/duplicatePackages.ts"; +import "./unittests/tsserver/dynamicFiles.ts"; +import "./unittests/tsserver/events/largeFileReferenced.ts"; +import "./unittests/tsserver/events/projectLanguageServiceState.ts"; +import "./unittests/tsserver/events/projectLoading.ts"; +import "./unittests/tsserver/events/projectUpdatedInBackground.ts"; +import "./unittests/tsserver/exportMapCache.ts"; +import "./unittests/tsserver/externalProjects.ts"; +import "./unittests/tsserver/forceConsistentCasingInFileNames.ts"; +import "./unittests/tsserver/formatSettings.ts"; +import "./unittests/tsserver/getApplicableRefactors.ts"; +import "./unittests/tsserver/getEditsForFileRename.ts"; +import "./unittests/tsserver/getExportReferences.ts"; +import "./unittests/tsserver/getFileReferences.ts"; +import "./unittests/tsserver/importHelpers.ts"; +import "./unittests/tsserver/inlayHints.ts"; +import "./unittests/tsserver/inferredProjects.ts"; +import "./unittests/tsserver/jsdocTag.ts"; +import "./unittests/tsserver/languageService.ts"; +import "./unittests/tsserver/maxNodeModuleJsDepth.ts"; +import "./unittests/tsserver/metadataInResponse.ts"; +import "./unittests/tsserver/moduleResolution.ts"; +import "./unittests/tsserver/moduleSpecifierCache.ts"; +import "./unittests/tsserver/navTo.ts"; +import "./unittests/tsserver/occurences.ts"; +import "./unittests/tsserver/openFile.ts"; +import "./unittests/tsserver/packageJsonInfo.ts"; +import "./unittests/tsserver/partialSemanticServer.ts"; +import "./unittests/tsserver/plugins.ts"; +import "./unittests/tsserver/projectErrors.ts"; +import "./unittests/tsserver/projectReferenceCompileOnSave.ts"; +import "./unittests/tsserver/projectReferenceErrors.ts"; +import "./unittests/tsserver/projectReferences.ts"; +import "./unittests/tsserver/projectReferencesSourcemap.ts"; +import "./unittests/tsserver/projects.ts"; +import "./unittests/tsserver/projectsWithReferences.ts"; +import "./unittests/tsserver/refactors.ts"; +import "./unittests/tsserver/reload.ts"; +import "./unittests/tsserver/reloadProjects.ts"; +import "./unittests/tsserver/rename.ts"; +import "./unittests/tsserver/resolutionCache.ts"; +import "./unittests/tsserver/session.ts"; +import "./unittests/tsserver/skipLibCheck.ts"; +import "./unittests/tsserver/smartSelection.ts"; +import "./unittests/tsserver/symlinkCache.ts"; +import "./unittests/tsserver/symLinks.ts"; +import "./unittests/tsserver/syntacticServer.ts"; +import "./unittests/tsserver/syntaxOperations.ts"; +import "./unittests/tsserver/textStorage.ts"; +import "./unittests/tsserver/telemetry.ts"; +import "./unittests/tsserver/typeAquisition.ts"; +import "./unittests/tsserver/typeOnlyImportChains.ts"; +import "./unittests/tsserver/typeReferenceDirectives.ts"; +import "./unittests/tsserver/typingsInstaller.ts"; +import "./unittests/tsserver/versionCache.ts"; +import "./unittests/tsserver/watchEnvironment.ts"; +import "./unittests/tsserver/webServer.ts"; +import "./unittests/debugDeprecation.ts"; diff --git a/src/testRunner/tsconfig.json b/src/testRunner/tsconfig.json index 72ffc01b7560b..be32183573d0b 100644 --- a/src/testRunner/tsconfig.json +++ b/src/testRunner/tsconfig.json @@ -1,10 +1,7 @@ { - "extends": "../tsconfig-noncomposite-base", + "extends": "../tsconfig-base", "compilerOptions": { - "outDir": "../../built/local", - "composite": false, - "declaration": false, - "declarationMap": false, + "outDir": "../../built/local/testRunner", "types": [ "node", "mocha", "chai" ], @@ -25,244 +22,5 @@ { "path": "../harness" }, { "path": "../loggedIO" } ], - - "files": [ - "compilerRef.ts", - "evaluatorRef.ts", - "fakesRef.ts", - "vpathRef.ts", - "vfsRef.ts", - "fourslashRef.ts", - "playbackRef.ts", - "utilsRef.ts", - "documentsRef.ts", - - "fourslashRunner.ts", - "compilerRunner.ts", - "projectsRunner.ts", - "rwcRunner.ts", - "externalCompileRunner.ts", - "test262Runner.ts", - - "parallel/host.ts", - "parallel/worker.ts", - "parallel/shared.ts", - - "runner.ts", - - "unittests/services/extract/helpers.ts", - "unittests/tsbuild/helpers.ts", - "unittests/tsc/helpers.ts", - "unittests/tscWatch/helpers.ts", - "unittests/tsserver/helpers.ts", - - "unittests/asserts.ts", - "unittests/base64.ts", - "unittests/builder.ts", - "unittests/comments.ts", - "unittests/compilerCore.ts", - "unittests/convertToBase64.ts", - "unittests/customTransforms.ts", - "unittests/factory.ts", - "unittests/incrementalParser.ts", - "unittests/jsDocParsing.ts", - "unittests/jsonParserRecovery.ts", - "unittests/moduleResolution.ts", - "unittests/parsePseudoBigInt.ts", - "unittests/paths.ts", - "unittests/printer.ts", - "unittests/programApi.ts", - "unittests/publicApi.ts", - "unittests/reuseProgramStructure.ts", - "unittests/semver.ts", - "unittests/transform.ts", - "unittests/typeParameterIsPossiblyReferenced.ts", - "unittests/config/commandLineParsing.ts", - "unittests/config/configurationExtension.ts", - "unittests/config/convertCompilerOptionsFromJson.ts", - "unittests/config/convertTypeAcquisitionFromJson.ts", - "unittests/config/initializeTSConfig.ts", - "unittests/config/matchFiles.ts", - "unittests/config/projectReferences.ts", - "unittests/config/showConfig.ts", - "unittests/config/tsconfigParsing.ts", - "unittests/config/tsconfigParsingWatchOptions.ts", - "unittests/evaluation/arraySpread.ts", - "unittests/evaluation/asyncArrow.ts", - "unittests/evaluation/asyncGenerator.ts", - "unittests/evaluation/autoAccessors.ts", - "unittests/evaluation/awaiter.ts", - "unittests/evaluation/destructuring.ts", - "unittests/evaluation/externalModules.ts", - "unittests/evaluation/forAwaitOf.ts", - "unittests/evaluation/forOf.ts", - "unittests/evaluation/generator.ts", - "unittests/evaluation/optionalCall.ts", - "unittests/evaluation/objectRest.ts", - "unittests/evaluation/superInStaticInitializer.ts", - "unittests/evaluation/templateLiteral.ts", - "unittests/evaluation/updateExpressionInModule.ts", - "unittests/services/cancellableLanguageServiceOperations.ts", - "unittests/services/colorization.ts", - "unittests/services/convertToAsyncFunction.ts", - "unittests/services/documentRegistry.ts", - "unittests/services/extract/constants.ts", - "unittests/services/extract/functions.ts", - "unittests/services/extract/symbolWalker.ts", - "unittests/services/extract/ranges.ts", - "unittests/services/hostNewLineSupport.ts", - "unittests/services/languageService.ts", - "unittests/services/organizeImports.ts", - "unittests/services/patternMatcher.ts", - "unittests/services/preProcessFile.ts", - "unittests/services/textChanges.ts", - "unittests/services/transpile.ts", - "unittests/tsbuild/amdModulesWithOut.ts", - "unittests/tsbuild/clean.ts", - "unittests/tsbuild/configFileErrors.ts", - "unittests/tsbuild/configFileExtends.ts", - "unittests/tsbuild/containerOnlyReferenced.ts", - "unittests/tsbuild/declarationEmit.ts", - "unittests/tsbuild/demo.ts", - "unittests/tsbuild/emitDeclarationOnly.ts", - "unittests/tsbuild/emptyFiles.ts", - "unittests/tsbuild/exitCodeOnBogusFile.ts", - "unittests/tsbuild/graphOrdering.ts", - "unittests/tsbuild/inferredTypeFromTransitiveModule.ts", - "unittests/tsbuild/javascriptProjectEmit.ts", - "unittests/tsbuild/lateBoundSymbol.ts", - "unittests/tsbuild/moduleResolution.ts", - "unittests/tsbuild/moduleSpecifiers.ts", - "unittests/tsbuild/noEmit.ts", - "unittests/tsbuild/noEmitOnError.ts", - "unittests/tsbuild/outFile.ts", - "unittests/tsbuild/outputPaths.ts", - "unittests/tsbuild/publicApi.ts", - "unittests/tsbuild/referencesWithRootDirInParent.ts", - "unittests/tsbuild/resolveJsonModule.ts", - "unittests/tsbuild/sample.ts", - "unittests/tsbuild/transitiveReferences.ts", - "unittests/tsbuildWatch/configFileErrors.ts", - "unittests/tsbuildWatch/demo.ts", - "unittests/tsbuildWatch/moduleResolution.ts", - "unittests/tsbuildWatch/noEmit.ts", - "unittests/tsbuildWatch/noEmitOnError.ts", - "unittests/tsbuildWatch/programUpdates.ts", - "unittests/tsbuildWatch/projectsBuilding.ts", - "unittests/tsbuildWatch/publicApi.ts", - "unittests/tsbuildWatch/reexport.ts", - "unittests/tsbuildWatch/watchEnvironment.ts", - "unittests/tsc/cancellationToken.ts", - "unittests/tsc/composite.ts", - "unittests/tsc/declarationEmit.ts", - "unittests/tsc/forceConsistentCasingInFileNames.ts", - "unittests/tsc/incremental.ts", - "unittests/tsc/listFilesOnly.ts", - "unittests/tsc/projectReferences.ts", - "unittests/tsc/redirect.ts", - "unittests/tsc/runWithoutArgs.ts", - "unittests/tscWatch/consoleClearing.ts", - "unittests/tscWatch/emit.ts", - "unittests/tscWatch/nodeNextWatch.ts", - "unittests/tscWatch/emitAndErrorUpdates.ts", - "unittests/tscWatch/forceConsistentCasingInFileNames.ts", - "unittests/tscWatch/incremental.ts", - "unittests/tscWatch/moduleResolution.ts", - "unittests/tscWatch/programUpdates.ts", - "unittests/tscWatch/projectsWithReferences.ts", - "unittests/tscWatch/resolutionCache.ts", - "unittests/tscWatch/sourceOfProjectReferenceRedirect.ts", - "unittests/tscWatch/watchApi.ts", - "unittests/tscWatch/watchEnvironment.ts", - "unittests/tsserver/applyChangesToOpenFiles.ts", - "unittests/tsserver/autoImportProvider.ts", - "unittests/tsserver/auxiliaryProject.ts", - "unittests/tsserver/cachingFileSystemInformation.ts", - "unittests/tsserver/cancellationToken.ts", - "unittests/tsserver/compileOnSave.ts", - "unittests/tsserver/completions.ts", - "unittests/tsserver/completionsIncomplete.ts", - "unittests/tsserver/configFileSearch.ts", - "unittests/tsserver/configuredProjects.ts", - "unittests/tsserver/declarationFileMaps.ts", - "unittests/tsserver/documentRegistry.ts", - "unittests/tsserver/duplicatePackages.ts", - "unittests/tsserver/dynamicFiles.ts", - "unittests/tsserver/events/largeFileReferenced.ts", - "unittests/tsserver/events/projectLanguageServiceState.ts", - "unittests/tsserver/events/projectLoading.ts", - "unittests/tsserver/events/projectUpdatedInBackground.ts", - "unittests/tsserver/exportMapCache.ts", - "unittests/tsserver/externalProjects.ts", - "unittests/tsserver/forceConsistentCasingInFileNames.ts", - "unittests/tsserver/formatSettings.ts", - "unittests/tsserver/getApplicableRefactors.ts", - "unittests/tsserver/getEditsForFileRename.ts", - "unittests/tsserver/getExportReferences.ts", - "unittests/tsserver/getFileReferences.ts", - "unittests/tsserver/importHelpers.ts", - "unittests/tsserver/inlayHints.ts", - "unittests/tsserver/inferredProjects.ts", - "unittests/tsserver/jsdocTag.ts", - "unittests/tsserver/languageService.ts", - "unittests/tsserver/maxNodeModuleJsDepth.ts", - "unittests/tsserver/metadataInResponse.ts", - "unittests/tsserver/moduleResolution.ts", - "unittests/tsserver/moduleSpecifierCache.ts", - "unittests/tsserver/navTo.ts", - "unittests/tsserver/occurences.ts", - "unittests/tsserver/openFile.ts", - "unittests/tsserver/packageJsonInfo.ts", - "unittests/tsserver/partialSemanticServer.ts", - "unittests/tsserver/plugins.ts", - "unittests/tsserver/projectErrors.ts", - "unittests/tsserver/projectReferenceCompileOnSave.ts", - "unittests/tsserver/projectReferenceErrors.ts", - "unittests/tsserver/projectReferences.ts", - "unittests/tsserver/projectReferencesSourcemap.ts", - "unittests/tsserver/projects.ts", - "unittests/tsserver/projectsWithReferences.ts", - "unittests/tsserver/refactors.ts", - "unittests/tsserver/reload.ts", - "unittests/tsserver/reloadProjects.ts", - "unittests/tsserver/rename.ts", - "unittests/tsserver/resolutionCache.ts", - "unittests/tsserver/session.ts", - "unittests/tsserver/skipLibCheck.ts", - "unittests/tsserver/smartSelection.ts", - "unittests/tsserver/symlinkCache.ts", - "unittests/tsserver/symLinks.ts", - "unittests/tsserver/syntacticServer.ts", - "unittests/tsserver/syntaxOperations.ts", - "unittests/tsserver/textStorage.ts", - "unittests/tsserver/telemetry.ts", - "unittests/tsserver/typeAquisition.ts", - "unittests/tsserver/typeOnlyImportChains.ts", - "unittests/tsserver/typeReferenceDirectives.ts", - "unittests/tsserver/typingsInstaller.ts", - "unittests/tsserver/versionCache.ts", - "unittests/tsserver/watchEnvironment.ts", - "unittests/tsserver/webServer.ts", - "unittests/debugDeprecation.ts", - "_namespaces/compiler.ts", - "_namespaces/Harness.ts", - "_namespaces/documents.ts", - "_namespaces/evaluator.ts", - "_namespaces/fakes.ts", - "_namespaces/FourSlash.ts", - "_namespaces/Playback.ts", - "_namespaces/project.ts", - "_namespaces/RWC.ts", - "_namespaces/Utils.ts", - "_namespaces/vfs.ts", - "_namespaces/vpath.ts", - "_namespaces/Harness.Parallel.Host.ts", - "_namespaces/Harness.Parallel.ts", - "_namespaces/Harness.Parallel.Worker.ts", - "_namespaces/ts.ts", - "_namespaces/ts.tscWatch.ts", - "_namespaces/ts.projectSystem.ts", - "_namespaces/ts.server.ts", - "_namespaces/ts.textStorage.ts" - ] + "include": ["**/*"] } diff --git a/src/testRunner/unittests/helpers.ts b/src/testRunner/unittests/helpers.ts new file mode 100644 index 0000000000000..7706b16ab1a57 --- /dev/null +++ b/src/testRunner/unittests/helpers.ts @@ -0,0 +1,241 @@ +import * as ts from "../_namespaces/ts"; + +const enum ChangedPart { + references = 1 << 0, + importsAndExports = 1 << 1, + program = 1 << 2 +} + +export const newLine = "\r\n"; + +export interface SourceFileWithText extends ts.SourceFile { + sourceText?: SourceText; +} + +export interface NamedSourceText { + name: string; + text: SourceText; +} + +export interface ProgramWithSourceTexts extends ts.Program { + sourceTexts?: readonly NamedSourceText[]; + host: TestCompilerHost; +} + +export interface TestCompilerHost extends ts.CompilerHost { + getTrace(): string[]; +} + +export class SourceText implements ts.IScriptSnapshot { + private fullText: string | undefined; + + constructor(private references: string, + private importsAndExports: string, + private program: string, + private changedPart: ChangedPart = 0, + private version = 0) { + } + + static New(references: string, importsAndExports: string, program: string): SourceText { + ts.Debug.assert(references !== undefined); + ts.Debug.assert(importsAndExports !== undefined); + ts.Debug.assert(program !== undefined); + return new SourceText(references + newLine, importsAndExports + newLine, program || ""); + } + + public getVersion(): number { + return this.version; + } + + public updateReferences(newReferences: string): SourceText { + ts.Debug.assert(newReferences !== undefined); + return new SourceText(newReferences + newLine, this.importsAndExports, this.program, this.changedPart | ChangedPart.references, this.version + 1); + } + public updateImportsAndExports(newImportsAndExports: string): SourceText { + ts.Debug.assert(newImportsAndExports !== undefined); + return new SourceText(this.references, newImportsAndExports + newLine, this.program, this.changedPart | ChangedPart.importsAndExports, this.version + 1); + } + public updateProgram(newProgram: string): SourceText { + ts.Debug.assert(newProgram !== undefined); + return new SourceText(this.references, this.importsAndExports, newProgram, this.changedPart | ChangedPart.program, this.version + 1); + } + + public getFullText() { + return this.fullText || (this.fullText = this.references + this.importsAndExports + this.program); + } + + public getText(start: number, end: number): string { + return this.getFullText().substring(start, end); + } + + getLength(): number { + return this.getFullText().length; + } + + getChangeRange(oldSnapshot: ts.IScriptSnapshot): ts.TextChangeRange { + const oldText = oldSnapshot as SourceText; + let oldSpan: ts.TextSpan; + let newLength: number; + switch (oldText.changedPart ^ this.changedPart) { + case ChangedPart.references: + oldSpan = ts.createTextSpan(0, oldText.references.length); + newLength = this.references.length; + break; + case ChangedPart.importsAndExports: + oldSpan = ts.createTextSpan(oldText.references.length, oldText.importsAndExports.length); + newLength = this.importsAndExports.length; + break; + case ChangedPart.program: + oldSpan = ts.createTextSpan(oldText.references.length + oldText.importsAndExports.length, oldText.program.length); + newLength = this.program.length; + break; + default: + return ts.Debug.fail("Unexpected change"); + } + + return ts.createTextChangeRange(oldSpan, newLength); + } +} + +function createSourceFileWithText(fileName: string, sourceText: SourceText, target: ts.ScriptTarget) { + const file = ts.createSourceFile(fileName, sourceText.getFullText(), target) as SourceFileWithText; + file.sourceText = sourceText; + file.version = "" + sourceText.getVersion(); + return file; +} + +export function createTestCompilerHost(texts: readonly NamedSourceText[], target: ts.ScriptTarget, oldProgram?: ProgramWithSourceTexts, useGetSourceFileByPath?: boolean) { + const files = ts.arrayToMap(texts, t => t.name, t => { + if (oldProgram) { + let oldFile = oldProgram.getSourceFile(t.name) as SourceFileWithText; + if (oldFile && oldFile.redirectInfo) { + oldFile = oldFile.redirectInfo.unredirected; + } + if (oldFile && oldFile.sourceText!.getVersion() === t.text.getVersion()) { + return oldFile; + } + } + return createSourceFileWithText(t.name, t.text, target); + }); + const useCaseSensitiveFileNames = ts.sys && ts.sys.useCaseSensitiveFileNames; + const getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); + const trace: string[] = []; + const result: TestCompilerHost = { + trace: s => trace.push(s), + getTrace: () => trace, + getSourceFile: fileName => files.get(fileName), + getDefaultLibFileName: () => "lib.d.ts", + writeFile: ts.notImplemented, + getCurrentDirectory: () => "", + getDirectories: () => [], + getCanonicalFileName, + useCaseSensitiveFileNames: () => useCaseSensitiveFileNames, + getNewLine: () => ts.sys ? ts.sys.newLine : newLine, + fileExists: fileName => files.has(fileName), + readFile: fileName => { + const file = files.get(fileName); + return file && file.text; + }, + }; + if (useGetSourceFileByPath) { + const filesByPath = ts.mapEntries(files, (fileName, file) => [ts.toPath(fileName, "", getCanonicalFileName), file]); + result.getSourceFileByPath = (_fileName, path) => filesByPath.get(path); + } + return result; +} + +export function newProgram(texts: NamedSourceText[], rootNames: string[], options: ts.CompilerOptions, useGetSourceFileByPath?: boolean): ProgramWithSourceTexts { + const host = createTestCompilerHost(texts, options.target!, /*oldProgram*/ undefined, useGetSourceFileByPath); + const program = ts.createProgram(rootNames, options, host) as ProgramWithSourceTexts; + program.sourceTexts = texts; + program.host = host; + return program; +} + +export function updateProgram(oldProgram: ProgramWithSourceTexts, rootNames: readonly string[], options: ts.CompilerOptions, updater: (files: NamedSourceText[]) => void, newTexts?: NamedSourceText[], useGetSourceFileByPath?: boolean) { + if (!newTexts) { + newTexts = oldProgram.sourceTexts!.slice(0); + } + updater(newTexts); + const host = createTestCompilerHost(newTexts, options.target!, oldProgram, useGetSourceFileByPath); + const program = ts.createProgram(rootNames, options, host, oldProgram) as ProgramWithSourceTexts; + program.sourceTexts = newTexts; + program.host = host; + return program; +} + +export function updateProgramText(files: readonly NamedSourceText[], fileName: string, newProgramText: string) { + const file = ts.find(files, f => f.name === fileName)!; + file.text = file.text.updateProgram(newProgramText); +} + +export function checkResolvedTypeDirective(actual: ts.ResolvedTypeReferenceDirective, expected: ts.ResolvedTypeReferenceDirective) { + assert.equal(actual.resolvedFileName, expected.resolvedFileName, `'resolvedFileName': expected '${actual.resolvedFileName}' to be equal to '${expected.resolvedFileName}'`); + assert.equal(actual.primary, expected.primary, `'primary': expected '${actual.primary}' to be equal to '${expected.primary}'`); + return true; +} + +function checkCache(caption: string, program: ts.Program, fileName: string, expectedContent: ts.ESMap | undefined, getCache: (f: ts.SourceFile) => ts.ModeAwareCache | undefined, entryChecker: (expected: T, original: T) => boolean): void { + const file = program.getSourceFile(fileName); + assert.isTrue(file !== undefined, `cannot find file ${fileName}`); + const cache = getCache(file!); + if (expectedContent === undefined) { + assert.isTrue(cache === undefined, `expected ${caption} to be undefined`); + } + else { + assert.isTrue(cache !== undefined, `expected ${caption} to be set`); + assert.isTrue(mapEqualToCache(expectedContent, cache!, entryChecker), `contents of ${caption} did not match the expected contents.`); + } +} + +/** True if the maps have the same keys and values. */ +function mapEqualToCache(left: ts.ESMap, right: ts.ModeAwareCache, valuesAreEqual?: (left: T, right: T) => boolean): boolean { + if (left as any === right) return true; // given the type mismatch (the tests never pass a cache), this'll never be true + if (!left || !right) return false; + const someInLeftHasNoMatch = ts.forEachEntry(left, (leftValue, leftKey) => { + if (!right.has(leftKey, /*mode*/ undefined)) return true; + const rightValue = right.get(leftKey, /*mode*/ undefined)!; + return !(valuesAreEqual ? valuesAreEqual(leftValue, rightValue) : leftValue === rightValue); + }); + if (someInLeftHasNoMatch) return false; + let someInRightHasNoMatch = false; + right.forEach((_, rightKey) => someInRightHasNoMatch = someInRightHasNoMatch || !left.has(rightKey)); + return !someInRightHasNoMatch; +} + +export function checkResolvedModulesCache(program: ts.Program, fileName: string, expectedContent: ts.ESMap | undefined): void { + checkCache("resolved modules", program, fileName, expectedContent, f => f.resolvedModules, ts.checkResolvedModule); +} + +export function checkResolvedTypeDirectivesCache(program: ts.Program, fileName: string, expectedContent: ts.ESMap | undefined): void { + checkCache("resolved type directives", program, fileName, expectedContent, f => f.resolvedTypeReferenceDirectiveNames, checkResolvedTypeDirective); +} + +export function createResolvedModule(resolvedFileName: string, isExternalLibraryImport = false): ts.ResolvedModuleFull { + return { resolvedFileName, extension: ts.extensionFromPath(resolvedFileName), isExternalLibraryImport }; +} + +export function checkResolvedModule(actual: ts.ResolvedModuleFull | undefined, expected: ts.ResolvedModuleFull | undefined): boolean { + if (!expected) { + if (actual) { + assert.fail(actual, expected, "expected resolved module to be undefined"); + return false; + } + return true; + } + else if (!actual) { + assert.fail(actual, expected, "expected resolved module to be defined"); + return false; + } + + assert.isTrue(actual.resolvedFileName === expected.resolvedFileName, `'resolvedFileName': expected '${actual.resolvedFileName}' to be equal to '${expected.resolvedFileName}'`); + assert.isTrue(actual.extension === expected.extension, `'ext': expected '${actual.extension}' to be equal to '${expected.extension}'`); + assert.isTrue(actual.isExternalLibraryImport === expected.isExternalLibraryImport, `'isExternalLibraryImport': expected '${actual.isExternalLibraryImport}' to be equal to '${expected.isExternalLibraryImport}'`); + return true; +} + +export function checkResolvedModuleWithFailedLookupLocations(actual: ts.ResolvedModuleWithFailedLookupLocations, expectedResolvedModule: ts.ResolvedModuleFull, expectedFailedLookupLocations: string[]): void { + assert.isTrue(actual.resolvedModule !== undefined, "module should be resolved"); + checkResolvedModule(actual.resolvedModule, expectedResolvedModule); + assert.deepEqual(actual.failedLookupLocations, expectedFailedLookupLocations, `Failed lookup locations should match - expected has ${expectedFailedLookupLocations.length}, actual has ${actual.failedLookupLocations.length}`); +} diff --git a/src/testRunner/unittests/moduleResolution.ts b/src/testRunner/unittests/moduleResolution.ts index 90c49fbb881f8..7f2c76fedd37c 100644 --- a/src/testRunner/unittests/moduleResolution.ts +++ b/src/testRunner/unittests/moduleResolution.ts @@ -1,34 +1,6 @@ import * as ts from "../_namespaces/ts"; import * as Harness from "../_namespaces/Harness"; - -export function checkResolvedModule(actual: ts.ResolvedModuleFull | undefined, expected: ts.ResolvedModuleFull | undefined): boolean { - if (!expected) { - if (actual) { - assert.fail(actual, expected, "expected resolved module to be undefined"); - return false; - } - return true; - } - else if (!actual) { - assert.fail(actual, expected, "expected resolved module to be defined"); - return false; - } - - assert.isTrue(actual.resolvedFileName === expected.resolvedFileName, `'resolvedFileName': expected '${actual.resolvedFileName}' to be equal to '${expected.resolvedFileName}'`); - assert.isTrue(actual.extension === expected.extension, `'ext': expected '${actual.extension}' to be equal to '${expected.extension}'`); - assert.isTrue(actual.isExternalLibraryImport === expected.isExternalLibraryImport, `'isExternalLibraryImport': expected '${actual.isExternalLibraryImport}' to be equal to '${expected.isExternalLibraryImport}'`); - return true; -} - -export function checkResolvedModuleWithFailedLookupLocations(actual: ts.ResolvedModuleWithFailedLookupLocations, expectedResolvedModule: ts.ResolvedModuleFull, expectedFailedLookupLocations: string[]): void { - assert.isTrue(actual.resolvedModule !== undefined, "module should be resolved"); - checkResolvedModule(actual.resolvedModule, expectedResolvedModule); - assert.deepEqual(actual.failedLookupLocations, expectedFailedLookupLocations, `Failed lookup locations should match - expected has ${expectedFailedLookupLocations.length}, actual has ${actual.failedLookupLocations.length}`); -} - -export function createResolvedModule(resolvedFileName: string, isExternalLibraryImport = false): ts.ResolvedModuleFull { - return { resolvedFileName, extension: ts.extensionFromPath(resolvedFileName), isExternalLibraryImport }; -} +import { checkResolvedModule, checkResolvedModuleWithFailedLookupLocations, createResolvedModule } from "./helpers"; interface File { name: string; diff --git a/src/testRunner/unittests/reuseProgramStructure.ts b/src/testRunner/unittests/reuseProgramStructure.ts index fbbcaf7595134..28fd3300f5502 100644 --- a/src/testRunner/unittests/reuseProgramStructure.ts +++ b/src/testRunner/unittests/reuseProgramStructure.ts @@ -1,215 +1,6 @@ import * as ts from "../_namespaces/ts"; -const enum ChangedPart { - references = 1 << 0, - importsAndExports = 1 << 1, - program = 1 << 2 -} - -const newLine = "\r\n"; - -interface SourceFileWithText extends ts.SourceFile { - sourceText?: SourceText; -} - -export interface NamedSourceText { - name: string; - text: SourceText; -} - -export interface ProgramWithSourceTexts extends ts.Program { - sourceTexts?: readonly NamedSourceText[]; - host: TestCompilerHost; -} - -interface TestCompilerHost extends ts.CompilerHost { - getTrace(): string[]; -} - -export class SourceText implements ts.IScriptSnapshot { - private fullText: string | undefined; - - constructor(private references: string, - private importsAndExports: string, - private program: string, - private changedPart: ChangedPart = 0, - private version = 0) { - } - - static New(references: string, importsAndExports: string, program: string): SourceText { - ts.Debug.assert(references !== undefined); - ts.Debug.assert(importsAndExports !== undefined); - ts.Debug.assert(program !== undefined); - return new SourceText(references + newLine, importsAndExports + newLine, program || ""); - } - - public getVersion(): number { - return this.version; - } - - public updateReferences(newReferences: string): SourceText { - ts.Debug.assert(newReferences !== undefined); - return new SourceText(newReferences + newLine, this.importsAndExports, this.program, this.changedPart | ChangedPart.references, this.version + 1); - } - public updateImportsAndExports(newImportsAndExports: string): SourceText { - ts.Debug.assert(newImportsAndExports !== undefined); - return new SourceText(this.references, newImportsAndExports + newLine, this.program, this.changedPart | ChangedPart.importsAndExports, this.version + 1); - } - public updateProgram(newProgram: string): SourceText { - ts.Debug.assert(newProgram !== undefined); - return new SourceText(this.references, this.importsAndExports, newProgram, this.changedPart | ChangedPart.program, this.version + 1); - } - - public getFullText() { - return this.fullText || (this.fullText = this.references + this.importsAndExports + this.program); - } - - public getText(start: number, end: number): string { - return this.getFullText().substring(start, end); - } - - getLength(): number { - return this.getFullText().length; - } - - getChangeRange(oldSnapshot: ts.IScriptSnapshot): ts.TextChangeRange { - const oldText = oldSnapshot as SourceText; - let oldSpan: ts.TextSpan; - let newLength: number; - switch (oldText.changedPart ^ this.changedPart) { - case ChangedPart.references: - oldSpan = ts.createTextSpan(0, oldText.references.length); - newLength = this.references.length; - break; - case ChangedPart.importsAndExports: - oldSpan = ts.createTextSpan(oldText.references.length, oldText.importsAndExports.length); - newLength = this.importsAndExports.length; - break; - case ChangedPart.program: - oldSpan = ts.createTextSpan(oldText.references.length + oldText.importsAndExports.length, oldText.program.length); - newLength = this.program.length; - break; - default: - return ts.Debug.fail("Unexpected change"); - } - - return ts.createTextChangeRange(oldSpan, newLength); - } -} - -function createSourceFileWithText(fileName: string, sourceText: SourceText, target: ts.ScriptTarget) { - const file = ts.createSourceFile(fileName, sourceText.getFullText(), target) as SourceFileWithText; - file.sourceText = sourceText; - file.version = "" + sourceText.getVersion(); - return file; -} - -export function createTestCompilerHost(texts: readonly NamedSourceText[], target: ts.ScriptTarget, oldProgram?: ProgramWithSourceTexts, useGetSourceFileByPath?: boolean) { - const files = ts.arrayToMap(texts, t => t.name, t => { - if (oldProgram) { - let oldFile = oldProgram.getSourceFile(t.name) as SourceFileWithText; - if (oldFile && oldFile.redirectInfo) { - oldFile = oldFile.redirectInfo.unredirected; - } - if (oldFile && oldFile.sourceText!.getVersion() === t.text.getVersion()) { - return oldFile; - } - } - return createSourceFileWithText(t.name, t.text, target); - }); - const useCaseSensitiveFileNames = ts.sys && ts.sys.useCaseSensitiveFileNames; - const getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); - const trace: string[] = []; - const result: TestCompilerHost = { - trace: s => trace.push(s), - getTrace: () => trace, - getSourceFile: fileName => files.get(fileName), - getDefaultLibFileName: () => "lib.d.ts", - writeFile: ts.notImplemented, - getCurrentDirectory: () => "", - getDirectories: () => [], - getCanonicalFileName, - useCaseSensitiveFileNames: () => useCaseSensitiveFileNames, - getNewLine: () => ts.sys ? ts.sys.newLine : newLine, - fileExists: fileName => files.has(fileName), - readFile: fileName => { - const file = files.get(fileName); - return file && file.text; - }, - }; - if (useGetSourceFileByPath) { - const filesByPath = ts.mapEntries(files, (fileName, file) => [ts.toPath(fileName, "", getCanonicalFileName), file]); - result.getSourceFileByPath = (_fileName, path) => filesByPath.get(path); - } - return result; -} - -export function newProgram(texts: NamedSourceText[], rootNames: string[], options: ts.CompilerOptions, useGetSourceFileByPath?: boolean): ProgramWithSourceTexts { - const host = createTestCompilerHost(texts, options.target!, /*oldProgram*/ undefined, useGetSourceFileByPath); - const program = ts.createProgram(rootNames, options, host) as ProgramWithSourceTexts; - program.sourceTexts = texts; - program.host = host; - return program; -} - -export function updateProgram(oldProgram: ProgramWithSourceTexts, rootNames: readonly string[], options: ts.CompilerOptions, updater: (files: NamedSourceText[]) => void, newTexts?: NamedSourceText[], useGetSourceFileByPath?: boolean) { - if (!newTexts) { - newTexts = oldProgram.sourceTexts!.slice(0); - } - updater(newTexts); - const host = createTestCompilerHost(newTexts, options.target!, oldProgram, useGetSourceFileByPath); - const program = ts.createProgram(rootNames, options, host, oldProgram) as ProgramWithSourceTexts; - program.sourceTexts = newTexts; - program.host = host; - return program; -} - -export function updateProgramText(files: readonly NamedSourceText[], fileName: string, newProgramText: string) { - const file = ts.find(files, f => f.name === fileName)!; - file.text = file.text.updateProgram(newProgramText); -} - -function checkResolvedTypeDirective(actual: ts.ResolvedTypeReferenceDirective, expected: ts.ResolvedTypeReferenceDirective) { - assert.equal(actual.resolvedFileName, expected.resolvedFileName, `'resolvedFileName': expected '${actual.resolvedFileName}' to be equal to '${expected.resolvedFileName}'`); - assert.equal(actual.primary, expected.primary, `'primary': expected '${actual.primary}' to be equal to '${expected.primary}'`); - return true; -} - -function checkCache(caption: string, program: ts.Program, fileName: string, expectedContent: ts.ESMap | undefined, getCache: (f: ts.SourceFile) => ts.ModeAwareCache | undefined, entryChecker: (expected: T, original: T) => boolean): void { - const file = program.getSourceFile(fileName); - assert.isTrue(file !== undefined, `cannot find file ${fileName}`); - const cache = getCache(file!); - if (expectedContent === undefined) { - assert.isTrue(cache === undefined, `expected ${caption} to be undefined`); - } - else { - assert.isTrue(cache !== undefined, `expected ${caption} to be set`); - assert.isTrue(mapEqualToCache(expectedContent, cache!, entryChecker), `contents of ${caption} did not match the expected contents.`); - } -} - -/** True if the maps have the same keys and values. */ -function mapEqualToCache(left: ts.ESMap, right: ts.ModeAwareCache, valuesAreEqual?: (left: T, right: T) => boolean): boolean { - if (left as any === right) return true; // given the type mismatch (the tests never pass a cache), this'll never be true - if (!left || !right) return false; - const someInLeftHasNoMatch = ts.forEachEntry(left, (leftValue, leftKey) => { - if (!right.has(leftKey, /*mode*/ undefined)) return true; - const rightValue = right.get(leftKey, /*mode*/ undefined)!; - return !(valuesAreEqual ? valuesAreEqual(leftValue, rightValue) : leftValue === rightValue); - }); - if (someInLeftHasNoMatch) return false; - let someInRightHasNoMatch = false; - right.forEach((_, rightKey) => someInRightHasNoMatch = someInRightHasNoMatch || !left.has(rightKey)); - return !someInRightHasNoMatch; -} - -function checkResolvedModulesCache(program: ts.Program, fileName: string, expectedContent: ts.ESMap | undefined): void { - checkCache("resolved modules", program, fileName, expectedContent, f => f.resolvedModules, ts.checkResolvedModule); -} - -function checkResolvedTypeDirectivesCache(program: ts.Program, fileName: string, expectedContent: ts.ESMap | undefined): void { - checkCache("resolved type directives", program, fileName, expectedContent, f => f.resolvedTypeReferenceDirectiveNames, checkResolvedTypeDirective); -} +import { checkResolvedModulesCache, checkResolvedTypeDirectivesCache, createTestCompilerHost, NamedSourceText, newLine, newProgram, ProgramWithSourceTexts, SourceText, TestCompilerHost, updateProgram, updateProgramText } from "./helpers"; describe("unittests:: Reuse program structure:: General", () => { const target = ts.ScriptTarget.Latest; diff --git a/src/testRunner/unittests/tsserver/dynamicFiles.ts b/src/testRunner/unittests/tsserver/dynamicFiles.ts index 19398777e39e6..8ef9fd038b405 100644 --- a/src/testRunner/unittests/tsserver/dynamicFiles.ts +++ b/src/testRunner/unittests/tsserver/dynamicFiles.ts @@ -1,9 +1,5 @@ import * as ts from "../../_namespaces/ts"; - -export function verifyDynamic(service: ts.server.ProjectService, path: string) { - const info = ts.Debug.checkDefined(service.filenameToScriptInfo.get(path), `Expected ${path} in :: ${JSON.stringify(ts.arrayFrom(service.filenameToScriptInfo.entries(), ([key, f]) => ({ key, fileName: f.fileName, path: f.path })))}`); - assert.isTrue(info.isDynamic); -} +import { verifyDynamic } from "./helpers"; function verifyPathRecognizedAsDynamic(path: string) { const file: ts.projectSystem.File = { diff --git a/src/testRunner/unittests/tsserver/helpers.ts b/src/testRunner/unittests/tsserver/helpers.ts index 8163b8a249baf..4c56d91fd867c 100644 --- a/src/testRunner/unittests/tsserver/helpers.ts +++ b/src/testRunner/unittests/tsserver/helpers.ts @@ -942,3 +942,15 @@ export function verifyGetErrScenario(scenario: VerifyGetErrScenario) { verifyErrorsUsingGeterrForProject(scenario); verifyErrorsUsingSyncMethods(scenario); } + +export function verifyDynamic(service: ts.server.ProjectService, path: string) { + const info = ts.Debug.checkDefined(service.filenameToScriptInfo.get(path), `Expected ${path} in :: ${JSON.stringify(ts.arrayFrom(service.filenameToScriptInfo.entries(), ([key, f]) => ({ key, fileName: f.fileName, path: f.path })))}`); + assert.isTrue(info.isDynamic); +} + +export function createHostWithSolutionBuild(files: readonly ts.TestFSWithWatch.FileOrFolderOrSymLink[], rootNames: readonly string[]) { + const host = ts.projectSystem.createServerHost(files); + // ts build should succeed + ts.tscWatch.ensureErrorFreeBuild(host, rootNames); + return host; +} diff --git a/src/testRunner/unittests/tsserver/projectReferences.ts b/src/testRunner/unittests/tsserver/projectReferences.ts index 85ca59c24f68d..d03e2167deb99 100644 --- a/src/testRunner/unittests/tsserver/projectReferences.ts +++ b/src/testRunner/unittests/tsserver/projectReferences.ts @@ -1,11 +1,5 @@ import * as ts from "../../_namespaces/ts"; - -export function createHostWithSolutionBuild(files: readonly ts.TestFSWithWatch.FileOrFolderOrSymLink[], rootNames: readonly string[]) { - const host = ts.projectSystem.createServerHost(files); - // ts build should succeed - ts.tscWatch.ensureErrorFreeBuild(host, rootNames); - return host; -} +import { createHostWithSolutionBuild } from "./helpers"; describe("unittests:: tsserver:: with project references and tsbuild", () => { describe("with container project", () => { diff --git a/src/testRunner/utilsRef.ts b/src/testRunner/utilsRef.ts deleted file mode 100644 index 02df007be146d..0000000000000 --- a/src/testRunner/utilsRef.ts +++ /dev/null @@ -1,2 +0,0 @@ -// empty ref to Utils so it can be referenced by unittests -export { }; diff --git a/src/testRunner/vfsRef.ts b/src/testRunner/vfsRef.ts deleted file mode 100644 index 7a9130a0d9c65..0000000000000 --- a/src/testRunner/vfsRef.ts +++ /dev/null @@ -1,2 +0,0 @@ -// empty ref to vfs so it can be referenced by unittests -export { }; diff --git a/src/testRunner/vpathRef.ts b/src/testRunner/vpathRef.ts deleted file mode 100644 index 13cb846ee5ee8..0000000000000 --- a/src/testRunner/vpathRef.ts +++ /dev/null @@ -1,2 +0,0 @@ -// empty ref to vpath so it can be referenced by unittests -export { }; diff --git a/src/tsc/_namespaces/ts.ts b/src/tsc/_namespaces/ts.ts index 8579e4a93bbff..8e361ae718461 100644 --- a/src/tsc/_namespaces/ts.ts +++ b/src/tsc/_namespaces/ts.ts @@ -2,4 +2,3 @@ export * from "../../compiler/_namespaces/ts"; export * from "../../executeCommandLine/_namespaces/ts"; -export * from "../tsc"; diff --git a/src/tsc/tsconfig.json b/src/tsc/tsconfig.json index 205112c6f8c24..a649d4b9fdf54 100644 --- a/src/tsc/tsconfig.json +++ b/src/tsc/tsconfig.json @@ -1,14 +1,11 @@ { - "extends": "../tsconfig-noncomposite-base", + "extends": "../tsconfig-base", "compilerOptions": { - "outDir": "../../built/local" + "outDir": "../../built/local/tsc" }, - "files": [ - "tsc.ts", - "_namespaces/ts.ts" - ], "references": [ { "path": "../compiler" }, { "path": "../executeCommandLine" } - ] + ], + "include": ["**/*"] } diff --git a/src/tsc/tsconfig.release.json b/src/tsc/tsconfig.release.json deleted file mode 100644 index 8ddc790faf07f..0000000000000 --- a/src/tsc/tsconfig.release.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../built/local/release", - "stripInternal": true, - "preserveConstEnums": false, - "declaration": false, - "declarationMap": false, - "sourceMap": false, - "composite": false, - "incremental": true - }, - "references": [ - { "path": "../compiler/tsconfig.release.json" }, - { "path": "../executeCommandLine/tsconfig.release.json" } - ] -} diff --git a/src/tsconfig-base.json b/src/tsconfig-base.json index 51cf414728dc0..c3f416245b8a6 100644 --- a/src/tsconfig-base.json +++ b/src/tsconfig-base.json @@ -1,10 +1,10 @@ { "compilerOptions": { "pretty": true, - "lib": ["es2015.iterable", "es2015.generator", "es5"], - "target": "es5", + "lib": ["es2018"], + "target": "es2018", + "module": "CommonJS", "moduleResolution": "node", - "rootDir": ".", "declaration": true, "declarationMap": true, diff --git a/src/tsconfig-library-base.json b/src/tsconfig-library-base.json deleted file mode 100644 index f4ded3f16c590..0000000000000 --- a/src/tsconfig-library-base.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "./tsconfig-base", - "compilerOptions": { - "declarationMap": false, - "composite": false, - "incremental": true, - "declaration": true, - "stripInternal": true - } -} diff --git a/src/tsconfig-noncomposite-base.json b/src/tsconfig-noncomposite-base.json deleted file mode 100644 index 879a038f5a01b..0000000000000 --- a/src/tsconfig-noncomposite-base.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "./tsconfig-base", - "compilerOptions": { - "declaration": false, - "declarationMap": false, - "composite": false, - "incremental": true - } -} diff --git a/src/tsconfig.json b/src/tsconfig.json index a8ae1655e8fd4..bb93273166a2c 100644 --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -2,13 +2,25 @@ "files": [], "include": [], "references": [ + { "path": "./cancellationToken" }, + { "path": "./compiler" }, + { "path": "./debug" }, + { "path": "./deprecatedCompat" }, + { "path": "./dynamicImportCompat" }, + { "path": "./executeCommandLine" }, + { "path": "./harness" }, + { "path": "./jsTyping" }, + { "path": "./loggedIO" }, + { "path": "./server" }, + { "path": "./services" }, + { "path": "./testRunner" }, { "path": "./tsc" }, { "path": "./tsserver" }, + { "path": "./tsserverlibrary" }, + { "path": "./typescript" }, { "path": "./typingsInstaller" }, + { "path": "./typingsInstallerCore" }, { "path": "./watchGuard" }, - { "path": "./debug" }, - { "path": "./cancellationToken" }, - { "path": "./dynamicImportCompat" }, - { "path": "./testRunner" } + { "path": "./webServer" }, ] } diff --git a/src/tsserver/nodeServer.ts b/src/tsserver/nodeServer.ts index 45c89194bfa0c..de9b8a0ad672e 100644 --- a/src/tsserver/nodeServer.ts +++ b/src/tsserver/nodeServer.ts @@ -526,7 +526,8 @@ function startNodeSession(options: StartSessionOptions, logger: Logger, cancella } } - this.installer = childProcess.fork(combinePaths(__dirname, "typingsInstaller.js"), args, { execArgv }); + // TODO(jakebailey): fix this for module transform + this.installer = childProcess.fork(combinePaths(__dirname, "..", "typingsInstaller", "nodeTypingsInstaller.js"), args, { execArgv }); this.installer.on("message", m => this.handleMessage(m)); // We have to schedule this event to the next tick diff --git a/src/tsserver/tsconfig.json b/src/tsserver/tsconfig.json index 3631224da5be6..d687a82d6f94e 100644 --- a/src/tsserver/tsconfig.json +++ b/src/tsserver/tsconfig.json @@ -1,19 +1,12 @@ { - "extends": "../tsconfig-noncomposite-base", + "extends": "../tsconfig-base", "compilerOptions": { - "outDir": "../../built/local", + "outDir": "../../built/local/tsserver", "types": [ "node" ] }, - "files": [ - "nodeServer.ts", - "webServer.ts", - "server.ts", - "_namespaces/ts.server.ts", - "_namespaces/ts.ts" - ], "references": [ { "path": "../compiler" }, { "path": "../services" }, @@ -21,5 +14,6 @@ { "path": "../server" }, { "path": "../webServer" }, { "path": "../deprecatedCompat" } - ] + ], + "include": ["**/*"] } diff --git a/src/tsserverlibrary/_namespaces/ts.server.ts b/src/tsserverlibrary/_namespaces/ts.server.ts index fb916b71f4d9a..21b0d0335fbd0 100644 --- a/src/tsserverlibrary/_namespaces/ts.server.ts +++ b/src/tsserverlibrary/_namespaces/ts.server.ts @@ -2,4 +2,3 @@ export * from "../../jsTyping/_namespaces/ts.server"; export * from "../../server/_namespaces/ts.server"; -export * from "../tsserverlibrary"; diff --git a/src/tsserverlibrary/tsconfig.json b/src/tsserverlibrary/tsconfig.json index 84e469faca605..7253696321bd0 100644 --- a/src/tsserverlibrary/tsconfig.json +++ b/src/tsserverlibrary/tsconfig.json @@ -1,18 +1,14 @@ { - "extends": "../tsconfig-library-base", + "extends": "../tsconfig-base", "compilerOptions": { - "outDir": "../../built/local" + "outDir": "../../built/local/tsserverlibrary" }, - "files": [ - "tsserverlibrary.ts", - "_namespaces/ts.server.ts", - "_namespaces/ts.ts" - ], "references": [ { "path": "../compiler" }, { "path": "../jsTyping" }, { "path": "../services" }, { "path": "../server" }, { "path": "../deprecatedCompat" } - ] + ], + "include": ["**/*"] } diff --git a/src/tsserverlibrary/tsserverlibrary.ts b/src/tsserverlibrary/tsserverlibrary.ts index 8aa07479d794a..bd73794b37c80 100644 --- a/src/tsserverlibrary/tsserverlibrary.ts +++ b/src/tsserverlibrary/tsserverlibrary.ts @@ -1 +1,5 @@ -export { }; +import * as ts from "./_namespaces/ts"; + +// TODO(jakebailey): replace const enum with enum in d.ts + +export = ts; diff --git a/src/typescript/_namespaces/ts.ts b/src/typescript/_namespaces/ts.ts new file mode 100644 index 0000000000000..e55b26438094f --- /dev/null +++ b/src/typescript/_namespaces/ts.ts @@ -0,0 +1,6 @@ +/* Generated file to emulate the ts namespace. */ + +export * from "../../compiler/_namespaces/ts"; +export * from "../../jsTyping/_namespaces/ts"; +export * from "../../services/_namespaces/ts"; +export * from "../../deprecatedCompat/_namespaces/ts"; diff --git a/src/typescript/tsconfig.json b/src/typescript/tsconfig.json new file mode 100644 index 0000000000000..a1e1447379bbf --- /dev/null +++ b/src/typescript/tsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "../tsconfig-base", + "compilerOptions": { + "outDir": "../../built/local/typescript" + }, + "references": [ + { "path": "../compiler" }, + { "path": "../jsTyping" }, + { "path": "../services" }, + { "path": "../deprecatedCompat" } + ], + "include": ["**/*"] +} diff --git a/src/typescript/typescript.ts b/src/typescript/typescript.ts new file mode 100644 index 0000000000000..c9862f6a73476 --- /dev/null +++ b/src/typescript/typescript.ts @@ -0,0 +1,21 @@ +import * as ts from "./_namespaces/ts"; +import { Debug, LogLevel } from "./_namespaces/ts"; + +// TODO(jakebailey): replace const enum with enum in d.ts + +// enable deprecation logging +declare const console: any; +if (typeof console !== "undefined") { + Debug.loggingHost = { + log(level, s) { + switch (level) { + case LogLevel.Error: return console.error(s); + case LogLevel.Warning: return console.warn(s); + case LogLevel.Info: return console.log(s); + case LogLevel.Verbose: return console.log(s); + } + } + }; +} + +export = ts; diff --git a/src/typingsInstaller/tsconfig.json b/src/typingsInstaller/tsconfig.json index ce1cd04846b6b..7301536476d8b 100644 --- a/src/typingsInstaller/tsconfig.json +++ b/src/typingsInstaller/tsconfig.json @@ -1,8 +1,7 @@ { - "extends": "../tsconfig-noncomposite-base", + "extends": "../tsconfig-base", "compilerOptions": { - "removeComments": true, - "outDir": "../../built/local", + "outDir": "../../built/local/typingsInstaller", "types": [ "node" ], @@ -16,10 +15,5 @@ { "path": "../jsTyping" }, { "path": "../typingsInstallerCore" } ], - "files": [ - "nodeTypingsInstaller.ts", - "_namespaces/ts.server.typingsInstaller.ts", - "_namespaces/ts.ts", - "_namespaces/ts.server.ts" - ] + "include": ["**/*"] } diff --git a/src/typingsInstallerCore/tsconfig.json b/src/typingsInstallerCore/tsconfig.json index f1001c80d4e0a..e5920e87c606a 100644 --- a/src/typingsInstallerCore/tsconfig.json +++ b/src/typingsInstallerCore/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../tsconfig-base", "compilerOptions": { - "outDir": "../../built/local", + "outDir": "../../built/local/typingsInstallerCore", "types": [ "node" ], @@ -14,10 +14,5 @@ { "path": "../compiler" }, { "path": "../jsTyping" } ], - "files": [ - "typingsInstaller.ts", - "_namespaces/ts.server.typingsInstaller.ts", - "_namespaces/ts.ts", - "_namespaces/ts.server.ts" - ] + "include": ["**/*"] } diff --git a/src/watchGuard/tsconfig.json b/src/watchGuard/tsconfig.json index 09507204745e1..0a32df080d690 100644 --- a/src/watchGuard/tsconfig.json +++ b/src/watchGuard/tsconfig.json @@ -1,9 +1,7 @@ { - "extends": "../tsconfig-noncomposite-base", + "extends": "../tsconfig-base", "compilerOptions": { - "removeComments": true, - "incremental": false, - "outDir": "../../built/local", + "outDir": "../../built/local/watchGuard", "types": [ "node" ], @@ -11,7 +9,5 @@ "es6" ] }, - "files": [ - "watchGuard.ts" - ] + "include": ["**/*"] } diff --git a/src/webServer/tsconfig.json b/src/webServer/tsconfig.json index 6adb45247201e..69955d2baa434 100644 --- a/src/webServer/tsconfig.json +++ b/src/webServer/tsconfig.json @@ -1,9 +1,7 @@ { "extends": "../tsconfig-base", "compilerOptions": { - "removeComments": false, - "outDir": "../../built/local", - "preserveConstEnums": true, + "outDir": "../../built/local/webServer", "types": [ "node" ] @@ -14,9 +12,5 @@ { "path": "../services" }, { "path": "../server" } ], - "files": [ - "webServer.ts", - "_namespaces/ts.server.ts", - "_namespaces/ts.ts" - ] + "include": ["**/*"] } diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 7d5bd0d6c5015..d8d17f21af973 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -42,9 +42,8 @@ // // TODO: figure out a better solution to the API exposure problem. -/// - declare module ts { + export const Diagnostics: typeof import("../../../src/compiler/diagnosticInformationMap.generated").Diagnostics; export type MapKey = string | number; export interface Map { forEach(action: (value: T, key: string) => void): void;