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
4 changes: 3 additions & 1 deletion tsc/internal/execute/incremental/affectedfileshandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ func (h *affectedFilesHandler) updateShapeSignature(file *ast.SourceFile, useFil

info, _ := h.program.snapshot.fileInfos.Load(file.Path())
prevSignature := info.signature
if !file.IsDeclarationFile && !useFileVersionAsSignature {
// JSON files have no declaration output from which to compute a shape
// signature, so use the file version to conservatively invalidate dependents.
if !file.IsDeclarationFile && !ast.IsJsonSourceFile(file) && !useFileVersionAsSignature {
Comment thread
jakebailey marked this conversation as resolved.
update.signature = h.computeDtsSignature(file)
}
// Default is to use file version as signature
Expand Down
38 changes: 38 additions & 0 deletions tsc/internal/execute/tsctests/tsc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2270,6 +2270,44 @@ func TestTscIncremental(t *testing.T) {
},
commandLineArgs: []string{"--noEmit"},
},
{
subScenario: "json module diagnostics are cleared after fixing the json file",
files: FileMap{
"/home/src/workspaces/project/tsconfig.json": stringtestutil.Dedent(`
{
"compilerOptions": {
"strict": true,
"noEmit": true,
"incremental": true,
"resolveJsonModule": true,
"esModuleInterop": true
}
}`),
"/home/src/workspaces/project/data.json": `{ "title": "hello" }`,
"/home/src/workspaces/project/check.ts": stringtestutil.Dedent(`
import type data from "./data.json";

type Shape = { title: string };
type Covers<T extends Shape> = T;

export type Check = Covers<typeof data>;
`),
},
edits: []*tscEdit{
{
caption: "remove required property",
edit: func(sys *TestSys) {
sys.writeFileNoError("/home/src/workspaces/project/data.json", `{}`)
},
},
{
caption: "restore required property",
edit: func(sys *TestSys) {
sys.writeFileNoError("/home/src/workspaces/project/data.json", `{ "title": "fixed" }`)
},
},
},
},
}

for _, test := range testCases {
Expand Down
Loading