diff --git a/tests/baselines/reference/propertyElementAccessOnVoidNoImplicitAnyFalse01.errors.txt b/tests/baselines/reference/propertyElementAccessOnVoidNoImplicitAnyFalse01.errors.txt new file mode 100644 index 00000000000..a5f76ef0ce5 --- /dev/null +++ b/tests/baselines/reference/propertyElementAccessOnVoidNoImplicitAnyFalse01.errors.txt @@ -0,0 +1,21 @@ +tests/cases/compiler/propertyElementAccessOnVoidNoImplicitAnyFalse01.ts(7,12): error TS2339: Property 'world' does not exist on type 'void'. +tests/cases/compiler/propertyElementAccessOnVoidNoImplicitAnyFalse01.ts(11,24): error TS2339: Property 'world' does not exist on type 'void'. + + +==== tests/cases/compiler/propertyElementAccessOnVoidNoImplicitAnyFalse01.ts (2 errors) ==== + let result = [1, 2, 3, 4].forEach(x => { + console.log(x); + }); + + if (Math.random()) { + result["hello"] = "foo"; + result.world = "foo"; + ~~~~~ +!!! error TS2339: Property 'world' does not exist on type 'void'. + } + else { + console.log(result["hello"]); + console.log(result.world); + ~~~~~ +!!! error TS2339: Property 'world' does not exist on type 'void'. + } \ No newline at end of file diff --git a/tests/baselines/reference/propertyElementAccessOnVoidNoImplicitAnyFalse01.js b/tests/baselines/reference/propertyElementAccessOnVoidNoImplicitAnyFalse01.js new file mode 100644 index 00000000000..4fbd7434b95 --- /dev/null +++ b/tests/baselines/reference/propertyElementAccessOnVoidNoImplicitAnyFalse01.js @@ -0,0 +1,26 @@ +//// [propertyElementAccessOnVoidNoImplicitAnyFalse01.ts] +let result = [1, 2, 3, 4].forEach(x => { + console.log(x); +}); + +if (Math.random()) { + result["hello"] = "foo"; + result.world = "foo"; +} +else { + console.log(result["hello"]); + console.log(result.world); +} + +//// [propertyElementAccessOnVoidNoImplicitAnyFalse01.js] +var result = [1, 2, 3, 4].forEach(function (x) { + console.log(x); +}); +if (Math.random()) { + result["hello"] = "foo"; + result.world = "foo"; +} +else { + console.log(result["hello"]); + console.log(result.world); +} diff --git a/tests/baselines/reference/propertyElementAccessOnVoidNoImplicitAnyFalse01.symbols b/tests/baselines/reference/propertyElementAccessOnVoidNoImplicitAnyFalse01.symbols new file mode 100644 index 00000000000..de45b2b3038 --- /dev/null +++ b/tests/baselines/reference/propertyElementAccessOnVoidNoImplicitAnyFalse01.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/propertyElementAccessOnVoidNoImplicitAnyFalse01.ts === +let result = [1, 2, 3, 4].forEach(x => { +>result : Symbol(result, Decl(propertyElementAccessOnVoidNoImplicitAnyFalse01.ts, 0, 3)) +>[1, 2, 3, 4].forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(propertyElementAccessOnVoidNoImplicitAnyFalse01.ts, 0, 34)) + + console.log(x); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>x : Symbol(x, Decl(propertyElementAccessOnVoidNoImplicitAnyFalse01.ts, 0, 34)) + +}); + +if (Math.random()) { +>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) + + result["hello"] = "foo"; +>result : Symbol(result, Decl(propertyElementAccessOnVoidNoImplicitAnyFalse01.ts, 0, 3)) + + result.world = "foo"; +>result : Symbol(result, Decl(propertyElementAccessOnVoidNoImplicitAnyFalse01.ts, 0, 3)) +} +else { + console.log(result["hello"]); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>result : Symbol(result, Decl(propertyElementAccessOnVoidNoImplicitAnyFalse01.ts, 0, 3)) + + console.log(result.world); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>result : Symbol(result, Decl(propertyElementAccessOnVoidNoImplicitAnyFalse01.ts, 0, 3)) +} diff --git a/tests/baselines/reference/propertyElementAccessOnVoidNoImplicitAnyFalse01.types b/tests/baselines/reference/propertyElementAccessOnVoidNoImplicitAnyFalse01.types new file mode 100644 index 00000000000..c4cdde55a2e --- /dev/null +++ b/tests/baselines/reference/propertyElementAccessOnVoidNoImplicitAnyFalse01.types @@ -0,0 +1,62 @@ +=== tests/cases/compiler/propertyElementAccessOnVoidNoImplicitAnyFalse01.ts === +let result = [1, 2, 3, 4].forEach(x => { +>result : void +>[1, 2, 3, 4].forEach(x => { console.log(x);}) : void +>[1, 2, 3, 4].forEach : (callbackfn: (value: number, index: number, array: number[]) => void, thisArg?: any) => void +>[1, 2, 3, 4] : number[] +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 +>forEach : (callbackfn: (value: number, index: number, array: number[]) => void, thisArg?: any) => void +>x => { console.log(x);} : (x: number) => void +>x : number + + console.log(x); +>console.log(x) : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>x : number + +}); + +if (Math.random()) { +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number + + result["hello"] = "foo"; +>result["hello"] = "foo" : "foo" +>result["hello"] : any +>result : void +>"hello" : "hello" +>"foo" : "foo" + + result.world = "foo"; +>result.world = "foo" : "foo" +>result.world : any +>result : void +>world : any +>"foo" : "foo" +} +else { + console.log(result["hello"]); +>console.log(result["hello"]) : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>result["hello"] : any +>result : void +>"hello" : "hello" + + console.log(result.world); +>console.log(result.world) : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>result.world : any +>result : void +>world : any +}