Skip to content

Commit 5c1ae7a

Browse files
committed
Update showing fix in microsoft#44004 works
1 parent 8da9ed0 commit 5c1ae7a

File tree

2 files changed

+29
-44
lines changed

2 files changed

+29
-44
lines changed

src/compiler/tsbuildPublic.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ namespace ts {
849849
state.projectCompilerOptions = config.options;
850850
// Update module resolution cache if needed
851851
state.moduleResolutionCache?.update(config.options);
852-
// state.typeReferenceDirectiveResolutionCache?.update(config.options);
852+
state.typeReferenceDirectiveResolutionCache?.update(config.options);
853853

854854
// Create program
855855
program = host.createProgram(

tests/baselines/reference/tsbuild/moduleResolution/initial-build/type-reference-resolution-uses-correct-options-for-different-resolution-options-referenced-project.js

Lines changed: 28 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const theNum: TheNum2 = "type2";
3030
declare type TheNum = "type1";
3131

3232
//// [/src/packages/typeroot2/sometype/index.d.ts]
33-
33+
declare type TheNum2 = "type2";
3434

3535

3636

@@ -54,18 +54,13 @@ Resolving real path for '/src/packages/typeroot1/sometype/index.d.ts', result '/
5454

5555
[12:00:00 AM] Building project '/src/packages/pkg2.tsconfig.json'...
5656

57-
======== Resolving type reference directive 'sometype', containing file '/src/packages/__inferred type names__.ts'. ========
58-
Resolution for type reference directive 'sometype' was found in cache from location '/src/packages'.
59-
======== Type reference directive 'sometype' was successfully resolved to '/src/packages/typeroot1/sometype/index.d.ts', primary: true. ========
60-
src/packages/pkg2_index.ts:1:22 - error TS2304: Cannot find name 'TheNum2'.
61-
62-
1 export const theNum: TheNum2 = "type2";
63-
   ~~~~~~~
64-
65-
66-
Found 1 error.
67-
68-
exitCode:: ExitStatus.DiagnosticsPresent_OutputsGenerated
57+
======== Resolving type reference directive 'sometype', containing file '/src/packages/__inferred type names__.ts', root directory '/src/packages/typeroot2'. ========
58+
Resolving with primary search path '/src/packages/typeroot2'.
59+
File '/src/packages/typeroot2/sometype/package.json' does not exist.
60+
File '/src/packages/typeroot2/sometype/index.d.ts' exist - use it as a name resolution result.
61+
Resolving real path for '/src/packages/typeroot2/sometype/index.d.ts', result '/src/packages/typeroot2/sometype/index.d.ts'.
62+
======== Type reference directive 'sometype' was successfully resolved to '/src/packages/typeroot2/sometype/index.d.ts', primary: true. ========
63+
exitCode:: ExitStatus.Success
6964

7065

7166
//// [/src/packages/pkg1.tsconfig.tsbuildinfo]
@@ -123,15 +118,15 @@ exports.theNum = "type1";
123118

124119

125120
//// [/src/packages/pkg2.tsconfig.tsbuildinfo]
126-
{"program":{"fileNames":["../../lib/lib.d.ts","./pkg2_index.ts","./typeroot1/sometype/index.d.ts"],"fileInfos":[{"version":"3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"-12823281204-export const theNum: TheNum2 = \"type2\";",{"version":"-4557394441-declare type TheNum = \"type1\";","affectsGlobalScope":true}],"options":{"composite":true},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,[2,[{"file":"./pkg2_index.ts","start":21,"length":7,"messageText":"Cannot find name 'TheNum2'.","category":1,"code":2304}]],3],"affectedFilesPendingEmit":[[2,1],[3,1]]},"version":"FakeTSVersion"}
121+
{"program":{"fileNames":["../../lib/lib.d.ts","./pkg2_index.ts","./typeroot2/sometype/index.d.ts"],"fileInfos":[{"version":"3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"-12823281204-export const theNum: TheNum2 = \"type2\";",{"version":"-980425686-declare type TheNum2 = \"type2\";","affectsGlobalScope":true}],"options":{"composite":true},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2,3]},"version":"FakeTSVersion"}
127122

128123
//// [/src/packages/pkg2.tsconfig.tsbuildinfo.readable.baseline.txt]
129124
{
130125
"program": {
131126
"fileNames": [
132127
"../../lib/lib.d.ts",
133128
"./pkg2_index.ts",
134-
"./typeroot1/sometype/index.d.ts"
129+
"./typeroot2/sometype/index.d.ts"
135130
],
136131
"fileInfos": {
137132
"../../lib/lib.d.ts": {
@@ -143,9 +138,9 @@ exports.theNum = "type1";
143138
"version": "-12823281204-export const theNum: TheNum2 = \"type2\";",
144139
"signature": "-12823281204-export const theNum: TheNum2 = \"type2\";"
145140
},
146-
"./typeroot1/sometype/index.d.ts": {
147-
"version": "-4557394441-declare type TheNum = \"type1\";",
148-
"signature": "-4557394441-declare type TheNum = \"type1\";",
141+
"./typeroot2/sometype/index.d.ts": {
142+
"version": "-980425686-declare type TheNum2 = \"type2\";",
143+
"signature": "-980425686-declare type TheNum2 = \"type2\";",
149144
"affectsGlobalScope": true
150145
}
151146
},
@@ -156,33 +151,23 @@ exports.theNum = "type1";
156151
"exportedModulesMap": {},
157152
"semanticDiagnosticsPerFile": [
158153
"../../lib/lib.d.ts",
159-
[
160-
"./pkg2_index.ts",
161-
[
162-
{
163-
"file": "./pkg2_index.ts",
164-
"start": 21,
165-
"length": 7,
166-
"messageText": "Cannot find name 'TheNum2'.",
167-
"category": 1,
168-
"code": 2304
169-
}
170-
]
171-
],
172-
"./typeroot1/sometype/index.d.ts"
173-
],
174-
"affectedFilesPendingEmit": [
175-
[
176-
"./pkg2_index.ts",
177-
"Full"
178-
],
179-
[
180-
"./typeroot1/sometype/index.d.ts",
181-
"Full"
182-
]
154+
"./pkg2_index.ts",
155+
"./typeroot2/sometype/index.d.ts"
183156
]
184157
},
185158
"version": "FakeTSVersion",
186-
"size": 1033
159+
"size": 870
187160
}
188161

162+
//// [/src/packages/pkg2_index.d.ts]
163+
/// <reference types="sometype" />
164+
export declare const theNum: TheNum2;
165+
166+
167+
//// [/src/packages/pkg2_index.js]
168+
"use strict";
169+
exports.__esModule = true;
170+
exports.theNum = void 0;
171+
exports.theNum = "type2";
172+
173+

0 commit comments

Comments
 (0)