forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not allow freshness to move errors out of the current file, ensure…
… json documents are deeply unfreshened and fully widened (microsoft#35048)
- Loading branch information
Showing
6 changed files
with
158 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
tests/baselines/reference/jsonFileImportChecksCallCorrectlyTwice.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
//// [tests/cases/compiler/jsonFileImportChecksCallCorrectlyTwice.ts] //// | ||
|
||
//// [index.ts] | ||
import data from "./data.json"; | ||
|
||
interface Foo { | ||
str: string; | ||
} | ||
|
||
fn(data.foo); | ||
fn(data.foo); // <-- shouldn't error! | ||
|
||
function fn(arg: Foo[]) { } | ||
//// [data.json] | ||
{ | ||
"foo": [ | ||
{ | ||
"bool": true, | ||
"str": "123" | ||
} | ||
] | ||
} | ||
|
||
//// [data.json] | ||
{ | ||
"foo": [ | ||
{ | ||
"bool": true, | ||
"str": "123" | ||
} | ||
] | ||
} | ||
//// [index.js] | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
exports.__esModule = true; | ||
var data_json_1 = __importDefault(require("./data.json")); | ||
fn(data_json_1["default"].foo); | ||
fn(data_json_1["default"].foo); // <-- shouldn't error! | ||
function fn(arg) { } |
41 changes: 41 additions & 0 deletions
41
tests/baselines/reference/jsonFileImportChecksCallCorrectlyTwice.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
=== tests/cases/compiler/index.ts === | ||
import data from "./data.json"; | ||
>data : Symbol(data, Decl(index.ts, 0, 6)) | ||
|
||
interface Foo { | ||
>Foo : Symbol(Foo, Decl(index.ts, 0, 31)) | ||
|
||
str: string; | ||
>str : Symbol(Foo.str, Decl(index.ts, 2, 15)) | ||
} | ||
|
||
fn(data.foo); | ||
>fn : Symbol(fn, Decl(index.ts, 7, 13)) | ||
>data.foo : Symbol("foo", Decl(data.json, 0, 1)) | ||
>data : Symbol(data, Decl(index.ts, 0, 6)) | ||
>foo : Symbol("foo", Decl(data.json, 0, 1)) | ||
|
||
fn(data.foo); // <-- shouldn't error! | ||
>fn : Symbol(fn, Decl(index.ts, 7, 13)) | ||
>data.foo : Symbol("foo", Decl(data.json, 0, 1)) | ||
>data : Symbol(data, Decl(index.ts, 0, 6)) | ||
>foo : Symbol("foo", Decl(data.json, 0, 1)) | ||
|
||
function fn(arg: Foo[]) { } | ||
>fn : Symbol(fn, Decl(index.ts, 7, 13)) | ||
>arg : Symbol(arg, Decl(index.ts, 9, 12)) | ||
>Foo : Symbol(Foo, Decl(index.ts, 0, 31)) | ||
|
||
=== tests/cases/compiler/data.json === | ||
{ | ||
"foo": [ | ||
>"foo" : Symbol("foo", Decl(data.json, 0, 1)) | ||
{ | ||
"bool": true, | ||
>"bool" : Symbol("bool", Decl(data.json, 2, 7)) | ||
|
||
"str": "123" | ||
>"str" : Symbol("str", Decl(data.json, 3, 21)) | ||
} | ||
] | ||
} |
47 changes: 47 additions & 0 deletions
47
tests/baselines/reference/jsonFileImportChecksCallCorrectlyTwice.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
=== tests/cases/compiler/index.ts === | ||
import data from "./data.json"; | ||
>data : { foo: { bool: boolean; str: string; }[]; } | ||
|
||
interface Foo { | ||
str: string; | ||
>str : string | ||
} | ||
|
||
fn(data.foo); | ||
>fn(data.foo) : void | ||
>fn : (arg: Foo[]) => void | ||
>data.foo : { bool: boolean; str: string; }[] | ||
>data : { foo: { bool: boolean; str: string; }[]; } | ||
>foo : { bool: boolean; str: string; }[] | ||
|
||
fn(data.foo); // <-- shouldn't error! | ||
>fn(data.foo) : void | ||
>fn : (arg: Foo[]) => void | ||
>data.foo : { bool: boolean; str: string; }[] | ||
>data : { foo: { bool: boolean; str: string; }[]; } | ||
>foo : { bool: boolean; str: string; }[] | ||
|
||
function fn(arg: Foo[]) { } | ||
>fn : (arg: Foo[]) => void | ||
>arg : Foo[] | ||
|
||
=== tests/cases/compiler/data.json === | ||
{ | ||
>{ "foo": [ { "bool": true, "str": "123" } ]} : { foo: { bool: boolean; str: string; }[]; } | ||
|
||
"foo": [ | ||
>"foo" : { bool: boolean; str: string; }[] | ||
>[ { "bool": true, "str": "123" } ] : { bool: boolean; str: string; }[] | ||
{ | ||
>{ "bool": true, "str": "123" } : { bool: boolean; str: string; } | ||
|
||
"bool": true, | ||
>"bool" : boolean | ||
>true : true | ||
|
||
"str": "123" | ||
>"str" : string | ||
>"123" : "123" | ||
} | ||
] | ||
} |
24 changes: 24 additions & 0 deletions
24
tests/cases/compiler/jsonFileImportChecksCallCorrectlyTwice.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// @esModuleInterop: true | ||
// @resolveJsonModule: true | ||
// @strict: true | ||
// @outDir: dist | ||
// @filename: index.ts | ||
import data from "./data.json"; | ||
|
||
interface Foo { | ||
str: string; | ||
} | ||
|
||
fn(data.foo); | ||
fn(data.foo); // <-- shouldn't error! | ||
|
||
function fn(arg: Foo[]) { } | ||
// @filename: data.json | ||
{ | ||
"foo": [ | ||
{ | ||
"bool": true, | ||
"str": "123" | ||
} | ||
] | ||
} |