Skip to content

Commit c9968e6

Browse files
Copilotjakebailey
andauthored
Treat zero-byte tsconfig.json as an empty config (#4155)
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 a980d86 commit c9968e6

3 files changed

Lines changed: 47 additions & 1 deletion

File tree

internal/execute/tsctests/tsc_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,14 @@ func TestTscCommandline(t *testing.T) {
174174
},
175175
commandLineArgs: []string{"-p", "/home/src/workspaces/project"},
176176
},
177+
{
178+
subScenario: "Parse -p with empty tsconfig file",
179+
files: FileMap{
180+
"/home/src/workspaces/project/first.ts": `export const a = 1`,
181+
"/home/src/workspaces/project/tsconfig.json": ``,
182+
},
183+
commandLineArgs: []string{"-p", "."},
184+
},
177185
{
178186
subScenario: "Parse enum type options",
179187
commandLineArgs: []string{"--moduleResolution", "nodenext ", "first.ts", "--module", "nodenext", "--target", "esnext", "--moduleDetection", "auto", "--jsx", "react", "--newLine", "crlf"},

internal/tsoptions/commandlineparser.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func tryReadFile(fileName string, readFile func(string) (string, bool), errors [
217217
// this function adds a compiler diagnostic if the file cannot be read
218218
text, e := readFile(fileName)
219219

220-
if !e || text == "" {
220+
if !e {
221221
// !!! Divergence: the returned error will not give a useful message
222222
// errors = append(errors, ast.NewCompilerDiagnostic(diagnostics.Cannot_read_file_0_Colon_1, *e));
223223
text = ""
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
currentDirectory::/home/src/workspaces/project
2+
useCaseSensitiveFileNames::true
3+
Input::
4+
//// [/home/src/workspaces/project/first.ts] *new*
5+
export const a = 1
6+
//// [/home/src/workspaces/project/tsconfig.json] *new*
7+
8+
9+
tsgo -p .
10+
ExitStatus:: Success
11+
Output::
12+
//// [/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts] *Lib*
13+
/// <reference no-default-lib="true"/>
14+
interface Boolean {}
15+
interface Function {}
16+
interface CallableFunction {}
17+
interface NewableFunction {}
18+
interface IArguments {}
19+
interface Number { toExponential: any; }
20+
interface Object {}
21+
interface RegExp {}
22+
interface String { charAt: any; }
23+
interface Array<T> { length: number; [n: number]: T; }
24+
interface ReadonlyArray<T> {}
25+
interface SymbolConstructor {
26+
(desc?: string | number): symbol;
27+
for(name: string): symbol;
28+
readonly toStringTag: symbol;
29+
}
30+
declare var Symbol: SymbolConstructor;
31+
interface Symbol {
32+
readonly [Symbol.toStringTag]: string;
33+
}
34+
declare const console: { log(msg: any): void; };
35+
//// [/home/src/workspaces/project/first.js] *new*
36+
export const a = 1;
37+
38+

0 commit comments

Comments
 (0)