diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 79adcbd04e7..cd71846f8fc 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -4525,13 +4525,13 @@ export function createProgram(_rootNamesOrOptions: readonly string[] | CreatePro } }); - checkDeprecations("6.0", "7.0", createDiagnostic, createDeprecatedDiagnostic => { - if (options.moduleResolution === ModuleResolutionKind.Node10) { - createDeprecatedDiagnostic("moduleResolution", "node10"); - } - if (options.baseUrl) { - createDeprecatedDiagnostic("baseUrl"); - } + checkDeprecations("6.0", "7.0", createDiagnostic, createDeprecatedDiagnostic => { + if (options.moduleResolution === ModuleResolutionKind.Node10) { + createDeprecatedDiagnostic("moduleResolution", "node10"); + } + if (options.baseUrl) { + createDeprecatedDiagnostic("baseUrl"); + } }); } diff --git a/tests/baselines/reference/baseUrlMigrationExample.errors.txt b/tests/baselines/reference/baseUrlMigrationExample.errors.txt new file mode 100644 index 00000000000..f614168ebb5 --- /dev/null +++ b/tests/baselines/reference/baseUrlMigrationExample.errors.txt @@ -0,0 +1,58 @@ +/before/tsconfig.json(3,9): error TS5101: Option 'baseUrl' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. + + +==== /before/tsconfig.json (1 errors) ==== + { + "compilerOptions": { + "baseUrl": "./src", + ~~~~~~~~~ +!!! error TS5101: Option 'baseUrl' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. + "paths": { + "@app/*": ["app/*"], + "@lib/*": ["lib/*"] + } + } + } + +==== /before/src/app/module.ts (0 errors) ==== + export const value = 42; + +==== /before/src/lib/utils.ts (0 errors) ==== + export function helper() { return "help"; } + +==== /before/src/main.ts (0 errors) ==== + import { value } from "@app/module"; + import { helper } from "@lib/utils"; + // This would also resolve due to baseUrl: + import * as something from "someModule"; // Resolves to ./src/someModule + +==== /before/src/someModule.ts (0 errors) ==== + export const data = "from baseUrl resolution"; + +==== /after/tsconfig.json (0 errors) ==== + { + "compilerOptions": { + "paths": { + // Explicit prefix for all path mappings + "@app/*": ["./src/app/*"], + "@lib/*": ["./src/lib/*"], + // Optional: preserve baseUrl behavior with catch-all + "*": ["./src/*"] + } + } + } + +==== /after/src/app/module.ts (0 errors) ==== + export const value = 42; + +==== /after/src/lib/utils.ts (0 errors) ==== + export function helper() { return "help"; } + +==== /after/src/main.ts (0 errors) ==== + import { value } from "@app/module"; + import { helper } from "@lib/utils"; + // With explicit catch-all mapping, this still works: + import * as something from "someModule"; // Resolves to ./src/someModule + +==== /after/src/someModule.ts (0 errors) ==== + export const data = "from explicit path mapping"; \ No newline at end of file diff --git a/tests/baselines/reference/baseUrlMigrationExample.js b/tests/baselines/reference/baseUrlMigrationExample.js new file mode 100644 index 00000000000..64dee7a1f16 --- /dev/null +++ b/tests/baselines/reference/baseUrlMigrationExample.js @@ -0,0 +1,63 @@ +//// [tests/cases/compiler/baseUrlMigrationExample.ts] //// + +//// [tsconfig.json] +{ + "compilerOptions": { + "paths": { + // Explicit prefix for all path mappings + "@app/*": ["./src/app/*"], + "@lib/*": ["./src/lib/*"], + // Optional: preserve baseUrl behavior with catch-all + "*": ["./src/*"] + } + } +} + +//// [module.ts] +export const value = 42; + +//// [utils.ts] +export function helper() { return "help"; } + +//// [main.ts] +import { value } from "@app/module"; +import { helper } from "@lib/utils"; +// With explicit catch-all mapping, this still works: +import * as something from "someModule"; // Resolves to ./src/someModule + +//// [someModule.ts] +export const data = "from explicit path mapping"; +//// [module.ts] +export const value = 42; + +//// [utils.ts] +export function helper() { return "help"; } + +//// [main.ts] +import { value } from "@app/module"; +import { helper } from "@lib/utils"; +// This would also resolve due to baseUrl: +import * as something from "someModule"; // Resolves to ./src/someModule + +//// [someModule.ts] +export const data = "from baseUrl resolution"; + + +//// [module.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.value = void 0; +exports.value = 42; +//// [utils.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.helper = helper; +function helper() { return "help"; } +//// [someModule.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.data = void 0; +exports.data = "from baseUrl resolution"; +//// [main.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/baseUrlMigrationExample.symbols b/tests/baselines/reference/baseUrlMigrationExample.symbols new file mode 100644 index 00000000000..e4f9434dd67 --- /dev/null +++ b/tests/baselines/reference/baseUrlMigrationExample.symbols @@ -0,0 +1,25 @@ +//// [tests/cases/compiler/baseUrlMigrationExample.ts] //// + +=== /before/src/app/module.ts === +export const value = 42; +>value : Symbol(value, Decl(module.ts, 0, 12)) + +=== /before/src/lib/utils.ts === +export function helper() { return "help"; } +>helper : Symbol(helper, Decl(utils.ts, 0, 0)) + +=== /before/src/main.ts === +import { value } from "@app/module"; +>value : Symbol(value, Decl(main.ts, 0, 8)) + +import { helper } from "@lib/utils"; +>helper : Symbol(helper, Decl(main.ts, 1, 8)) + +// This would also resolve due to baseUrl: +import * as something from "someModule"; // Resolves to ./src/someModule +>something : Symbol(something, Decl(main.ts, 3, 6)) + +=== /before/src/someModule.ts === +export const data = "from baseUrl resolution"; +>data : Symbol(data, Decl(someModule.ts, 0, 12)) + diff --git a/tests/baselines/reference/baseUrlMigrationExample.types b/tests/baselines/reference/baseUrlMigrationExample.types new file mode 100644 index 00000000000..d9017357351 --- /dev/null +++ b/tests/baselines/reference/baseUrlMigrationExample.types @@ -0,0 +1,37 @@ +//// [tests/cases/compiler/baseUrlMigrationExample.ts] //// + +=== /before/src/app/module.ts === +export const value = 42; +>value : 42 +> : ^^ +>42 : 42 +> : ^^ + +=== /before/src/lib/utils.ts === +export function helper() { return "help"; } +>helper : () => string +> : ^^^^^^^^^^^^ +>"help" : "help" +> : ^^^^^^ + +=== /before/src/main.ts === +import { value } from "@app/module"; +>value : 42 +> : ^^ + +import { helper } from "@lib/utils"; +>helper : () => string +> : ^^^^^^^^^^^^ + +// This would also resolve due to baseUrl: +import * as something from "someModule"; // Resolves to ./src/someModule +>something : typeof something +> : ^^^^^^^^^^^^^^^^ + +=== /before/src/someModule.ts === +export const data = "from baseUrl resolution"; +>data : "from baseUrl resolution" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ +>"from baseUrl resolution" : "from baseUrl resolution" +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ + diff --git a/tests/cases/compiler/baseUrlMigrationExample.ts b/tests/cases/compiler/baseUrlMigrationExample.ts new file mode 100644 index 00000000000..c7510ba0377 --- /dev/null +++ b/tests/cases/compiler/baseUrlMigrationExample.ts @@ -0,0 +1,56 @@ +// @typeScriptVersion: 6.0 +// Test showing the recommended migration from baseUrl to explicit path mappings + +// @filename: /before/tsconfig.json +{ + "compilerOptions": { + "baseUrl": "./src", + "paths": { + "@app/*": ["app/*"], + "@lib/*": ["lib/*"] + } + } +} + +// @filename: /before/src/app/module.ts +export const value = 42; + +// @filename: /before/src/lib/utils.ts +export function helper() { return "help"; } + +// @filename: /before/src/main.ts +import { value } from "@app/module"; +import { helper } from "@lib/utils"; +// This would also resolve due to baseUrl: +import * as something from "someModule"; // Resolves to ./src/someModule + +// @filename: /before/src/someModule.ts +export const data = "from baseUrl resolution"; + +// @filename: /after/tsconfig.json +{ + "compilerOptions": { + "paths": { + // Explicit prefix for all path mappings + "@app/*": ["./src/app/*"], + "@lib/*": ["./src/lib/*"], + // Optional: preserve baseUrl behavior with catch-all + "*": ["./src/*"] + } + } +} + +// @filename: /after/src/app/module.ts +export const value = 42; + +// @filename: /after/src/lib/utils.ts +export function helper() { return "help"; } + +// @filename: /after/src/main.ts +import { value } from "@app/module"; +import { helper } from "@lib/utils"; +// With explicit catch-all mapping, this still works: +import * as something from "someModule"; // Resolves to ./src/someModule + +// @filename: /after/src/someModule.ts +export const data = "from explicit path mapping"; \ No newline at end of file diff --git a/tests/cases/compiler/pathMappingBasedModuleResolution2_node.ts b/tests/cases/compiler/pathMappingBasedModuleResolution2_node.ts index ac4d51bacf5..e2d56045a35 100644 --- a/tests/cases/compiler/pathMappingBasedModuleResolution2_node.ts +++ b/tests/cases/compiler/pathMappingBasedModuleResolution2_node.ts @@ -1,18 +1,19 @@ -// @module: commonjs -// @traceResolution: true - -// baseurl is defined in tsconfig.json -// paths has errors - -// @filename: root/tsconfig.json -{ - "compilerOptions": { - "baseUrl": "./src", - "paths": { - "*1*": [ "*2*" ] - } - } -} - -// @filename: root/src/folder1/file1.ts +// @module: commonjs +// @traceResolution: true + +// baseurl is defined in tsconfig.json +// paths has errors + +// @filename: root/tsconfig.json +{ + "compilerOptions": { + "baseUrl": "./src", + "ignoreDeprecations": "6.0", + "paths": { + "*1*": [ "*2*" ] + } + } +} + +// @filename: root/src/folder1/file1.ts export var x = 1; \ No newline at end of file diff --git a/tests/cases/compiler/pathMappingBasedModuleResolution4_node.ts b/tests/cases/compiler/pathMappingBasedModuleResolution4_node.ts index e302ca0addc..cad08906c4f 100644 --- a/tests/cases/compiler/pathMappingBasedModuleResolution4_node.ts +++ b/tests/cases/compiler/pathMappingBasedModuleResolution4_node.ts @@ -1,28 +1,29 @@ -// @moduleResolution: bundler -// @module: commonjs -// @traceResolution: true - -// baseUrl set via command line - -// @filename: c:/root/tsconfig.json -{ - "compilerOptions": { - "baseUrl": "." - } -} - -// @filename: c:/root/folder1/file1.ts -import {x} from "folder2/file2" -declare function use(a: any): void; -use(x.toExponential()); - -// @filename: c:/root/folder2/file2.ts -import {x as a} from "./file3" // found with baseurl -import {y as b} from "file4" // found with fallback -export var x = a + b; - -// @filename: c:/root/folder2/file3.ts -export var x = 1; - -// @filename: c:/node_modules/file4/index.d.ts +// @moduleResolution: bundler +// @module: commonjs +// @traceResolution: true + +// baseUrl set via command line + +// @filename: c:/root/tsconfig.json +{ + "compilerOptions": { + "baseUrl": ".", + "ignoreDeprecations": "6.0" + } +} + +// @filename: c:/root/folder1/file1.ts +import {x} from "folder2/file2" +declare function use(a: any): void; +use(x.toExponential()); + +// @filename: c:/root/folder2/file2.ts +import {x as a} from "./file3" // found with baseurl +import {y as b} from "file4" // found with fallback +export var x = a + b; + +// @filename: c:/root/folder2/file3.ts +export var x = 1; + +// @filename: c:/node_modules/file4/index.d.ts export var y: number; \ No newline at end of file diff --git a/tests/cases/compiler/pathMappingBasedModuleResolution5_classic.ts b/tests/cases/compiler/pathMappingBasedModuleResolution5_classic.ts index 9779f0ca644..8b0599bfc13 100644 --- a/tests/cases/compiler/pathMappingBasedModuleResolution5_classic.ts +++ b/tests/cases/compiler/pathMappingBasedModuleResolution5_classic.ts @@ -1,43 +1,44 @@ -// @module: amd -// @traceResolution: true - -// paths is defined in tsconfig.json -// @filename: c:/root/tsconfig.json -{ - "compilerOptions": { - "baseUrl": ".", - "paths": { - "*": [ - "*", - "generated/*" - ], - "components/*": [ - "shared/components/*" - ] - } - } -} -// @filename: c:/root/folder1/file1.ts -import {x} from "folder2/file1" -import {y} from "folder3/file2" -import {z} from "components/file3" -import {z1} from "file4" - -declare function use(a: any): void; - -use(x.toExponential()); -use(y.toExponential()); -use(z.toExponential()); -use(z1.toExponential()); - -// @filename: c:/root/folder2/file1.ts -export var x = 1; - -// @filename: c:/root/generated/folder3/file2.ts -export var y = 1; - -// @filename: c:/root/shared/components/file3.ts -export var z = 1; - -// @filename: c:/file4.ts +// @module: amd +// @traceResolution: true + +// paths is defined in tsconfig.json +// @filename: c:/root/tsconfig.json +{ + "compilerOptions": { + "baseUrl": ".", + "ignoreDeprecations": "6.0", + "paths": { + "*": [ + "*", + "generated/*" + ], + "components/*": [ + "shared/components/*" + ] + } + } +} +// @filename: c:/root/folder1/file1.ts +import {x} from "folder2/file1" +import {y} from "folder3/file2" +import {z} from "components/file3" +import {z1} from "file4" + +declare function use(a: any): void; + +use(x.toExponential()); +use(y.toExponential()); +use(z.toExponential()); +use(z1.toExponential()); + +// @filename: c:/root/folder2/file1.ts +export var x = 1; + +// @filename: c:/root/generated/folder3/file2.ts +export var y = 1; + +// @filename: c:/root/shared/components/file3.ts +export var z = 1; + +// @filename: c:/file4.ts export var z1 = 1; \ No newline at end of file diff --git a/tests/cases/compiler/pathMappingBasedModuleResolution5_node.ts b/tests/cases/compiler/pathMappingBasedModuleResolution5_node.ts index ddc8e0e4925..98e9fa2ecff 100644 --- a/tests/cases/compiler/pathMappingBasedModuleResolution5_node.ts +++ b/tests/cases/compiler/pathMappingBasedModuleResolution5_node.ts @@ -1,43 +1,44 @@ -// @module: commonjs -// @traceResolution: true - -// paths is defined in tsconfig.json -// @filename: c:/root/tsconfig.json -{ - "compilerOptions": { - "baseUrl": ".", - "paths": { - "*": [ - "*", - "generated/*" - ], - "components/*": [ - "shared/components/*" - ] - } - } -} -// @filename: c:/root/folder1/file1.ts -import {x} from "folder2/file1" -import {y} from "folder3/file2" -import {z} from "components/file3" -import {z1} from "file4" - -declare function use(a: any): void; - -use(x.toExponential()); -use(y.toExponential()); -use(z.toExponential()); -use(z1.toExponential()); - -// @filename: c:/root/folder2/file1.ts -export var x = 1; - -// @filename: c:/root/generated/folder3/file2.ts -export var y = 1; - -// @filename: c:/root/shared/components/file3/index.d.ts -export var z: number; - -// @filename: c:/node_modules/file4.ts -export var z1 = 1; +// @module: commonjs +// @traceResolution: true + +// paths is defined in tsconfig.json +// @filename: c:/root/tsconfig.json +{ + "compilerOptions": { + "baseUrl": ".", + "ignoreDeprecations": "6.0", + "paths": { + "*": [ + "*", + "generated/*" + ], + "components/*": [ + "shared/components/*" + ] + } + } +} +// @filename: c:/root/folder1/file1.ts +import {x} from "folder2/file1" +import {y} from "folder3/file2" +import {z} from "components/file3" +import {z1} from "file4" + +declare function use(a: any): void; + +use(x.toExponential()); +use(y.toExponential()); +use(z.toExponential()); +use(z1.toExponential()); + +// @filename: c:/root/folder2/file1.ts +export var x = 1; + +// @filename: c:/root/generated/folder3/file2.ts +export var y = 1; + +// @filename: c:/root/shared/components/file3/index.d.ts +export var z: number; + +// @filename: c:/node_modules/file4.ts +export var z1 = 1; diff --git a/tests/cases/compiler/pathMappingBasedModuleResolution7_classic.ts b/tests/cases/compiler/pathMappingBasedModuleResolution7_classic.ts index 81c2328df67..36769f4f9f2 100644 --- a/tests/cases/compiler/pathMappingBasedModuleResolution7_classic.ts +++ b/tests/cases/compiler/pathMappingBasedModuleResolution7_classic.ts @@ -1,49 +1,50 @@ -// @module: amd -// @traceResolution: true - -// @filename: c:/root/src/tsconfig.json -{ - "compilerOptions": { - "baseUrl": "../", - "paths": { - "*": [ - "*", - "c:/shared/*" - ], - "templates/*": [ - "generated/src/templates/*" - ] - }, - "rootDirs": [ - ".", - "../generated/src" - ] - } -} - -// @filename: c:/root/src/file1.ts -import {x} from "./project/file2"; -import {y} from "module3"; - -declare function use(x: string); -use(x.toFixed()); -use(y.toFixed()); - -// @filename: c:/root/generated/src/project/file2.ts -import {a} from "module1"; -import {b} from "templates/module2"; -import {x as c} from "../file3"; -export let x = a + b + c; - -// @filename: c:/shared/module1.d.ts -export let a: number - -// @filename: c:/root/generated/src/templates/module2.ts -export let b: number; - -// @filename: c:/root/src/file3.d.ts -export let x: number; - -// @filename: c:/module3.d.ts -export let y: number; - +// @module: amd +// @traceResolution: true + +// @filename: c:/root/src/tsconfig.json +{ + "compilerOptions": { + "baseUrl": "../", + "ignoreDeprecations": "6.0", + "paths": { + "*": [ + "*", + "c:/shared/*" + ], + "templates/*": [ + "generated/src/templates/*" + ] + }, + "rootDirs": [ + ".", + "../generated/src" + ] + } +} + +// @filename: c:/root/src/file1.ts +import {x} from "./project/file2"; +import {y} from "module3"; + +declare function use(x: string); +use(x.toFixed()); +use(y.toFixed()); + +// @filename: c:/root/generated/src/project/file2.ts +import {a} from "module1"; +import {b} from "templates/module2"; +import {x as c} from "../file3"; +export let x = a + b + c; + +// @filename: c:/shared/module1.d.ts +export let a: number + +// @filename: c:/root/generated/src/templates/module2.ts +export let b: number; + +// @filename: c:/root/src/file3.d.ts +export let x: number; + +// @filename: c:/module3.d.ts +export let y: number; + diff --git a/tests/cases/compiler/pathMappingBasedModuleResolution7_node.ts b/tests/cases/compiler/pathMappingBasedModuleResolution7_node.ts index 1ba9630e0cf..4a60418651f 100644 --- a/tests/cases/compiler/pathMappingBasedModuleResolution7_node.ts +++ b/tests/cases/compiler/pathMappingBasedModuleResolution7_node.ts @@ -1,49 +1,50 @@ -// @module: commonjs -// @traceResolution: true - -// @filename: c:/root/src/tsconfig.json -{ - "compilerOptions": { - "baseUrl": "../", - "paths": { - "*": [ - "*", - "c:/shared/*" - ], - "templates/*": [ - "generated/src/templates/*" - ] - }, - "rootDirs": [ - ".", - "../generated/src" - ] - } -} - -// @filename: c:/root/src/file1.ts -import {x} from "./project/file2"; -import {y} from "module3"; - -declare function use(x: string); -use(x.toFixed()); -use(y.toFixed()); - -// @filename: c:/root/generated/src/project/file2.ts -import {a} from "module1"; -import {b} from "templates/module2"; -import {x as c} from "../file3"; -export let x = a + b + c; - -// @filename: c:/shared/module1/index.d.ts -export let a: number - -// @filename: c:/root/generated/src/templates/module2.ts -export let b: number; - -// @filename: c:/root/src/file3/index.d.ts -export let x: number; - -// @filename: c:/node_modules/module3.d.ts -export let y: number; - +// @module: commonjs +// @traceResolution: true + +// @filename: c:/root/src/tsconfig.json +{ + "compilerOptions": { + "baseUrl": "../", + "ignoreDeprecations": "6.0", + "paths": { + "*": [ + "*", + "c:/shared/*" + ], + "templates/*": [ + "generated/src/templates/*" + ] + }, + "rootDirs": [ + ".", + "../generated/src" + ] + } +} + +// @filename: c:/root/src/file1.ts +import {x} from "./project/file2"; +import {y} from "module3"; + +declare function use(x: string); +use(x.toFixed()); +use(y.toFixed()); + +// @filename: c:/root/generated/src/project/file2.ts +import {a} from "module1"; +import {b} from "templates/module2"; +import {x as c} from "../file3"; +export let x = a + b + c; + +// @filename: c:/shared/module1/index.d.ts +export let a: number + +// @filename: c:/root/generated/src/templates/module2.ts +export let b: number; + +// @filename: c:/root/src/file3/index.d.ts +export let x: number; + +// @filename: c:/node_modules/module3.d.ts +export let y: number; + diff --git a/tests/cases/compiler/pathMappingBasedModuleResolution8_classic.ts b/tests/cases/compiler/pathMappingBasedModuleResolution8_classic.ts index dbbf84ab91b..c871c416582 100644 --- a/tests/cases/compiler/pathMappingBasedModuleResolution8_classic.ts +++ b/tests/cases/compiler/pathMappingBasedModuleResolution8_classic.ts @@ -1,21 +1,22 @@ -// @moduleResolution: classic -// @module: amd -// @traceResolution: true - -// @filename: c:/root/tsconfig.json -{ - "compilerOptions": { - "baseUrl": ".", - "paths": { - "@speedy/*/testing": [ - "*/dist/index.ts" - ] - } - } -} - -// @filename: c:/root/index.ts -import {x} from "@speedy/folder1/testing" - -// @filename: c:/root/folder1/dist/index.ts -export const x = 1 + 2; +// @moduleResolution: classic +// @module: amd +// @traceResolution: true + +// @filename: c:/root/tsconfig.json +{ + "compilerOptions": { + "baseUrl": ".", + "ignoreDeprecations": "6.0", + "paths": { + "@speedy/*/testing": [ + "*/dist/index.ts" + ] + } + } +} + +// @filename: c:/root/index.ts +import {x} from "@speedy/folder1/testing" + +// @filename: c:/root/folder1/dist/index.ts +export const x = 1 + 2; diff --git a/tests/cases/compiler/pathMappingBasedModuleResolution8_node.ts b/tests/cases/compiler/pathMappingBasedModuleResolution8_node.ts index 5cf3b61bb44..0bb308f36bf 100644 --- a/tests/cases/compiler/pathMappingBasedModuleResolution8_node.ts +++ b/tests/cases/compiler/pathMappingBasedModuleResolution8_node.ts @@ -1,21 +1,22 @@ -// @moduleResolution: bundler -// @module: commonjs -// @traceResolution: true - -// @filename: c:/root/tsconfig.json -{ - "compilerOptions": { - "baseUrl": ".", - "paths": { - "@speedy/*/testing": [ - "*/dist/index.ts" - ] - } - } -} - -// @filename: c:/root/index.ts -import {x} from "@speedy/folder1/testing" - -// @filename: c:/root/folder1/dist/index.ts -export const x = 1 + 2; +// @moduleResolution: bundler +// @module: commonjs +// @traceResolution: true + +// @filename: c:/root/tsconfig.json +{ + "compilerOptions": { + "baseUrl": ".", + "ignoreDeprecations": "6.0", + "paths": { + "@speedy/*/testing": [ + "*/dist/index.ts" + ] + } + } +} + +// @filename: c:/root/index.ts +import {x} from "@speedy/folder1/testing" + +// @filename: c:/root/folder1/dist/index.ts +export const x = 1 + 2; diff --git a/tests/cases/compiler/pathMappingBasedModuleResolution_rootImport_aliasWithRoot.ts b/tests/cases/compiler/pathMappingBasedModuleResolution_rootImport_aliasWithRoot.ts index 9af12c71a95..6af7065721d 100644 --- a/tests/cases/compiler/pathMappingBasedModuleResolution_rootImport_aliasWithRoot.ts +++ b/tests/cases/compiler/pathMappingBasedModuleResolution_rootImport_aliasWithRoot.ts @@ -1,25 +1,26 @@ -// @noImplicitReferences: true -// @traceResolution: true -// @allowJs: true - -// @filename: /root/src/foo.ts -export function foo() {} - -// @filename: /root/src/bar.js -export function bar() {} - -// @filename: /root/a.ts -import { foo } from "/foo"; -import { bar } from "/bar"; - -// @filename: /root/tsconfig.json -{ - "compilerOptions": { - "baseUrl": ".", - "paths": { - "/*": ["./src/*"] - }, - "allowJs": true, - "outDir": "bin" - } -} +// @noImplicitReferences: true +// @traceResolution: true +// @allowJs: true + +// @filename: /root/src/foo.ts +export function foo() {} + +// @filename: /root/src/bar.js +export function bar() {} + +// @filename: /root/a.ts +import { foo } from "/foo"; +import { bar } from "/bar"; + +// @filename: /root/tsconfig.json +{ + "compilerOptions": { + "baseUrl": ".", + "ignoreDeprecations": "6.0", + "paths": { + "/*": ["./src/*"] + }, + "allowJs": true, + "outDir": "bin" + } +} diff --git a/tests/cases/compiler/pathMappingBasedModuleResolution_rootImport_aliasWithRoot_differentRootTypes.ts b/tests/cases/compiler/pathMappingBasedModuleResolution_rootImport_aliasWithRoot_differentRootTypes.ts index a9fd2cde5bd..fda6422a9f3 100644 --- a/tests/cases/compiler/pathMappingBasedModuleResolution_rootImport_aliasWithRoot_differentRootTypes.ts +++ b/tests/cases/compiler/pathMappingBasedModuleResolution_rootImport_aliasWithRoot_differentRootTypes.ts @@ -1,49 +1,50 @@ -// @noImplicitReferences: true -// @traceResolution: true -// @allowJs: true - -// @filename: /root/src/foo.ts -export function foo() {} - -// @filename: /root/src/bar.js -export function bar() {} - -// @filename: /root/a.ts -import { foo as foo1 } from "/foo"; -import { bar as bar1 } from "/bar"; -import { foo as foo2 } from "c:/foo"; -import { bar as bar2 } from "c:/bar"; -import { foo as foo3 } from "c:\\foo"; -import { bar as bar3 } from "c:\\bar"; -import { foo as foo4 } from "//server/foo"; -import { bar as bar4 } from "//server/bar"; -import { foo as foo5 } from "\\\\server\\foo"; -import { bar as bar5 } from "\\\\server\\bar"; -import { foo as foo6 } from "file:///foo"; -import { bar as bar6 } from "file:///bar"; -import { foo as foo7 } from "file://c:/foo"; -import { bar as bar7 } from "file://c:/bar"; -import { foo as foo8 } from "file://server/foo"; -import { bar as bar8 } from "file://server/bar"; -import { foo as foo9 } from "http://server/foo"; -import { bar as bar9 } from "http://server/bar"; - -// @filename: /root/tsconfig.json -{ - "compilerOptions": { - "baseUrl": ".", - "paths": { - "/*": ["./src/*"], - "c:/*": ["./src/*"], - "c:\\*": ["./src/*"], - "//server/*": ["./src/*"], - "\\\\server\\*": ["./src/*"], - "file:///*": ["./src/*"], - "file://c:/*": ["./src/*"], - "file://server/*": ["./src/*"], - "http://server/*": ["./src/*"] - }, - "allowJs": true, - "outDir": "bin" - } -} +// @noImplicitReferences: true +// @traceResolution: true +// @allowJs: true + +// @filename: /root/src/foo.ts +export function foo() {} + +// @filename: /root/src/bar.js +export function bar() {} + +// @filename: /root/a.ts +import { foo as foo1 } from "/foo"; +import { bar as bar1 } from "/bar"; +import { foo as foo2 } from "c:/foo"; +import { bar as bar2 } from "c:/bar"; +import { foo as foo3 } from "c:\\foo"; +import { bar as bar3 } from "c:\\bar"; +import { foo as foo4 } from "//server/foo"; +import { bar as bar4 } from "//server/bar"; +import { foo as foo5 } from "\\\\server\\foo"; +import { bar as bar5 } from "\\\\server\\bar"; +import { foo as foo6 } from "file:///foo"; +import { bar as bar6 } from "file:///bar"; +import { foo as foo7 } from "file://c:/foo"; +import { bar as bar7 } from "file://c:/bar"; +import { foo as foo8 } from "file://server/foo"; +import { bar as bar8 } from "file://server/bar"; +import { foo as foo9 } from "http://server/foo"; +import { bar as bar9 } from "http://server/bar"; + +// @filename: /root/tsconfig.json +{ + "compilerOptions": { + "baseUrl": ".", + "ignoreDeprecations": "6.0", + "paths": { + "/*": ["./src/*"], + "c:/*": ["./src/*"], + "c:\\*": ["./src/*"], + "//server/*": ["./src/*"], + "\\\\server\\*": ["./src/*"], + "file:///*": ["./src/*"], + "file://c:/*": ["./src/*"], + "file://server/*": ["./src/*"], + "http://server/*": ["./src/*"] + }, + "allowJs": true, + "outDir": "bin" + } +} diff --git a/tests/cases/compiler/pathMappingBasedModuleResolution_rootImport_aliasWithRoot_multipleAliases.ts b/tests/cases/compiler/pathMappingBasedModuleResolution_rootImport_aliasWithRoot_multipleAliases.ts index 5225f1dbd05..75e9e3d1ed0 100644 --- a/tests/cases/compiler/pathMappingBasedModuleResolution_rootImport_aliasWithRoot_multipleAliases.ts +++ b/tests/cases/compiler/pathMappingBasedModuleResolution_rootImport_aliasWithRoot_multipleAliases.ts @@ -1,26 +1,27 @@ -// @noImplicitReferences: true -// @traceResolution: true -// @allowJs: true - -// @filename: /root/import/foo.ts -export function foo() {} - -// @filename: /root/client/bar.js -export function bar() {} - -// @filename: /root/src/a.ts -import { foo } from "/import/foo"; -import { bar } from "/client/bar"; - -// @filename: /root/tsconfig.json -{ - "compilerOptions": { - "baseUrl": ".", - "paths": { - "/client/*": ["./client/*"], - "/import/*": ["./import/*"] - }, - "allowJs": true, - "outDir": "bin" - } -} +// @noImplicitReferences: true +// @traceResolution: true +// @allowJs: true + +// @filename: /root/import/foo.ts +export function foo() {} + +// @filename: /root/client/bar.js +export function bar() {} + +// @filename: /root/src/a.ts +import { foo } from "/import/foo"; +import { bar } from "/client/bar"; + +// @filename: /root/tsconfig.json +{ + "compilerOptions": { + "baseUrl": ".", + "ignoreDeprecations": "6.0", + "paths": { + "/client/*": ["./client/*"], + "/import/*": ["./import/*"] + }, + "allowJs": true, + "outDir": "bin" + } +} diff --git a/tests/cases/compiler/pathMappingBasedModuleResolution_rootImport_aliasWithRoot_realRootFile.ts b/tests/cases/compiler/pathMappingBasedModuleResolution_rootImport_aliasWithRoot_realRootFile.ts index e45a25b1e11..3b09b7b8eae 100644 --- a/tests/cases/compiler/pathMappingBasedModuleResolution_rootImport_aliasWithRoot_realRootFile.ts +++ b/tests/cases/compiler/pathMappingBasedModuleResolution_rootImport_aliasWithRoot_realRootFile.ts @@ -1,25 +1,26 @@ -// @noImplicitReferences: true -// @traceResolution: true -// @allowJs: true - -// @filename: /foo.ts -export function foo() {} - -// @filename: /bar.js -export function bar() {} - -// @filename: /root/a.ts -import { foo } from "/foo"; -import { bar } from "/bar"; - -// @filename: /root/tsconfig.json -{ - "compilerOptions": { - "baseUrl": ".", - "paths": { - "/*": ["./src/*"] - }, - "allowJs": true, - "outDir": "bin" - } -} +// @noImplicitReferences: true +// @traceResolution: true +// @allowJs: true + +// @filename: /foo.ts +export function foo() {} + +// @filename: /bar.js +export function bar() {} + +// @filename: /root/a.ts +import { foo } from "/foo"; +import { bar } from "/bar"; + +// @filename: /root/tsconfig.json +{ + "compilerOptions": { + "baseUrl": ".", + "ignoreDeprecations": "6.0", + "paths": { + "/*": ["./src/*"] + }, + "allowJs": true, + "outDir": "bin" + } +} diff --git a/tests/cases/compiler/pathMappingBasedModuleResolution_rootImport_noAliasWithRoot.ts b/tests/cases/compiler/pathMappingBasedModuleResolution_rootImport_noAliasWithRoot.ts index d05ea12b257..17e2b4fa45f 100644 --- a/tests/cases/compiler/pathMappingBasedModuleResolution_rootImport_noAliasWithRoot.ts +++ b/tests/cases/compiler/pathMappingBasedModuleResolution_rootImport_noAliasWithRoot.ts @@ -1,25 +1,26 @@ -// @noImplicitReferences: true -// @traceResolution: true -// @allowJs: true - -// @filename: /root/src/foo.ts -export function foo() {} - -// @filename: /root/src/bar.js -export function bar() {} - -// @filename: /root/a.ts -import { foo } from "/foo"; -import { bar } from "/bar"; - -// @filename: /root/tsconfig.json -{ - "compilerOptions": { - "baseUrl": ".", - "paths": { - "*": ["./src/*"] - }, - "allowJs": true, - "outDir": "bin" - } -} +// @noImplicitReferences: true +// @traceResolution: true +// @allowJs: true + +// @filename: /root/src/foo.ts +export function foo() {} + +// @filename: /root/src/bar.js +export function bar() {} + +// @filename: /root/a.ts +import { foo } from "/foo"; +import { bar } from "/bar"; + +// @filename: /root/tsconfig.json +{ + "compilerOptions": { + "baseUrl": ".", + "ignoreDeprecations": "6.0", + "paths": { + "*": ["./src/*"] + }, + "allowJs": true, + "outDir": "bin" + } +} diff --git a/tests/cases/compiler/pathMappingBasedModuleResolution_rootImport_noAliasWithRoot_realRootFile.ts b/tests/cases/compiler/pathMappingBasedModuleResolution_rootImport_noAliasWithRoot_realRootFile.ts index eb552c73c82..2f1999e007e 100644 --- a/tests/cases/compiler/pathMappingBasedModuleResolution_rootImport_noAliasWithRoot_realRootFile.ts +++ b/tests/cases/compiler/pathMappingBasedModuleResolution_rootImport_noAliasWithRoot_realRootFile.ts @@ -1,25 +1,26 @@ -// @noImplicitReferences: true -// @traceResolution: true -// @allowJs: true - -// @filename: /foo.ts -export function foo() {} - -// @filename: /bar.js -export function bar() {} - -// @filename: /root/a.ts -import { foo } from "/foo"; -import { bar } from "/bar"; - -// @filename: /root/tsconfig.json -{ - "compilerOptions": { - "baseUrl": ".", - "paths": { - "*": ["./src/*"] - }, - "allowJs": true, - "outDir": "bin" - } -} +// @noImplicitReferences: true +// @traceResolution: true +// @allowJs: true + +// @filename: /foo.ts +export function foo() {} + +// @filename: /bar.js +export function bar() {} + +// @filename: /root/a.ts +import { foo } from "/foo"; +import { bar } from "/bar"; + +// @filename: /root/tsconfig.json +{ + "compilerOptions": { + "baseUrl": ".", + "ignoreDeprecations": "6.0", + "paths": { + "*": ["./src/*"] + }, + "allowJs": true, + "outDir": "bin" + } +} diff --git a/tests/cases/compiler/pathMappingBasedModuleResolution_withExtension.ts b/tests/cases/compiler/pathMappingBasedModuleResolution_withExtension.ts index e40c67e4ea3..8d96d5229de 100644 --- a/tests/cases/compiler/pathMappingBasedModuleResolution_withExtension.ts +++ b/tests/cases/compiler/pathMappingBasedModuleResolution_withExtension.ts @@ -1,26 +1,27 @@ -// @noImplicitReferences: true -// @traceResolution: true -// @allowJs: true - -// @Filename: /foo/foo.ts -export function foo() {} - -// @Filename: /bar/bar.js -export function bar() {} - -// @Filename: /a.ts -import { foo } from "foo"; -import { bar } from "bar"; - -// @Filename: /tsconfig.json -{ - "compilerOptions": { - "baseUrl": ".", - "paths": { - "foo": ["foo/foo.ts"], - "bar": ["bar/bar.js"] - }, - "allowJs": true, - "outDir": "bin" - } -} +// @noImplicitReferences: true +// @traceResolution: true +// @allowJs: true + +// @Filename: /foo/foo.ts +export function foo() {} + +// @Filename: /bar/bar.js +export function bar() {} + +// @Filename: /a.ts +import { foo } from "foo"; +import { bar } from "bar"; + +// @Filename: /tsconfig.json +{ + "compilerOptions": { + "baseUrl": ".", + "ignoreDeprecations": "6.0", + "paths": { + "foo": ["foo/foo.ts"], + "bar": ["bar/bar.js"] + }, + "allowJs": true, + "outDir": "bin" + } +} diff --git a/tests/cases/compiler/pathMappingBasedModuleResolution_withExtensionInName.ts b/tests/cases/compiler/pathMappingBasedModuleResolution_withExtensionInName.ts index 675003fe142..fceab3d90ba 100644 --- a/tests/cases/compiler/pathMappingBasedModuleResolution_withExtensionInName.ts +++ b/tests/cases/compiler/pathMappingBasedModuleResolution_withExtensionInName.ts @@ -1,23 +1,24 @@ -// @traceResolution: true -// @module: commonjs -// @noImplicitReferences: true - -// @filename: /tsconfig.json -{ - "compilerOptions": { - "baseUrl": ".", - "paths": { - "*": ["foo/*"] - } - } -} - -// @filename: /foo/zone.js/index.d.ts -export const x: number; - -// @filename: /foo/zone.tsx/index.d.ts -export const y: number; - -// @filename: /a.ts -import { x } from "zone.js"; -import { y } from "zone.tsx"; +// @traceResolution: true +// @module: commonjs +// @noImplicitReferences: true + +// @filename: /tsconfig.json +{ + "compilerOptions": { + "baseUrl": ".", + "ignoreDeprecations": "6.0", + "paths": { + "*": ["foo/*"] + } + } +} + +// @filename: /foo/zone.js/index.d.ts +export const x: number; + +// @filename: /foo/zone.tsx/index.d.ts +export const y: number; + +// @filename: /a.ts +import { x } from "zone.js"; +import { y } from "zone.tsx"; diff --git a/tests/cases/compiler/pathMappingBasedModuleResolution_withExtension_MapedToNodeModules.ts b/tests/cases/compiler/pathMappingBasedModuleResolution_withExtension_MapedToNodeModules.ts index 99e4070ff8a..8671a98e05e 100644 --- a/tests/cases/compiler/pathMappingBasedModuleResolution_withExtension_MapedToNodeModules.ts +++ b/tests/cases/compiler/pathMappingBasedModuleResolution_withExtension_MapedToNodeModules.ts @@ -1,23 +1,24 @@ -// @noImplicitReferences: true -// @traceResolution: true -// @allowJs: true -// @esModuleInterop: true -// @fullEmitPaths: true - -// @Filename: /node_modules/foo/bar/foobar.js -module.exports = { a: 10 }; - -// @Filename: /a.ts -import foobar from "foo/bar/foobar.js"; - -// @Filename: /tsconfig.json -{ - "compilerOptions": { - "baseUrl": ".", - "paths": { - "*": ["node_modules/*", "src/types"] - }, - "allowJs": true, - "outDir": "bin" - } -} +// @noImplicitReferences: true +// @traceResolution: true +// @allowJs: true +// @esModuleInterop: true +// @fullEmitPaths: true + +// @Filename: /node_modules/foo/bar/foobar.js +module.exports = { a: 10 }; + +// @Filename: /a.ts +import foobar from "foo/bar/foobar.js"; + +// @Filename: /tsconfig.json +{ + "compilerOptions": { + "baseUrl": ".", + "ignoreDeprecations": "6.0", + "paths": { + "*": ["node_modules/*", "src/types"] + }, + "allowJs": true, + "outDir": "bin" + } +} diff --git a/tests/cases/compiler/pathMappingBasedModuleResolution_withExtension_failedLookup.ts b/tests/cases/compiler/pathMappingBasedModuleResolution_withExtension_failedLookup.ts index a983b6c4825..d38d788de78 100644 --- a/tests/cases/compiler/pathMappingBasedModuleResolution_withExtension_failedLookup.ts +++ b/tests/cases/compiler/pathMappingBasedModuleResolution_withExtension_failedLookup.ts @@ -1,15 +1,16 @@ -// @noImplicitReferences: true -// @traceResolution: true - -// @Filename: /a.ts -import { foo } from "foo"; - -// @Filename: /tsconfig.json -{ - "compilerOptions": { - "baseUrl": ".", - "paths": { - "foo": ["foo/foo.ts"] - } - } -} +// @noImplicitReferences: true +// @traceResolution: true + +// @Filename: /a.ts +import { foo } from "foo"; + +// @Filename: /tsconfig.json +{ + "compilerOptions": { + "baseUrl": ".", + "ignoreDeprecations": "6.0", + "paths": { + "foo": ["foo/foo.ts"] + } + } +}