diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index f3e482be32ab2..62f4bf4829b18 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -4917,6 +4917,10 @@ "category": "Message", "code": 6163 }, + "Skipping module '{0}' that looks like an absolute URI, target file types: {1}.": { + "category": "Message", + "code": 6164 + }, "Do not truncate error messages.": { "category": "Message", "code": 6165 diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index c860198172c30..35dcc0d4e95a8 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -1795,6 +1795,12 @@ function nodeModuleNameResolverWorker(features: NodeResolutionFeatures, moduleNa resolved = loadModuleFromSelfNameReference(extensions, moduleName, containingDirectory, state, cache, redirectedReference); } if (!resolved) { + if (moduleName.indexOf(":") > -1) { + if (traceEnabled) { + trace(host, Diagnostics.Skipping_module_0_that_looks_like_an_absolute_URI_target_file_types_Colon_1, moduleName, formatExtensions(extensions)); + } + return undefined; + } if (traceEnabled) { trace(host, Diagnostics.Loading_module_0_from_node_modules_folder_target_file_types_Colon_1, moduleName, formatExtensions(extensions)); } @@ -2896,7 +2902,7 @@ function loadModuleFromSpecificNodeModulesDirectory(extensions: Extensions, modu const loader: ResolutionKindSpecificLoader = (extensions, candidate, onlyRecordFailures, state) => { let pathAndExtension = - loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) || + (rest || !(state.features & NodeResolutionFeatures.EsmMode)) && loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) || loadNodeModuleFromDirectoryWorker( extensions, candidate, @@ -2937,7 +2943,6 @@ function loadModuleFromSpecificNodeModulesDirectory(extensions: Extensions, modu return fromPaths.value; } } - return loader(extensions, candidate, !nodeModulesDirectoryExists, state); } diff --git a/src/testRunner/unittests/tsserver/configuredProjects.ts b/src/testRunner/unittests/tsserver/configuredProjects.ts index bd461d7056e41..a496d5612849c 100644 --- a/src/testRunner/unittests/tsserver/configuredProjects.ts +++ b/src/testRunner/unittests/tsserver/configuredProjects.ts @@ -1139,4 +1139,4 @@ describe("unittests:: tsserver:: ConfiguredProjects:: when reading tsconfig file baselineTsserverLogs("configuredProjects", "should be tolerated without crashing the server when reading tsconfig file fails", session); }); -}); \ No newline at end of file +}); diff --git a/tests/baselines/reference/cachedModuleResolution1.js b/tests/baselines/reference/cachedModuleResolution1.js index 2a8211b1e600f..14081ac41923a 100644 --- a/tests/baselines/reference/cachedModuleResolution1.js +++ b/tests/baselines/reference/cachedModuleResolution1.js @@ -7,7 +7,8 @@ export declare let x: number import {x} from "foo"; //// [lib.ts] -import {x} from "foo"; +import {x} from "foo"; + //// [app.js] "use strict"; diff --git a/tests/baselines/reference/cachedModuleResolution5.js b/tests/baselines/reference/cachedModuleResolution5.js index dee5a46122c61..dfabec484bd12 100644 --- a/tests/baselines/reference/cachedModuleResolution5.js +++ b/tests/baselines/reference/cachedModuleResolution5.js @@ -7,7 +7,8 @@ export declare let x: number import {x} from "foo"; //// [lib.ts] -import {x} from "foo"; +import {x} from "foo"; + //// [app.js] "use strict"; diff --git a/tests/baselines/reference/nodeColonModuleResolution.js b/tests/baselines/reference/nodeColonModuleResolution.js new file mode 100644 index 0000000000000..40ba92a641ebd --- /dev/null +++ b/tests/baselines/reference/nodeColonModuleResolution.js @@ -0,0 +1,31 @@ +//// [tests/cases/compiler/nodeColonModuleResolution.ts] //// + +//// [ph.d.ts] +declare module 'ph' { + namespace constants { + const NODE_PERFORMANCE_GC_MAJOR: number; + const NODE_PERFORMANCE_GC_MINOR: number; + const NODE_PERFORMANCE_GC_INCREMENTAL: number; + const NODE_PERFORMANCE_GC_WEAKCB: number; + const NODE_PERFORMANCE_GC_FLAGS_NO: number; + const NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED: number; + const NODE_PERFORMANCE_GC_FLAGS_FORCED: number; + const NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING: number; + const NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE: number; + const NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY: number; + const NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE: number; + } +} +declare module 'node:ph' { + export * from 'ph'; +} +//// [main.ts] +import * as ph from 'node:ph' +console.log(ph.constants.NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE) + + +//// [main.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var ph = require("node:ph"); +console.log(ph.constants.NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE); diff --git a/tests/baselines/reference/nodeColonModuleResolution.symbols b/tests/baselines/reference/nodeColonModuleResolution.symbols new file mode 100644 index 0000000000000..6f266393c7905 --- /dev/null +++ b/tests/baselines/reference/nodeColonModuleResolution.symbols @@ -0,0 +1,60 @@ +=== /a/b/node_modules/@types/node/ph.d.ts === +declare module 'ph' { +>'ph' : Symbol("ph", Decl(ph.d.ts, 0, 0)) + + namespace constants { +>constants : Symbol(constants, Decl(ph.d.ts, 0, 21)) + + const NODE_PERFORMANCE_GC_MAJOR: number; +>NODE_PERFORMANCE_GC_MAJOR : Symbol(NODE_PERFORMANCE_GC_MAJOR, Decl(ph.d.ts, 2, 13)) + + const NODE_PERFORMANCE_GC_MINOR: number; +>NODE_PERFORMANCE_GC_MINOR : Symbol(NODE_PERFORMANCE_GC_MINOR, Decl(ph.d.ts, 3, 13)) + + const NODE_PERFORMANCE_GC_INCREMENTAL: number; +>NODE_PERFORMANCE_GC_INCREMENTAL : Symbol(NODE_PERFORMANCE_GC_INCREMENTAL, Decl(ph.d.ts, 4, 13)) + + const NODE_PERFORMANCE_GC_WEAKCB: number; +>NODE_PERFORMANCE_GC_WEAKCB : Symbol(NODE_PERFORMANCE_GC_WEAKCB, Decl(ph.d.ts, 5, 13)) + + const NODE_PERFORMANCE_GC_FLAGS_NO: number; +>NODE_PERFORMANCE_GC_FLAGS_NO : Symbol(NODE_PERFORMANCE_GC_FLAGS_NO, Decl(ph.d.ts, 6, 13)) + + const NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED: number; +>NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED : Symbol(NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED, Decl(ph.d.ts, 7, 13)) + + const NODE_PERFORMANCE_GC_FLAGS_FORCED: number; +>NODE_PERFORMANCE_GC_FLAGS_FORCED : Symbol(NODE_PERFORMANCE_GC_FLAGS_FORCED, Decl(ph.d.ts, 8, 13)) + + const NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING: number; +>NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING : Symbol(NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING, Decl(ph.d.ts, 9, 13)) + + const NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE: number; +>NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE : Symbol(NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE, Decl(ph.d.ts, 10, 13)) + + const NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY: number; +>NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY : Symbol(NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY, Decl(ph.d.ts, 11, 13)) + + const NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE: number; +>NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE : Symbol(NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE, Decl(ph.d.ts, 12, 13)) + } +} +declare module 'node:ph' { +>'node:ph' : Symbol("node:ph", Decl(ph.d.ts, 14, 1)) + + export * from 'ph'; +} +=== /a/b/main.ts === +import * as ph from 'node:ph' +>ph : Symbol(ph, Decl(main.ts, 0, 6)) + +console.log(ph.constants.NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE) +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>ph.constants.NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE : Symbol(ph.constants.NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE, Decl(ph.d.ts, 10, 13)) +>ph.constants : Symbol(ph.constants, Decl(ph.d.ts, 0, 21)) +>ph : Symbol(ph, Decl(main.ts, 0, 6)) +>constants : Symbol(ph.constants, Decl(ph.d.ts, 0, 21)) +>NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE : Symbol(ph.constants.NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE, Decl(ph.d.ts, 10, 13)) + diff --git a/tests/baselines/reference/nodeColonModuleResolution.trace.json b/tests/baselines/reference/nodeColonModuleResolution.trace.json new file mode 100644 index 0000000000000..be7ef45752c4c --- /dev/null +++ b/tests/baselines/reference/nodeColonModuleResolution.trace.json @@ -0,0 +1,73 @@ +[ + "======== Resolving module 'node:ph' from '/a/b/main.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Skipping module 'node:ph' that looks like an absolute URI, target file types: TypeScript, Declaration.", + "Skipping module 'node:ph' that looks like an absolute URI, target file types: JavaScript.", + "======== Module name 'node:ph' was not resolved. ========", + "======== Resolving module '@typescript/lib-es5' from '__lib_node_modules_lookup_lib.es5.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Directory 'node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es5'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es5'", + "Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: JavaScript.", + "Directory 'node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es5' was not resolved. ========", + "======== Resolving module '@typescript/lib-decorators' from '__lib_node_modules_lookup_lib.decorators.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Directory 'node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators'", + "Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: JavaScript.", + "Directory 'node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-decorators' was not resolved. ========", + "======== Resolving module '@typescript/lib-decorators/legacy' from '__lib_node_modules_lookup_lib.decorators.legacy.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Directory 'node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators/legacy'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators/legacy'", + "Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: JavaScript.", + "Directory 'node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-decorators/legacy' was not resolved. ========", + "======== Resolving module '@typescript/lib-dom' from '__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Directory 'node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-dom'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-dom'", + "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: JavaScript.", + "Directory 'node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-dom' was not resolved. ========", + "======== Resolving module '@typescript/lib-webworker/importscripts' from '__lib_node_modules_lookup_lib.webworker.importscripts.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Directory 'node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-webworker/importscripts'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-webworker/importscripts'", + "Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: JavaScript.", + "Directory 'node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-webworker/importscripts' was not resolved. ========", + "======== Resolving module '@typescript/lib-scripthost' from '__lib_node_modules_lookup_lib.scripthost.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Directory 'node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-scripthost'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-scripthost'", + "Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: JavaScript.", + "Directory 'node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-scripthost' was not resolved. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/nodeColonModuleResolution.types b/tests/baselines/reference/nodeColonModuleResolution.types new file mode 100644 index 0000000000000..ee664556aaa66 --- /dev/null +++ b/tests/baselines/reference/nodeColonModuleResolution.types @@ -0,0 +1,61 @@ +=== /a/b/node_modules/@types/node/ph.d.ts === +declare module 'ph' { +>'ph' : typeof import("ph") + + namespace constants { +>constants : typeof constants + + const NODE_PERFORMANCE_GC_MAJOR: number; +>NODE_PERFORMANCE_GC_MAJOR : number + + const NODE_PERFORMANCE_GC_MINOR: number; +>NODE_PERFORMANCE_GC_MINOR : number + + const NODE_PERFORMANCE_GC_INCREMENTAL: number; +>NODE_PERFORMANCE_GC_INCREMENTAL : number + + const NODE_PERFORMANCE_GC_WEAKCB: number; +>NODE_PERFORMANCE_GC_WEAKCB : number + + const NODE_PERFORMANCE_GC_FLAGS_NO: number; +>NODE_PERFORMANCE_GC_FLAGS_NO : number + + const NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED: number; +>NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED : number + + const NODE_PERFORMANCE_GC_FLAGS_FORCED: number; +>NODE_PERFORMANCE_GC_FLAGS_FORCED : number + + const NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING: number; +>NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING : number + + const NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE: number; +>NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE : number + + const NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY: number; +>NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY : number + + const NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE: number; +>NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE : number + } +} +declare module 'node:ph' { +>'node:ph' : typeof import("node:ph") + + export * from 'ph'; +} +=== /a/b/main.ts === +import * as ph from 'node:ph' +>ph : typeof ph + +console.log(ph.constants.NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE) +>console.log(ph.constants.NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE) : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>ph.constants.NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE : number +>ph.constants : typeof ph.constants +>ph : typeof ph +>constants : typeof ph.constants +>NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE : number + diff --git a/tests/baselines/reference/nodeColonModuleResolution2.js b/tests/baselines/reference/nodeColonModuleResolution2.js new file mode 100644 index 0000000000000..bbf0729e89776 --- /dev/null +++ b/tests/baselines/reference/nodeColonModuleResolution2.js @@ -0,0 +1,26 @@ +//// [tests/cases/compiler/nodeColonModuleResolution2.ts] //// + +//// [index.d.ts] +export namespace constants { + const NODE_PERFORMANCE_GC_MAJOR: number; + const NODE_PERFORMANCE_GC_MINOR: number; + const NODE_PERFORMANCE_GC_INCREMENTAL: number; + const NODE_PERFORMANCE_GC_WEAKCB: number; + const NODE_PERFORMANCE_GC_FLAGS_NO: number; + const NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED: number; + const NODE_PERFORMANCE_GC_FLAGS_FORCED: number; + const NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING: number; + const NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE: number; + const NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY: number; + const NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE: number; +} +//// [main.ts] +import * as ph from 'fake:thing' +console.log(ph.constants.NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE) + + +//// [main.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var ph = require("fake:thing"); +console.log(ph.constants.NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE); diff --git a/tests/baselines/reference/nodeColonModuleResolution2.symbols b/tests/baselines/reference/nodeColonModuleResolution2.symbols new file mode 100644 index 0000000000000..44c3e2407fbd3 --- /dev/null +++ b/tests/baselines/reference/nodeColonModuleResolution2.symbols @@ -0,0 +1,51 @@ +=== /a/b/node_modules/fake/thing/index.d.ts === +export namespace constants { +>constants : Symbol(constants, Decl(index.d.ts, 0, 0)) + + const NODE_PERFORMANCE_GC_MAJOR: number; +>NODE_PERFORMANCE_GC_MAJOR : Symbol(NODE_PERFORMANCE_GC_MAJOR, Decl(index.d.ts, 1, 9)) + + const NODE_PERFORMANCE_GC_MINOR: number; +>NODE_PERFORMANCE_GC_MINOR : Symbol(NODE_PERFORMANCE_GC_MINOR, Decl(index.d.ts, 2, 9)) + + const NODE_PERFORMANCE_GC_INCREMENTAL: number; +>NODE_PERFORMANCE_GC_INCREMENTAL : Symbol(NODE_PERFORMANCE_GC_INCREMENTAL, Decl(index.d.ts, 3, 9)) + + const NODE_PERFORMANCE_GC_WEAKCB: number; +>NODE_PERFORMANCE_GC_WEAKCB : Symbol(NODE_PERFORMANCE_GC_WEAKCB, Decl(index.d.ts, 4, 9)) + + const NODE_PERFORMANCE_GC_FLAGS_NO: number; +>NODE_PERFORMANCE_GC_FLAGS_NO : Symbol(NODE_PERFORMANCE_GC_FLAGS_NO, Decl(index.d.ts, 5, 9)) + + const NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED: number; +>NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED : Symbol(NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED, Decl(index.d.ts, 6, 9)) + + const NODE_PERFORMANCE_GC_FLAGS_FORCED: number; +>NODE_PERFORMANCE_GC_FLAGS_FORCED : Symbol(NODE_PERFORMANCE_GC_FLAGS_FORCED, Decl(index.d.ts, 7, 9)) + + const NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING: number; +>NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING : Symbol(NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING, Decl(index.d.ts, 8, 9)) + + const NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE: number; +>NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE : Symbol(NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE, Decl(index.d.ts, 9, 9)) + + const NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY: number; +>NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY : Symbol(NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY, Decl(index.d.ts, 10, 9)) + + const NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE: number; +>NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE : Symbol(NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE, Decl(index.d.ts, 11, 9)) +} +=== /a/b/main.ts === +import * as ph from 'fake:thing' +>ph : Symbol(ph, Decl(main.ts, 0, 6)) + +console.log(ph.constants.NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE) +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>ph.constants.NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE : Symbol(ph.constants.NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE, Decl(index.d.ts, 9, 9)) +>ph.constants : Symbol(ph.constants, Decl(index.d.ts, 0, 0)) +>ph : Symbol(ph, Decl(main.ts, 0, 6)) +>constants : Symbol(ph.constants, Decl(index.d.ts, 0, 0)) +>NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE : Symbol(ph.constants.NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE, Decl(index.d.ts, 9, 9)) + diff --git a/tests/baselines/reference/nodeColonModuleResolution2.trace.json b/tests/baselines/reference/nodeColonModuleResolution2.trace.json new file mode 100644 index 0000000000000..1d7602c8f6f93 --- /dev/null +++ b/tests/baselines/reference/nodeColonModuleResolution2.trace.json @@ -0,0 +1,95 @@ +[ + "======== Resolving module 'fake:thing' from '/a/b/main.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "'paths' option is specified, looking for a pattern to match module name 'fake:thing'.", + "Module name 'fake:thing', matched pattern 'fake:thing'.", + "Trying substitution './node_modules/fake/thing', candidate module location: './node_modules/fake/thing'.", + "Loading module as file / folder, candidate module location '/a/b/node_modules/fake/thing', target file types: TypeScript, Declaration.", + "File '/a/b/node_modules/fake/thing.ts' does not exist.", + "File '/a/b/node_modules/fake/thing.tsx' does not exist.", + "File '/a/b/node_modules/fake/thing.d.ts' does not exist.", + "File '/a/b/node_modules/fake/thing/package.json' does not exist.", + "File '/a/b/node_modules/fake/thing/index.ts' does not exist.", + "File '/a/b/node_modules/fake/thing/index.tsx' does not exist.", + "File '/a/b/node_modules/fake/thing/index.d.ts' exists - use it as a name resolution result.", + "Resolving real path for '/a/b/node_modules/fake/thing/index.d.ts', result '/a/b/node_modules/fake/thing/index.d.ts'.", + "======== Module name 'fake:thing' was successfully resolved to '/a/b/node_modules/fake/thing/index.d.ts'. ========", + "======== Resolving module '@typescript/lib-es5' from '/a/b/__lib_node_modules_lookup_lib.es5.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Directory '/a/b/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es5'", + "Directory '/a/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es5'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es5'", + "Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: JavaScript.", + "Directory '/a/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es5' was not resolved. ========", + "======== Resolving module '@typescript/lib-decorators' from '/a/b/__lib_node_modules_lookup_lib.decorators.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Directory '/a/b/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators'", + "Directory '/a/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators'", + "Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: JavaScript.", + "Directory '/a/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-decorators' was not resolved. ========", + "======== Resolving module '@typescript/lib-decorators/legacy' from '/a/b/__lib_node_modules_lookup_lib.decorators.legacy.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Directory '/a/b/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators/legacy'", + "Directory '/a/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators/legacy'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators/legacy'", + "Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: JavaScript.", + "Directory '/a/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-decorators/legacy' was not resolved. ========", + "======== Resolving module '@typescript/lib-dom' from '/a/b/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Directory '/a/b/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-dom'", + "Directory '/a/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-dom'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-dom'", + "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: JavaScript.", + "Directory '/a/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-dom' was not resolved. ========", + "======== Resolving module '@typescript/lib-webworker/importscripts' from '/a/b/__lib_node_modules_lookup_lib.webworker.importscripts.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Directory '/a/b/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-webworker/importscripts'", + "Directory '/a/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-webworker/importscripts'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-webworker/importscripts'", + "Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: JavaScript.", + "Directory '/a/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-webworker/importscripts' was not resolved. ========", + "======== Resolving module '@typescript/lib-scripthost' from '/a/b/__lib_node_modules_lookup_lib.scripthost.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Directory '/a/b/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-scripthost'", + "Directory '/a/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-scripthost'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-scripthost'", + "Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: JavaScript.", + "Directory '/a/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-scripthost' was not resolved. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/nodeColonModuleResolution2.types b/tests/baselines/reference/nodeColonModuleResolution2.types new file mode 100644 index 0000000000000..3a45690a68c2e --- /dev/null +++ b/tests/baselines/reference/nodeColonModuleResolution2.types @@ -0,0 +1,52 @@ +=== /a/b/node_modules/fake/thing/index.d.ts === +export namespace constants { +>constants : typeof constants + + const NODE_PERFORMANCE_GC_MAJOR: number; +>NODE_PERFORMANCE_GC_MAJOR : number + + const NODE_PERFORMANCE_GC_MINOR: number; +>NODE_PERFORMANCE_GC_MINOR : number + + const NODE_PERFORMANCE_GC_INCREMENTAL: number; +>NODE_PERFORMANCE_GC_INCREMENTAL : number + + const NODE_PERFORMANCE_GC_WEAKCB: number; +>NODE_PERFORMANCE_GC_WEAKCB : number + + const NODE_PERFORMANCE_GC_FLAGS_NO: number; +>NODE_PERFORMANCE_GC_FLAGS_NO : number + + const NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED: number; +>NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED : number + + const NODE_PERFORMANCE_GC_FLAGS_FORCED: number; +>NODE_PERFORMANCE_GC_FLAGS_FORCED : number + + const NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING: number; +>NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING : number + + const NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE: number; +>NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE : number + + const NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY: number; +>NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY : number + + const NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE: number; +>NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE : number +} +=== /a/b/main.ts === +import * as ph from 'fake:thing' +>ph : typeof ph + +console.log(ph.constants.NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE) +>console.log(ph.constants.NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE) : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>ph.constants.NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE : number +>ph.constants : typeof ph.constants +>ph : typeof ph +>constants : typeof ph.constants +>NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE : number + diff --git a/tests/baselines/reference/nodeNextModuleResolution1.errors.txt b/tests/baselines/reference/nodeNextModuleResolution1.errors.txt new file mode 100644 index 0000000000000..00bab93c4a854 --- /dev/null +++ b/tests/baselines/reference/nodeNextModuleResolution1.errors.txt @@ -0,0 +1,18 @@ +/a/b/c/d/e/app.ts(1,17): error TS2307: Cannot find module 'foo' or its corresponding type declarations. + + +==== /a/node_modules/foo.d.ts (0 errors) ==== + export declare let x: number + +==== /a/b/c/d/e/package.json (0 errors) ==== + { + "name": "e", + "version": "1.0.0", + "type": "module" + } +==== /a/b/c/d/e/app.ts (1 errors) ==== + import {x} from "foo"; + ~~~~~ +!!! error TS2307: Cannot find module 'foo' or its corresponding type declarations. + + \ No newline at end of file diff --git a/tests/baselines/reference/nodeNextModuleResolution1.js b/tests/baselines/reference/nodeNextModuleResolution1.js new file mode 100644 index 0000000000000..d76bd3acd7fb6 --- /dev/null +++ b/tests/baselines/reference/nodeNextModuleResolution1.js @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/nodeNextModuleResolution1.ts] //// + +//// [foo.d.ts] +export declare let x: number + +//// [package.json] +{ + "name": "e", + "version": "1.0.0", + "type": "module" +} +//// [app.ts] +import {x} from "foo"; + + + +//// [app.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/nodeNextModuleResolution1.symbols b/tests/baselines/reference/nodeNextModuleResolution1.symbols new file mode 100644 index 0000000000000..f8657910c2002 --- /dev/null +++ b/tests/baselines/reference/nodeNextModuleResolution1.symbols @@ -0,0 +1,9 @@ +=== /a/node_modules/foo.d.ts === +export declare let x: number +>x : Symbol(x, Decl(foo.d.ts, 0, 18)) + +=== /a/b/c/d/e/app.ts === +import {x} from "foo"; +>x : Symbol(x, Decl(app.ts, 0, 8)) + + diff --git a/tests/baselines/reference/nodeNextModuleResolution1.trace.json b/tests/baselines/reference/nodeNextModuleResolution1.trace.json new file mode 100644 index 0000000000000..9927ef6c30d11 --- /dev/null +++ b/tests/baselines/reference/nodeNextModuleResolution1.trace.json @@ -0,0 +1,103 @@ +[ + "File '/a/node_modules/package.json' does not exist.", + "File '/a/package.json' does not exist.", + "File '/package.json' does not exist.", + "Found 'package.json' at '/a/b/c/d/e/package.json'.", + "======== Resolving module 'foo' from '/a/b/c/d/e/app.ts'. ========", + "Explicitly specified module resolution kind: 'NodeNext'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", + "File '/a/b/c/d/e/package.json' exists according to earlier cached lookups.", + "Loading module 'foo' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", + "Directory '/a/b/c/d/e/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/b/c/d/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/b/c/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/b/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/node_modules/@types' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/b/c/d/e/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/b/c/d/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/b/c/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/b/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name 'foo' was not resolved. ========", + "File 'package.json' does not exist.", + "File '/package.json' does not exist according to earlier cached lookups.", + "======== Resolving module '@typescript/lib-es5' from '__lib_node_modules_lookup_lib.es5.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Directory 'node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es5'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es5'", + "Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: JavaScript.", + "Directory 'node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es5' was not resolved. ========", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "======== Resolving module '@typescript/lib-decorators' from '__lib_node_modules_lookup_lib.decorators.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Directory 'node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators'", + "Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: JavaScript.", + "Directory 'node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-decorators' was not resolved. ========", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "======== Resolving module '@typescript/lib-decorators/legacy' from '__lib_node_modules_lookup_lib.decorators.legacy.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Directory 'node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators/legacy'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators/legacy'", + "Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: JavaScript.", + "Directory 'node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-decorators/legacy' was not resolved. ========", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "======== Resolving module '@typescript/lib-dom' from '__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Directory 'node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-dom'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-dom'", + "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: JavaScript.", + "Directory 'node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-dom' was not resolved. ========", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "======== Resolving module '@typescript/lib-webworker/importscripts' from '__lib_node_modules_lookup_lib.webworker.importscripts.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Directory 'node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-webworker/importscripts'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-webworker/importscripts'", + "Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: JavaScript.", + "Directory 'node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-webworker/importscripts' was not resolved. ========", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "======== Resolving module '@typescript/lib-scripthost' from '__lib_node_modules_lookup_lib.scripthost.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Directory 'node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-scripthost'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-scripthost'", + "Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: JavaScript.", + "Directory 'node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-scripthost' was not resolved. ========", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups." +] \ No newline at end of file diff --git a/tests/baselines/reference/nodeNextModuleResolution1.types b/tests/baselines/reference/nodeNextModuleResolution1.types new file mode 100644 index 0000000000000..374248db15127 --- /dev/null +++ b/tests/baselines/reference/nodeNextModuleResolution1.types @@ -0,0 +1,9 @@ +=== /a/node_modules/foo.d.ts === +export declare let x: number +>x : number + +=== /a/b/c/d/e/app.ts === +import {x} from "foo"; +>x : any + + diff --git a/tests/baselines/reference/nodeNextModuleResolution2.js b/tests/baselines/reference/nodeNextModuleResolution2.js new file mode 100644 index 0000000000000..19475675a566b --- /dev/null +++ b/tests/baselines/reference/nodeNextModuleResolution2.js @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/nodeNextModuleResolution2.ts] //// + +//// [index.d.ts] +export declare let x: number +//// [package.json] +{ + "name": "foo", + "type": "module", + "exports": { + ".": "./index.d.ts" + } +} + +//// [app.mts] +import {x} from "foo"; + + +//// [app.mjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/nodeNextModuleResolution2.symbols b/tests/baselines/reference/nodeNextModuleResolution2.symbols new file mode 100644 index 0000000000000..e229b0e38e03b --- /dev/null +++ b/tests/baselines/reference/nodeNextModuleResolution2.symbols @@ -0,0 +1,8 @@ +=== /a/node_modules/foo/index.d.ts === +export declare let x: number +>x : Symbol(x, Decl(index.d.ts, 0, 18)) + +=== /a/b/c/d/e/app.mts === +import {x} from "foo"; +>x : Symbol(x, Decl(app.mts, 0, 8)) + diff --git a/tests/baselines/reference/nodeNextModuleResolution2.trace.json b/tests/baselines/reference/nodeNextModuleResolution2.trace.json new file mode 100644 index 0000000000000..79fe344e8e784 --- /dev/null +++ b/tests/baselines/reference/nodeNextModuleResolution2.trace.json @@ -0,0 +1,102 @@ +[ + "Found 'package.json' at '/a/node_modules/foo/package.json'.", + "======== Resolving module 'foo' from '/a/b/c/d/e/app.mts'. ========", + "Explicitly specified module resolution kind: 'NodeNext'.", + "Resolving in ESM mode with conditions 'import', 'types', 'node'.", + "File '/a/b/c/d/e/package.json' does not exist.", + "File '/a/b/c/d/package.json' does not exist.", + "File '/a/b/c/package.json' does not exist.", + "File '/a/b/package.json' does not exist.", + "File '/a/package.json' does not exist.", + "File '/package.json' does not exist.", + "Loading module 'foo' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.", + "Directory '/a/b/c/d/e/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/b/c/d/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/b/c/node_modules' does not exist, skipping all lookups in it.", + "Directory '/a/b/node_modules' does not exist, skipping all lookups in it.", + "File '/a/node_modules/foo/package.json' exists according to earlier cached lookups.", + "Using 'exports' subpath '.' with target './index.d.ts'.", + "File '/a/node_modules/foo/index.d.ts' exists - use it as a name resolution result.", + "Resolving real path for '/a/node_modules/foo/index.d.ts', result '/a/node_modules/foo/index.d.ts'.", + "======== Module name 'foo' was successfully resolved to '/a/node_modules/foo/index.d.ts'. ========", + "File 'package.json' does not exist.", + "File '/package.json' does not exist according to earlier cached lookups.", + "======== Resolving module '@typescript/lib-es5' from '__lib_node_modules_lookup_lib.es5.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Directory 'node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es5'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es5'", + "Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: JavaScript.", + "Directory 'node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es5' was not resolved. ========", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "======== Resolving module '@typescript/lib-decorators' from '__lib_node_modules_lookup_lib.decorators.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Directory 'node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators'", + "Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: JavaScript.", + "Directory 'node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-decorators' was not resolved. ========", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "======== Resolving module '@typescript/lib-decorators/legacy' from '__lib_node_modules_lookup_lib.decorators.legacy.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Directory 'node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators/legacy'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators/legacy'", + "Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: JavaScript.", + "Directory 'node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-decorators/legacy' was not resolved. ========", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "======== Resolving module '@typescript/lib-dom' from '__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Directory 'node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-dom'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-dom'", + "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: JavaScript.", + "Directory 'node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-dom' was not resolved. ========", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "======== Resolving module '@typescript/lib-webworker/importscripts' from '__lib_node_modules_lookup_lib.webworker.importscripts.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Directory 'node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-webworker/importscripts'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-webworker/importscripts'", + "Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: JavaScript.", + "Directory 'node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-webworker/importscripts' was not resolved. ========", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "======== Resolving module '@typescript/lib-scripthost' from '__lib_node_modules_lookup_lib.scripthost.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Directory 'node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-scripthost'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-scripthost'", + "Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: JavaScript.", + "Directory 'node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-scripthost' was not resolved. ========", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups." +] \ No newline at end of file diff --git a/tests/baselines/reference/nodeNextModuleResolution2.types b/tests/baselines/reference/nodeNextModuleResolution2.types new file mode 100644 index 0000000000000..9e8e5f87ef09b --- /dev/null +++ b/tests/baselines/reference/nodeNextModuleResolution2.types @@ -0,0 +1,8 @@ +=== /a/node_modules/foo/index.d.ts === +export declare let x: number +>x : number + +=== /a/b/c/d/e/app.mts === +import {x} from "foo"; +>x : number + diff --git a/tests/baselines/reference/nodeResolution2.js b/tests/baselines/reference/nodeResolution2.js index 842cfc66c1ef8..1c3058a1e0ea6 100644 --- a/tests/baselines/reference/nodeResolution2.js +++ b/tests/baselines/reference/nodeResolution2.js @@ -4,7 +4,8 @@ export var x: number; //// [b.ts] -import y = require("a"); +import y = require("a"); + //// [b.js] "use strict"; diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution5_node.js b/tests/baselines/reference/pathMappingBasedModuleResolution5_node.js index c1865e7c6c8b8..07d19ef51db95 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution5_node.js +++ b/tests/baselines/reference/pathMappingBasedModuleResolution5_node.js @@ -23,7 +23,8 @@ export var y = 1; export var z: number; //// [file4.ts] -export var z1 = 1; +export var z1 = 1; + //// [file1.js] "use strict"; diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution_rootImport_aliasWithRoot_differentRootTypes.trace.json b/tests/baselines/reference/pathMappingBasedModuleResolution_rootImport_aliasWithRoot_differentRootTypes.trace.json index d5f38b835556e..fc09abc422fea 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution_rootImport_aliasWithRoot_differentRootTypes.trace.json +++ b/tests/baselines/reference/pathMappingBasedModuleResolution_rootImport_aliasWithRoot_differentRootTypes.trace.json @@ -167,9 +167,7 @@ "File '/root/src/bar.tsx' does not exist.", "File '/root/src/bar.d.ts' does not exist.", "Directory '/root/src/bar' does not exist, skipping all lookups in it.", - "Loading module 'file:///bar' from 'node_modules' folder, target file types: TypeScript, Declaration.", - "Directory '/root/node_modules' does not exist, skipping all lookups in it.", - "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Skipping module 'file:///bar' that looks like an absolute URI, target file types: TypeScript, Declaration.", "'baseUrl' option is set to '/root', using this value to resolve non-relative module name 'file:///bar'.", "'paths' option is specified, looking for a pattern to match module name 'file:///bar'.", "Module name 'file:///bar', matched pattern 'file:///*'.", @@ -197,9 +195,7 @@ "File '/root/src/bar.tsx' does not exist.", "File '/root/src/bar.d.ts' does not exist.", "Directory '/root/src/bar' does not exist, skipping all lookups in it.", - "Loading module 'file://c:/bar' from 'node_modules' folder, target file types: TypeScript, Declaration.", - "Directory '/root/node_modules' does not exist, skipping all lookups in it.", - "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Skipping module 'file://c:/bar' that looks like an absolute URI, target file types: TypeScript, Declaration.", "'baseUrl' option is set to '/root', using this value to resolve non-relative module name 'file://c:/bar'.", "'paths' option is specified, looking for a pattern to match module name 'file://c:/bar'.", "Module name 'file://c:/bar', matched pattern 'file://c:/*'.", @@ -227,9 +223,7 @@ "File '/root/src/bar.tsx' does not exist.", "File '/root/src/bar.d.ts' does not exist.", "Directory '/root/src/bar' does not exist, skipping all lookups in it.", - "Loading module 'file://server/bar' from 'node_modules' folder, target file types: TypeScript, Declaration.", - "Directory '/root/node_modules' does not exist, skipping all lookups in it.", - "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Skipping module 'file://server/bar' that looks like an absolute URI, target file types: TypeScript, Declaration.", "'baseUrl' option is set to '/root', using this value to resolve non-relative module name 'file://server/bar'.", "'paths' option is specified, looking for a pattern to match module name 'file://server/bar'.", "Module name 'file://server/bar', matched pattern 'file://server/*'.", @@ -257,9 +251,7 @@ "File '/root/src/bar.tsx' does not exist.", "File '/root/src/bar.d.ts' does not exist.", "Directory '/root/src/bar' does not exist, skipping all lookups in it.", - "Loading module 'http://server/bar' from 'node_modules' folder, target file types: TypeScript, Declaration.", - "Directory '/root/node_modules' does not exist, skipping all lookups in it.", - "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Skipping module 'http://server/bar' that looks like an absolute URI, target file types: TypeScript, Declaration.", "'baseUrl' option is set to '/root', using this value to resolve non-relative module name 'http://server/bar'.", "'paths' option is specified, looking for a pattern to match module name 'http://server/bar'.", "Module name 'http://server/bar', matched pattern 'http://server/*'.", diff --git a/tests/baselines/reference/requireOfJsonFileNonRelative.js b/tests/baselines/reference/requireOfJsonFileNonRelative.js index c5827a943a7ab..e7a63e452443a 100644 --- a/tests/baselines/reference/requireOfJsonFileNonRelative.js +++ b/tests/baselines/reference/requireOfJsonFileNonRelative.js @@ -19,7 +19,8 @@ if (x) { { "a": true, "b": "hello" -} +} + //// [out/file1.js] "use strict"; diff --git a/tests/baselines/reference/requireOfJsonFileNonRelative.symbols b/tests/baselines/reference/requireOfJsonFileNonRelative.symbols index 4a38120620494..006cedc79272c 100644 --- a/tests/baselines/reference/requireOfJsonFileNonRelative.symbols +++ b/tests/baselines/reference/requireOfJsonFileNonRelative.symbols @@ -45,3 +45,4 @@ if (x) { "b": "hello" >"b" : Symbol("b", Decl(c.json, 1, 14)) } + diff --git a/tests/baselines/reference/requireOfJsonFileNonRelative.types b/tests/baselines/reference/requireOfJsonFileNonRelative.types index 20c8fa75ba82d..2d9057dbbcbdc 100644 --- a/tests/baselines/reference/requireOfJsonFileNonRelative.types +++ b/tests/baselines/reference/requireOfJsonFileNonRelative.types @@ -56,3 +56,4 @@ if (x) { >"b" : string >"hello" : "hello" } + diff --git a/tests/baselines/reference/requireOfJsonFileNonRelativeWithoutExtensionResolvesToTs.js b/tests/baselines/reference/requireOfJsonFileNonRelativeWithoutExtensionResolvesToTs.js index e773adf45857a..8ad2a61f2b5fb 100644 --- a/tests/baselines/reference/requireOfJsonFileNonRelativeWithoutExtensionResolvesToTs.js +++ b/tests/baselines/reference/requireOfJsonFileNonRelativeWithoutExtensionResolvesToTs.js @@ -11,7 +11,8 @@ let fnumber: number = f; } //// [f.ts] -export = 10; +export = 10; + //// [out/node_modules/f.js] "use strict"; diff --git a/tests/baselines/reference/requireOfJsonFileNonRelativeWithoutExtensionResolvesToTs.symbols b/tests/baselines/reference/requireOfJsonFileNonRelativeWithoutExtensionResolvesToTs.symbols index 0b46f3348e116..ab6a6f28af80a 100644 --- a/tests/baselines/reference/requireOfJsonFileNonRelativeWithoutExtensionResolvesToTs.symbols +++ b/tests/baselines/reference/requireOfJsonFileNonRelativeWithoutExtensionResolvesToTs.symbols @@ -9,3 +9,4 @@ let fnumber: number = f; === /src/node_modules/f.ts === export = 10; + diff --git a/tests/baselines/reference/requireOfJsonFileNonRelativeWithoutExtensionResolvesToTs.types b/tests/baselines/reference/requireOfJsonFileNonRelativeWithoutExtensionResolvesToTs.types index 44b49ab470fa1..589776e008f98 100644 --- a/tests/baselines/reference/requireOfJsonFileNonRelativeWithoutExtensionResolvesToTs.types +++ b/tests/baselines/reference/requireOfJsonFileNonRelativeWithoutExtensionResolvesToTs.types @@ -9,3 +9,4 @@ let fnumber: number = f; === /src/node_modules/f.ts === export = 10; + diff --git a/tests/cases/compiler/cachedModuleResolution1.ts b/tests/cases/compiler/cachedModuleResolution1.ts index 3ef09ea0ea512..2e8be93fdf37b 100644 --- a/tests/cases/compiler/cachedModuleResolution1.ts +++ b/tests/cases/compiler/cachedModuleResolution1.ts @@ -8,4 +8,4 @@ export declare let x: number import {x} from "foo"; // @filename: /a/b/c/lib.ts -import {x} from "foo"; \ No newline at end of file +import {x} from "foo"; diff --git a/tests/cases/compiler/cachedModuleResolution5.ts b/tests/cases/compiler/cachedModuleResolution5.ts index e37b14fc1a0b7..721ee2d4934c8 100644 --- a/tests/cases/compiler/cachedModuleResolution5.ts +++ b/tests/cases/compiler/cachedModuleResolution5.ts @@ -8,4 +8,4 @@ export declare let x: number import {x} from "foo"; // @filename: /a/b/lib.ts -import {x} from "foo"; \ No newline at end of file +import {x} from "foo"; diff --git a/tests/cases/compiler/nodeColonModuleResolution.ts b/tests/cases/compiler/nodeColonModuleResolution.ts new file mode 100644 index 0000000000000..e768e6ec8b66e --- /dev/null +++ b/tests/cases/compiler/nodeColonModuleResolution.ts @@ -0,0 +1,26 @@ +// @moduleResolution: node +// @traceResolution: true + + +// @filename: /a/b/node_modules/@types/node/ph.d.ts +declare module 'ph' { + namespace constants { + const NODE_PERFORMANCE_GC_MAJOR: number; + const NODE_PERFORMANCE_GC_MINOR: number; + const NODE_PERFORMANCE_GC_INCREMENTAL: number; + const NODE_PERFORMANCE_GC_WEAKCB: number; + const NODE_PERFORMANCE_GC_FLAGS_NO: number; + const NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED: number; + const NODE_PERFORMANCE_GC_FLAGS_FORCED: number; + const NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING: number; + const NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE: number; + const NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY: number; + const NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE: number; + } +} +declare module 'node:ph' { + export * from 'ph'; +} +// @filename: /a/b/main.ts +import * as ph from 'node:ph' +console.log(ph.constants.NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE) diff --git a/tests/cases/compiler/nodeColonModuleResolution2.ts b/tests/cases/compiler/nodeColonModuleResolution2.ts new file mode 100644 index 0000000000000..2c07f4e31d959 --- /dev/null +++ b/tests/cases/compiler/nodeColonModuleResolution2.ts @@ -0,0 +1,29 @@ +// @moduleResolution: node +// @traceResolution: true + + +// @filename: /a/b/tsconfig.json +{ + "compilerOptions": { + "paths": { + "fake:thing": ["./node_modules/fake/thing"] + } + } +} +// @filename: /a/b/node_modules/fake/thing/index.d.ts +export namespace constants { + const NODE_PERFORMANCE_GC_MAJOR: number; + const NODE_PERFORMANCE_GC_MINOR: number; + const NODE_PERFORMANCE_GC_INCREMENTAL: number; + const NODE_PERFORMANCE_GC_WEAKCB: number; + const NODE_PERFORMANCE_GC_FLAGS_NO: number; + const NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED: number; + const NODE_PERFORMANCE_GC_FLAGS_FORCED: number; + const NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING: number; + const NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE: number; + const NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY: number; + const NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE: number; +} +// @filename: /a/b/main.ts +import * as ph from 'fake:thing' +console.log(ph.constants.NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE) diff --git a/tests/cases/compiler/nodeNextModuleResolution1.ts b/tests/cases/compiler/nodeNextModuleResolution1.ts new file mode 100644 index 0000000000000..c22c4fe3312cf --- /dev/null +++ b/tests/cases/compiler/nodeNextModuleResolution1.ts @@ -0,0 +1,15 @@ +// @moduleResolution: nodenext +// @traceResolution: true + +// @filename: /a/node_modules/foo.d.ts +export declare let x: number + +// @filename: /a/b/c/d/e/package.json +{ + "name": "e", + "version": "1.0.0", + "type": "module" +} +// @filename: /a/b/c/d/e/app.ts +import {x} from "foo"; + diff --git a/tests/cases/compiler/nodeNextModuleResolution2.ts b/tests/cases/compiler/nodeNextModuleResolution2.ts new file mode 100644 index 0000000000000..2bbe7a540715d --- /dev/null +++ b/tests/cases/compiler/nodeNextModuleResolution2.ts @@ -0,0 +1,16 @@ +// @moduleResolution: nodenext +// @traceResolution: true + +// @filename: /a/node_modules/foo/index.d.ts +export declare let x: number +// @filename: /a/node_modules/foo/package.json +{ + "name": "foo", + "type": "module", + "exports": { + ".": "./index.d.ts" + } +} + +// @filename: /a/b/c/d/e/app.mts +import {x} from "foo"; diff --git a/tests/cases/compiler/nodeResolution2.ts b/tests/cases/compiler/nodeResolution2.ts index 9d1972c72390e..d03706ebeacb1 100644 --- a/tests/cases/compiler/nodeResolution2.ts +++ b/tests/cases/compiler/nodeResolution2.ts @@ -5,4 +5,4 @@ export var x: number; // @filename: b.ts -import y = require("a"); \ No newline at end of file +import y = require("a"); diff --git a/tests/cases/compiler/pathMappingBasedModuleResolution5_node.ts b/tests/cases/compiler/pathMappingBasedModuleResolution5_node.ts index 3606ab08cd10c..ddc8e0e492595 100644 --- a/tests/cases/compiler/pathMappingBasedModuleResolution5_node.ts +++ b/tests/cases/compiler/pathMappingBasedModuleResolution5_node.ts @@ -40,4 +40,4 @@ export var y = 1; export var z: number; // @filename: c:/node_modules/file4.ts -export var z1 = 1; \ No newline at end of file +export var z1 = 1; diff --git a/tests/cases/compiler/requireOfJsonFileNonRelative.ts b/tests/cases/compiler/requireOfJsonFileNonRelative.ts index 0cfce0bdb1a0e..610c0c8f9f717 100644 --- a/tests/cases/compiler/requireOfJsonFileNonRelative.ts +++ b/tests/cases/compiler/requireOfJsonFileNonRelative.ts @@ -1,26 +1,26 @@ -// @module: commonjs -// @outdir: out/ -// @allowJs: true -// @fullEmitPaths: true -// @resolveJsonModule: true - -// @Filename: /src/projects/file1.ts -import b1 = require('b.json'); -let x = b1.a; -import b2 = require('c.json'); -if (x) { - let b = b2.b; - x = (b1.b === b); -} - -// @Filename: /src/projects/node_modules/b.json -{ - "a": true, - "b": "hello" -} - -// @Filename: /src/node_modules/c.json -{ - "a": true, - "b": "hello" -} \ No newline at end of file +// @module: commonjs +// @outdir: out/ +// @allowJs: true +// @fullEmitPaths: true +// @resolveJsonModule: true + +// @Filename: /src/projects/file1.ts +import b1 = require('b.json'); +let x = b1.a; +import b2 = require('c.json'); +if (x) { + let b = b2.b; + x = (b1.b === b); +} + +// @Filename: /src/projects/node_modules/b.json +{ + "a": true, + "b": "hello" +} + +// @Filename: /src/node_modules/c.json +{ + "a": true, + "b": "hello" +} diff --git a/tests/cases/compiler/requireOfJsonFileNonRelativeWithoutExtensionResolvesToTs.ts b/tests/cases/compiler/requireOfJsonFileNonRelativeWithoutExtensionResolvesToTs.ts index 4c8181b7a1007..341d6a5f80c79 100644 --- a/tests/cases/compiler/requireOfJsonFileNonRelativeWithoutExtensionResolvesToTs.ts +++ b/tests/cases/compiler/requireOfJsonFileNonRelativeWithoutExtensionResolvesToTs.ts @@ -15,4 +15,4 @@ let fnumber: number = f; } // @Filename: /src/node_modules/f.ts -export = 10; \ No newline at end of file +export = 10;