Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions internal/execute/tsctests/tsc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ func TestTscCommandline(t *testing.T) {
subScenario: "when build not first argument",
commandLineArgs: []string{"--verbose", "--build"},
},
{
subScenario: "malformed tsconfig property without value",
files: FileMap{
"/home/src/workspaces/project/tsconfig.json": `{"" }`,
"/home/src/workspaces/project/index.ts": "",
},
commandLineArgs: nil,
},
{
subScenario: "Initialized TSConfig with files options",
commandLineArgs: []string{"--init", "file0.st", "file1.ts", "file2.ts"},
Expand Down
5 changes: 4 additions & 1 deletion internal/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,10 @@ func (p *Parser) parseJSONText() *ast.SourceFile {
}

func getErrorSpanForNode(sourceText string, node *ast.Node) core.TextRange {
pos := scanner.SkipTrivia(sourceText, node.Pos())
pos := node.Pos()
if !ast.NodeIsMissing(node) {
pos = scanner.SkipTrivia(sourceText, pos)
}
return core.NewTextRange(pos, node.End())
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
currentDirectory::/home/src/workspaces/project
useCaseSensitiveFileNames::true
Input::
//// [/home/src/workspaces/project/index.ts] *new*

//// [/home/src/workspaces/project/tsconfig.json] *new*
{"" }

tsgo
ExitStatus:: DiagnosticsPresent_OutputsGenerated
Output::
tsconfig.json:1:4 - error TS1328: Property value can only be string literal, numeric literal, 'true', 'false', 'null', object literal or array literal.

1 {"" }
   ~

tsconfig.json:1:5 - error TS1005: ':' expected.

1 {"" }
   ~


Found 2 errors in the same file, starting at: tsconfig.json:1

//// [/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts] *Lib*
/// <reference no-default-lib="true"/>
interface Boolean {}
interface Function {}
interface CallableFunction {}
interface NewableFunction {}
interface IArguments {}
interface Number { toExponential: any; }
interface Object {}
interface RegExp {}
interface String { charAt: any; }
interface Array<T> { length: number; [n: number]: T; }
interface ReadonlyArray<T> {}
interface SymbolConstructor {
(desc?: string | number): symbol;
for(name: string): symbol;
readonly toStringTag: symbol;
}
declare var Symbol: SymbolConstructor;
interface Symbol {
readonly [Symbol.toStringTag]: string;
}
declare const console: { log(msg: any): void; };
//// [/home/src/workspaces/project/index.js] *new*
"use strict";