Skip to content

Commit 8ea0688

Browse files
committed
Fix incorrecrty ignored dts source file from project reference
1 parent 45dd1ce commit 8ea0688

File tree

3 files changed

+13
-57
lines changed

3 files changed

+13
-57
lines changed

internal/compiler/fileloader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ func (p *fileLoader) addProjectReferenceTasks(singleThreaded bool) {
356356
})
357357
}
358358
} else {
359-
for outputDts := range resolved.GetOutputDeclarationFileNames() {
359+
for outputDts := range resolved.GetOutputDeclarationAndSourceFileNames() {
360360
if outputDts != "" {
361361
p.rootTasks = append(p.rootTasks, &parseTask{
362362
normalizedFilePath: outputDts,

internal/tsoptions/parsedcommandline.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func (p *ParsedCommandLine) ParseInputOutputNames() {
8787
sourceToOutput := map[tspath.Path]*SourceOutputAndProjectReference{}
8888
outputDtsToSource := map[tspath.Path]*SourceOutputAndProjectReference{}
8989

90-
for outputDts, source := range p.GetOutputDeclarationFileNames() {
90+
for outputDts, source := range p.GetOutputDeclarationAndSourceFileNames() {
9191
path := tspath.ToPath(source, p.GetCurrentDirectory(), p.UseCaseSensitiveFileNames())
9292
projectReference := &SourceOutputAndProjectReference{
9393
Source: source,
@@ -131,14 +131,11 @@ func (p *ParsedCommandLine) UseCaseSensitiveFileNames() bool {
131131
return p.comparePathsOptions.UseCaseSensitiveFileNames
132132
}
133133

134-
func (p *ParsedCommandLine) GetOutputDeclarationFileNames() iter.Seq2[string, string] {
134+
func (p *ParsedCommandLine) GetOutputDeclarationAndSourceFileNames() iter.Seq2[string, string] {
135135
return func(yield func(dtsName string, inputName string) bool) {
136136
for _, fileName := range p.ParsedConfig.FileNames {
137-
if tspath.IsDeclarationFileName(fileName) {
138-
continue
139-
}
140137
var outputDts string
141-
if !tspath.FileExtensionIs(fileName, tspath.ExtensionJson) {
138+
if !tspath.IsDeclarationFileName(fileName) && !tspath.FileExtensionIs(fileName, tspath.ExtensionJson) {
142139
outputDts = outputpaths.GetOutputDeclarationFileNameWorker(fileName, p.CompilerOptions(), p)
143140
}
144141
if !yield(outputDts, fileName) {

testdata/baselines/reference/tsbuild/moduleResolution/resolution-from-d.ts-of-referenced-project.js

Lines changed: 9 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export interface ValueProducerFromTs {
5252
}
5353

5454
tsgo --b consumer --traceResolution -v
55-
ExitStatus:: DiagnosticsPresent_OutputsGenerated
55+
ExitStatus:: Success
5656
Output::
5757
[HH:MM:SS AM] Projects in this build:
5858
* producer/tsconfig.json
@@ -118,54 +118,14 @@ Trying substitution '../common.d.ts', candidate module location: '../common.d.ts
118118
File '/home/src/workspaces/project/common.d.ts' exists - use it as a name resolution result.
119119
======== Module name '@common' was successfully resolved to '/home/src/workspaces/project/common.d.ts'. ========
120120
======== Resolving module '@common' from '/home/src/workspaces/project/producer/in-js.d.ts'. ========
121+
Using compiler options of project reference redirect '/home/src/workspaces/project/producer/tsconfig.json'.
121122
Explicitly specified module resolution kind: 'NodeNext'.
122123
Resolving in CJS mode with conditions 'require', 'types', 'node'.
123124
'paths' option is specified, looking for a pattern to match module name '@common'.
124-
File '/home/src/workspaces/project/producer/package.json' does not exist.
125-
File '/home/src/workspaces/project/package.json' does not exist.
126-
File '/home/src/workspaces/package.json' does not exist.
127-
File '/home/src/package.json' does not exist.
128-
File '/home/package.json' does not exist.
129-
File '/package.json' does not exist.
130-
Loading module '@common' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.
131-
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
132-
Directory '/home/src/workspaces/project/producer/node_modules' does not exist, skipping all lookups in it.
133-
Directory '/home/src/workspaces/project/producer/node_modules/@types' does not exist, skipping all lookups in it.
134-
Directory '/home/src/workspaces/project/node_modules' does not exist, skipping all lookups in it.
135-
Directory '/home/src/workspaces/project/node_modules/@types' does not exist, skipping all lookups in it.
136-
Directory '/home/src/workspaces/node_modules' does not exist, skipping all lookups in it.
137-
Directory '/home/src/workspaces/node_modules/@types' does not exist, skipping all lookups in it.
138-
Directory '/home/src/node_modules' does not exist, skipping all lookups in it.
139-
Directory '/home/src/node_modules/@types' does not exist, skipping all lookups in it.
140-
Directory '/home/node_modules' does not exist, skipping all lookups in it.
141-
Directory '/home/node_modules/@types' does not exist, skipping all lookups in it.
142-
Directory '/node_modules' does not exist, skipping all lookups in it.
143-
Directory '/node_modules/@types' does not exist, skipping all lookups in it.
144-
Searching all ancestor node_modules directories for fallback extensions: JavaScript.
145-
Directory '/home/src/workspaces/project/producer/node_modules' does not exist, skipping all lookups in it.
146-
Directory '/home/src/workspaces/project/node_modules' does not exist, skipping all lookups in it.
147-
Directory '/home/src/workspaces/node_modules' does not exist, skipping all lookups in it.
148-
Directory '/home/src/node_modules' does not exist, skipping all lookups in it.
149-
Directory '/home/node_modules' does not exist, skipping all lookups in it.
150-
Directory '/node_modules' does not exist, skipping all lookups in it.
151-
======== Module name '@common' was not resolved. ========
152-
consumer/index.ts:4:14 - error TS7006: Parameter 'n' implicitly has an 'any' type.
153-
154-
4 v.onValue = (n) => {
155-
   ~
156-
157-
producer/in-js.d.ts:1:25 - error TS2307: Cannot find module '@common' or its corresponding type declarations.
158-
159-
1 import { OnValue } from "@common"
160-
   ~~~~~~~~~
161-
162-
163-
Found 2 errors in 2 files.
164-
165-
Errors Files
166-
1 consumer/index.ts:4
167-
1 producer/in-js.d.ts:1
168-
125+
Module name '@common', matched pattern '@common'.
126+
Trying substitution '../common.d.ts', candidate module location: '../common.d.ts'.
127+
File '/home/src/workspaces/project/common.d.ts' exists - use it as a name resolution result.
128+
======== Module name '@common' was successfully resolved to '/home/src/workspaces/project/common.d.ts'. ========
169129
//// [/home/src/tslibs/TS/Lib/lib.esnext.full.d.ts] *Lib*
170130
/// <reference no-default-lib="true"/>
171131
interface Boolean {}
@@ -199,7 +159,7 @@ v2.onValue = (n) => {
199159
};
200160

201161
//// [/home/src/workspaces/project/consumer/tsconfig.tsbuildinfo] *new*
202-
{"version":"FakeTSVersion","root":["./index.ts"],"semanticErrors":true}
162+
{"version":"FakeTSVersion","root":["./index.ts"]}
203163
//// [/home/src/workspaces/project/consumer/tsconfig.tsbuildinfo.readable.baseline.txt] *new*
204164
{
205165
"version": "FakeTSVersion",
@@ -211,8 +171,7 @@ v2.onValue = (n) => {
211171
"original": "./index.ts"
212172
}
213173
],
214-
"size": 71,
215-
"semanticErrors": true
174+
"size": 49
216175
}
217176
//// [/home/src/workspaces/project/producer/index.d.ts] *new*
218177
export { ValueProducerDeclaration } from "./in-js";
@@ -324,8 +283,8 @@ Signatures::
324283
consumer/tsconfig.json::
325284
SemanticDiagnostics::
326285
*refresh* /home/src/tslibs/TS/Lib/lib.esnext.full.d.ts
327-
*refresh* /home/src/workspaces/project/producer/in-js.d.ts
328286
*refresh* /home/src/workspaces/project/common.d.ts
287+
*refresh* /home/src/workspaces/project/producer/in-js.d.ts
329288
*refresh* /home/src/workspaces/project/producer/index.d.ts
330289
*refresh* /home/src/workspaces/project/consumer/index.ts
331290
Signatures::

0 commit comments

Comments
 (0)