Skip to content

Commit 0565313

Browse files
Copilotjakebailey
andauthored
Fix extended tsconfig paths (#1268)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
1 parent 80aad85 commit 0565313

File tree

4 files changed

+318
-2
lines changed

4 files changed

+318
-2
lines changed

internal/tsoptions/tsconfigparsing.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,9 +1013,9 @@ func parseConfig(
10131013
if relativeDifference == "" {
10141014
t := tspath.ComparePathsOptions{
10151015
UseCaseSensitiveFileNames: host.FS().UseCaseSensitiveFileNames(),
1016-
CurrentDirectory: host.GetCurrentDirectory(),
1016+
CurrentDirectory: basePath,
10171017
}
1018-
relativeDifference = tspath.ConvertToRelativePath(basePath, t)
1018+
relativeDifference = tspath.ConvertToRelativePath(tspath.GetDirectoryPath(extendedConfigPath), t)
10191019
}
10201020
return tspath.CombinePaths(relativeDifference, path.(string))
10211021
}

internal/tsoptions/tsconfigparsing_test.go

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,76 @@ var parseJsonConfigFileTests = []parseJsonConfigTestCase{
513513
allFileList: map[string]string{"/app.ts": ""},
514514
}},
515515
},
516+
{
517+
title: "issue 1267 scenario - extended files not picked up",
518+
noSubmoduleBaseline: true,
519+
input: []testConfig{{
520+
jsonText: `{
521+
"extends": "./tsconfig-base/backend.json",
522+
"compilerOptions": {
523+
"baseUrl": "./",
524+
"outDir": "dist",
525+
"rootDir": "src",
526+
"resolveJsonModule": true
527+
},
528+
"exclude": ["node_modules", "dist"],
529+
"include": ["src/**/*"]
530+
}`,
531+
configFileName: "tsconfig.json",
532+
basePath: "/",
533+
allFileList: map[string]string{
534+
"/tsconfig-base/backend.json": `{
535+
"$schema": "https://json.schemastore.org/tsconfig",
536+
"display": "Backend",
537+
"compilerOptions": {
538+
"allowJs": true,
539+
"module": "nodenext",
540+
"removeComments": true,
541+
"emitDecoratorMetadata": true,
542+
"experimentalDecorators": true,
543+
"allowSyntheticDefaultImports": true,
544+
"target": "esnext",
545+
"lib": ["ESNext"],
546+
"incremental": false,
547+
"esModuleInterop": true,
548+
"noImplicitAny": true,
549+
"moduleResolution": "nodenext",
550+
"types": ["node", "vitest/globals"],
551+
"sourceMap": true,
552+
"strictPropertyInitialization": false
553+
},
554+
"files": [
555+
"types/ical2json.d.ts",
556+
"types/express.d.ts",
557+
"types/multer.d.ts",
558+
"types/reset.d.ts",
559+
"types/stripe-custom-typings.d.ts",
560+
"types/nestjs-modules.d.ts",
561+
"types/luxon.d.ts",
562+
"types/nestjs-pino.d.ts"
563+
],
564+
"ts-node": {
565+
"files": true
566+
}
567+
}`,
568+
"/tsconfig-base/types/ical2json.d.ts": "export {}",
569+
"/tsconfig-base/types/express.d.ts": "export {}",
570+
"/tsconfig-base/types/multer.d.ts": "export {}",
571+
"/tsconfig-base/types/reset.d.ts": "export {}",
572+
"/tsconfig-base/types/stripe-custom-typings.d.ts": "export {}",
573+
"/tsconfig-base/types/nestjs-modules.d.ts": "export {}",
574+
"/tsconfig-base/types/luxon.d.ts": `declare module 'luxon' {
575+
interface TSSettings {
576+
throwOnInvalid: true
577+
}
578+
}
579+
export {}`,
580+
"/tsconfig-base/types/nestjs-pino.d.ts": "export {}",
581+
"/src/main.ts": "export {}",
582+
"/src/utils.ts": "export {}",
583+
},
584+
}},
585+
},
516586
}
517587

518588
var tsconfigWithExtends = `{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
Fs::
2+
//// [/src/main.ts]
3+
export {}
4+
5+
//// [/src/utils.ts]
6+
export {}
7+
8+
//// [/tsconfig-base/backend.json]
9+
{
10+
"$schema": "https://json.schemastore.org/tsconfig",
11+
"display": "Backend",
12+
"compilerOptions": {
13+
"allowJs": true,
14+
"module": "nodenext",
15+
"removeComments": true,
16+
"emitDecoratorMetadata": true,
17+
"experimentalDecorators": true,
18+
"allowSyntheticDefaultImports": true,
19+
"target": "esnext",
20+
"lib": ["ESNext"],
21+
"incremental": false,
22+
"esModuleInterop": true,
23+
"noImplicitAny": true,
24+
"moduleResolution": "nodenext",
25+
"types": ["node", "vitest/globals"],
26+
"sourceMap": true,
27+
"strictPropertyInitialization": false
28+
},
29+
"files": [
30+
"types/ical2json.d.ts",
31+
"types/express.d.ts",
32+
"types/multer.d.ts",
33+
"types/reset.d.ts",
34+
"types/stripe-custom-typings.d.ts",
35+
"types/nestjs-modules.d.ts",
36+
"types/luxon.d.ts",
37+
"types/nestjs-pino.d.ts"
38+
],
39+
"ts-node": {
40+
"files": true
41+
}
42+
}
43+
44+
//// [/tsconfig-base/types/express.d.ts]
45+
export {}
46+
47+
//// [/tsconfig-base/types/ical2json.d.ts]
48+
export {}
49+
50+
//// [/tsconfig-base/types/luxon.d.ts]
51+
declare module 'luxon' {
52+
interface TSSettings {
53+
throwOnInvalid: true
54+
}
55+
}
56+
export {}
57+
58+
//// [/tsconfig-base/types/multer.d.ts]
59+
export {}
60+
61+
//// [/tsconfig-base/types/nestjs-modules.d.ts]
62+
export {}
63+
64+
//// [/tsconfig-base/types/nestjs-pino.d.ts]
65+
export {}
66+
67+
//// [/tsconfig-base/types/reset.d.ts]
68+
export {}
69+
70+
//// [/tsconfig-base/types/stripe-custom-typings.d.ts]
71+
export {}
72+
73+
//// [/tsconfig.json]
74+
{
75+
"extends": "./tsconfig-base/backend.json",
76+
"compilerOptions": {
77+
"baseUrl": "./",
78+
"outDir": "dist",
79+
"rootDir": "src",
80+
"resolveJsonModule": true
81+
},
82+
"exclude": ["node_modules", "dist"],
83+
"include": ["src/**/*"]
84+
}
85+
86+
87+
configFileName:: tsconfig.json
88+
CompilerOptions::
89+
{
90+
"allowJs": true,
91+
"allowSyntheticDefaultImports": true,
92+
"baseUrl": "/",
93+
"emitDecoratorMetadata": true,
94+
"esModuleInterop": true,
95+
"experimentalDecorators": true,
96+
"incremental": false,
97+
"lib": [
98+
"lib.esnext.d.ts"
99+
],
100+
"module": 199,
101+
"moduleResolution": 99,
102+
"noImplicitAny": true,
103+
"outDir": "/dist",
104+
"resolveJsonModule": true,
105+
"removeComments": true,
106+
"rootDir": "/src",
107+
"strictPropertyInitialization": false,
108+
"sourceMap": true,
109+
"target": 99,
110+
"types": [
111+
"node",
112+
"vitest/globals"
113+
],
114+
"configFilePath": "/tsconfig.json"
115+
}
116+
117+
TypeAcquisition::
118+
{}
119+
120+
FileNames::
121+
/tsconfig-base/types/ical2json.d.ts,/tsconfig-base/types/express.d.ts,/tsconfig-base/types/multer.d.ts,/tsconfig-base/types/reset.d.ts,/tsconfig-base/types/stripe-custom-typings.d.ts,/tsconfig-base/types/nestjs-modules.d.ts,/tsconfig-base/types/luxon.d.ts,/tsconfig-base/types/nestjs-pino.d.ts,/src/main.ts,/src/utils.ts
122+
Errors::
123+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
Fs::
2+
//// [/src/main.ts]
3+
export {}
4+
5+
//// [/src/utils.ts]
6+
export {}
7+
8+
//// [/tsconfig-base/backend.json]
9+
{
10+
"$schema": "https://json.schemastore.org/tsconfig",
11+
"display": "Backend",
12+
"compilerOptions": {
13+
"allowJs": true,
14+
"module": "nodenext",
15+
"removeComments": true,
16+
"emitDecoratorMetadata": true,
17+
"experimentalDecorators": true,
18+
"allowSyntheticDefaultImports": true,
19+
"target": "esnext",
20+
"lib": ["ESNext"],
21+
"incremental": false,
22+
"esModuleInterop": true,
23+
"noImplicitAny": true,
24+
"moduleResolution": "nodenext",
25+
"types": ["node", "vitest/globals"],
26+
"sourceMap": true,
27+
"strictPropertyInitialization": false
28+
},
29+
"files": [
30+
"types/ical2json.d.ts",
31+
"types/express.d.ts",
32+
"types/multer.d.ts",
33+
"types/reset.d.ts",
34+
"types/stripe-custom-typings.d.ts",
35+
"types/nestjs-modules.d.ts",
36+
"types/luxon.d.ts",
37+
"types/nestjs-pino.d.ts"
38+
],
39+
"ts-node": {
40+
"files": true
41+
}
42+
}
43+
44+
//// [/tsconfig-base/types/express.d.ts]
45+
export {}
46+
47+
//// [/tsconfig-base/types/ical2json.d.ts]
48+
export {}
49+
50+
//// [/tsconfig-base/types/luxon.d.ts]
51+
declare module 'luxon' {
52+
interface TSSettings {
53+
throwOnInvalid: true
54+
}
55+
}
56+
export {}
57+
58+
//// [/tsconfig-base/types/multer.d.ts]
59+
export {}
60+
61+
//// [/tsconfig-base/types/nestjs-modules.d.ts]
62+
export {}
63+
64+
//// [/tsconfig-base/types/nestjs-pino.d.ts]
65+
export {}
66+
67+
//// [/tsconfig-base/types/reset.d.ts]
68+
export {}
69+
70+
//// [/tsconfig-base/types/stripe-custom-typings.d.ts]
71+
export {}
72+
73+
//// [/tsconfig.json]
74+
{
75+
"extends": "./tsconfig-base/backend.json",
76+
"compilerOptions": {
77+
"baseUrl": "./",
78+
"outDir": "dist",
79+
"rootDir": "src",
80+
"resolveJsonModule": true
81+
},
82+
"exclude": ["node_modules", "dist"],
83+
"include": ["src/**/*"]
84+
}
85+
86+
87+
configFileName:: tsconfig.json
88+
CompilerOptions::
89+
{
90+
"allowJs": true,
91+
"allowSyntheticDefaultImports": true,
92+
"baseUrl": "/",
93+
"emitDecoratorMetadata": true,
94+
"esModuleInterop": true,
95+
"experimentalDecorators": true,
96+
"incremental": false,
97+
"lib": [
98+
"lib.esnext.d.ts"
99+
],
100+
"module": 199,
101+
"moduleResolution": 99,
102+
"noImplicitAny": true,
103+
"outDir": "/dist",
104+
"resolveJsonModule": true,
105+
"removeComments": true,
106+
"rootDir": "/src",
107+
"strictPropertyInitialization": false,
108+
"sourceMap": true,
109+
"target": 99,
110+
"types": [
111+
"node",
112+
"vitest/globals"
113+
],
114+
"configFilePath": "/tsconfig.json"
115+
}
116+
117+
TypeAcquisition::
118+
{}
119+
120+
FileNames::
121+
/tsconfig-base/types/ical2json.d.ts,/tsconfig-base/types/express.d.ts,/tsconfig-base/types/multer.d.ts,/tsconfig-base/types/reset.d.ts,/tsconfig-base/types/stripe-custom-typings.d.ts,/tsconfig-base/types/nestjs-modules.d.ts,/tsconfig-base/types/luxon.d.ts,/tsconfig-base/types/nestjs-pino.d.ts,/src/main.ts,/src/utils.ts
122+
Errors::
123+

0 commit comments

Comments
 (0)