diff --git a/tests/baselines/reference/contextuallyTypedClassExpressionMethodDeclaration01.errors.txt b/tests/baselines/reference/contextuallyTypedClassExpressionMethodDeclaration01.errors.txt new file mode 100644 index 0000000000..dab85baf2c --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedClassExpressionMethodDeclaration01.errors.txt @@ -0,0 +1,67 @@ +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration01.ts(17,24): error TS7006: Parameter 'arg' implicitly has an 'any' type. +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration01.ts(20,24): error TS7006: Parameter 'arg' implicitly has an 'any' type. +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration01.ts(28,27): error TS7006: Parameter 'arg' implicitly has an 'any' type. +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration01.ts(31,27): error TS7006: Parameter 'arg' implicitly has an 'any' type. +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration01.ts(39,36): error TS7006: Parameter 'arg' implicitly has an 'any' type. +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration01.ts(42,36): error TS7006: Parameter 'arg' implicitly has an 'any' type. + + +==== tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration01.ts (6 errors) ==== + + interface A { + numProp: number; + } + + interface B { + strProp: string; + } + + interface Foo { + method1(arg: A): void; + method2(arg: B): void; + } + + function getFoo1(): Foo { + return class { + static method1(arg) { + ~~~ +!!! error TS7006: Parameter 'arg' implicitly has an 'any' type. + arg.numProp = 10; + } + static method2(arg) { + ~~~ +!!! error TS7006: Parameter 'arg' implicitly has an 'any' type. + arg.strProp = "hello"; + } + } + } + + function getFoo2(): Foo { + return class { + static method1 = (arg) => { + ~~~ +!!! error TS7006: Parameter 'arg' implicitly has an 'any' type. + arg.numProp = 10; + } + static method2 = (arg) => { + ~~~ +!!! error TS7006: Parameter 'arg' implicitly has an 'any' type. + arg.strProp = "hello"; + } + } + } + + function getFoo3(): Foo { + return class { + static method1 = function (arg) { + ~~~ +!!! error TS7006: Parameter 'arg' implicitly has an 'any' type. + arg.numProp = 10; + } + static method2 = function (arg) { + ~~~ +!!! error TS7006: Parameter 'arg' implicitly has an 'any' type. + arg.strProp = "hello"; + } + } + } \ No newline at end of file diff --git a/tests/baselines/reference/contextuallyTypedClassExpressionMethodDeclaration01.js b/tests/baselines/reference/contextuallyTypedClassExpressionMethodDeclaration01.js new file mode 100644 index 0000000000..edbe8c4d33 --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedClassExpressionMethodDeclaration01.js @@ -0,0 +1,88 @@ +//// [contextuallyTypedClassExpressionMethodDeclaration01.ts] + +interface A { + numProp: number; +} + +interface B { + strProp: string; +} + +interface Foo { + method1(arg: A): void; + method2(arg: B): void; +} + +function getFoo1(): Foo { + return class { + static method1(arg) { + arg.numProp = 10; + } + static method2(arg) { + arg.strProp = "hello"; + } + } +} + +function getFoo2(): Foo { + return class { + static method1 = (arg) => { + arg.numProp = 10; + } + static method2 = (arg) => { + arg.strProp = "hello"; + } + } +} + +function getFoo3(): Foo { + return class { + static method1 = function (arg) { + arg.numProp = 10; + } + static method2 = function (arg) { + arg.strProp = "hello"; + } + } +} + +//// [contextuallyTypedClassExpressionMethodDeclaration01.js] +function getFoo1() { + return (function () { + function class_1() { + } + class_1.method1 = function (arg) { + arg.numProp = 10; + }; + class_1.method2 = function (arg) { + arg.strProp = "hello"; + }; + return class_1; + })(); +} +function getFoo2() { + return (function () { + function class_2() { + } + class_2.method1 = function (arg) { + arg.numProp = 10; + }; + class_2.method2 = function (arg) { + arg.strProp = "hello"; + }; + return class_2; + })(); +} +function getFoo3() { + return (function () { + function class_3() { + } + class_3.method1 = function (arg) { + arg.numProp = 10; + }; + class_3.method2 = function (arg) { + arg.strProp = "hello"; + }; + return class_3; + })(); +} diff --git a/tests/baselines/reference/contextuallyTypedClassExpressionMethodDeclaration02.errors.txt b/tests/baselines/reference/contextuallyTypedClassExpressionMethodDeclaration02.errors.txt new file mode 100644 index 0000000000..ae6dfee486 --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedClassExpressionMethodDeclaration02.errors.txt @@ -0,0 +1,71 @@ +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration02.ts(21,17): error TS7006: Parameter 'arg' implicitly has an 'any' type. +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration02.ts(24,17): error TS7006: Parameter 'arg' implicitly has an 'any' type. +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration02.ts(32,20): error TS7006: Parameter 'arg' implicitly has an 'any' type. +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration02.ts(35,20): error TS7006: Parameter 'arg' implicitly has an 'any' type. +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration02.ts(43,29): error TS7006: Parameter 'arg' implicitly has an 'any' type. +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration02.ts(46,29): error TS7006: Parameter 'arg' implicitly has an 'any' type. + + +==== tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration02.ts (6 errors) ==== + + interface A { + numProp: number; + } + + interface B { + strProp: string; + } + + interface Foo { + new (): Bar; + } + + interface Bar { + method1(arg: A): void; + method2(arg: B): void; + } + + function getFoo1(): Foo { + return class { + method1(arg) { + ~~~ +!!! error TS7006: Parameter 'arg' implicitly has an 'any' type. + arg.numProp = 10; + } + method2(arg) { + ~~~ +!!! error TS7006: Parameter 'arg' implicitly has an 'any' type. + arg.strProp = "hello"; + } + } + } + + function getFoo2(): Foo { + return class { + method1 = (arg) => { + ~~~ +!!! error TS7006: Parameter 'arg' implicitly has an 'any' type. + arg.numProp = 10; + } + method2 = (arg) => { + ~~~ +!!! error TS7006: Parameter 'arg' implicitly has an 'any' type. + arg.strProp = "hello"; + } + } + } + + function getFoo3(): Foo { + return class { + method1 = function (arg) { + ~~~ +!!! error TS7006: Parameter 'arg' implicitly has an 'any' type. + arg.numProp = 10; + } + method2 = function (arg) { + ~~~ +!!! error TS7006: Parameter 'arg' implicitly has an 'any' type. + arg.strProp = "hello"; + } + } + } \ No newline at end of file diff --git a/tests/baselines/reference/contextuallyTypedClassExpressionMethodDeclaration02.js b/tests/baselines/reference/contextuallyTypedClassExpressionMethodDeclaration02.js new file mode 100644 index 0000000000..43e9134689 --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedClassExpressionMethodDeclaration02.js @@ -0,0 +1,92 @@ +//// [contextuallyTypedClassExpressionMethodDeclaration02.ts] + +interface A { + numProp: number; +} + +interface B { + strProp: string; +} + +interface Foo { + new (): Bar; +} + +interface Bar { + method1(arg: A): void; + method2(arg: B): void; +} + +function getFoo1(): Foo { + return class { + method1(arg) { + arg.numProp = 10; + } + method2(arg) { + arg.strProp = "hello"; + } + } +} + +function getFoo2(): Foo { + return class { + method1 = (arg) => { + arg.numProp = 10; + } + method2 = (arg) => { + arg.strProp = "hello"; + } + } +} + +function getFoo3(): Foo { + return class { + method1 = function (arg) { + arg.numProp = 10; + } + method2 = function (arg) { + arg.strProp = "hello"; + } + } +} + +//// [contextuallyTypedClassExpressionMethodDeclaration02.js] +function getFoo1() { + return (function () { + function class_1() { + } + class_1.prototype.method1 = function (arg) { + arg.numProp = 10; + }; + class_1.prototype.method2 = function (arg) { + arg.strProp = "hello"; + }; + return class_1; + })(); +} +function getFoo2() { + return (function () { + function class_2() { + this.method1 = function (arg) { + arg.numProp = 10; + }; + this.method2 = function (arg) { + arg.strProp = "hello"; + }; + } + return class_2; + })(); +} +function getFoo3() { + return (function () { + function class_3() { + this.method1 = function (arg) { + arg.numProp = 10; + }; + this.method2 = function (arg) { + arg.strProp = "hello"; + }; + } + return class_3; + })(); +} diff --git a/tests/baselines/reference/contextuallyTypedObjectLiteralMethodDeclaration01.js b/tests/baselines/reference/contextuallyTypedObjectLiteralMethodDeclaration01.js new file mode 100644 index 0000000000..373854114d --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedObjectLiteralMethodDeclaration01.js @@ -0,0 +1,79 @@ +//// [contextuallyTypedObjectLiteralMethodDeclaration01.ts] + +interface A { + numProp: number; +} + +interface B { + strProp: string; +} + +interface Foo { + method1(arg: A): void; + method2(arg: B): void; +} + +function getFoo1(): Foo { + return { + method1(arg) { + arg.numProp = 10; + }, + method2(arg) { + arg.strProp = "hello"; + } + } +} + +function getFoo2(): Foo { + return { + method1: (arg) => { + arg.numProp = 10; + }, + method2: (arg) => { + arg.strProp = "hello"; + } + } +} + +function getFoo3(): Foo { + return { + method1: function (arg) { + arg.numProp = 10; + }, + method2: function (arg) { + arg.strProp = "hello"; + } + } +} + +//// [contextuallyTypedObjectLiteralMethodDeclaration01.js] +function getFoo1() { + return { + method1: function (arg) { + arg.numProp = 10; + }, + method2: function (arg) { + arg.strProp = "hello"; + } + }; +} +function getFoo2() { + return { + method1: function (arg) { + arg.numProp = 10; + }, + method2: function (arg) { + arg.strProp = "hello"; + } + }; +} +function getFoo3() { + return { + method1: function (arg) { + arg.numProp = 10; + }, + method2: function (arg) { + arg.strProp = "hello"; + } + }; +} diff --git a/tests/baselines/reference/contextuallyTypedObjectLiteralMethodDeclaration01.symbols b/tests/baselines/reference/contextuallyTypedObjectLiteralMethodDeclaration01.symbols new file mode 100644 index 0000000000..3c26110157 --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedObjectLiteralMethodDeclaration01.symbols @@ -0,0 +1,110 @@ +=== tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedObjectLiteralMethodDeclaration01.ts === + +interface A { +>A : Symbol(A, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 0, 0)) + + numProp: number; +>numProp : Symbol(numProp, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 1, 13)) +} + +interface B { +>B : Symbol(B, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 3, 1)) + + strProp: string; +>strProp : Symbol(strProp, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 5, 14)) +} + +interface Foo { +>Foo : Symbol(Foo, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 7, 1)) + + method1(arg: A): void; +>method1 : Symbol(method1, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 9, 15)) +>arg : Symbol(arg, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 10, 12)) +>A : Symbol(A, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 0, 0)) + + method2(arg: B): void; +>method2 : Symbol(method2, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 10, 26)) +>arg : Symbol(arg, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 11, 12)) +>B : Symbol(B, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 3, 1)) +} + +function getFoo1(): Foo { +>getFoo1 : Symbol(getFoo1, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 12, 1)) +>Foo : Symbol(Foo, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 7, 1)) + + return { + method1(arg) { +>method1 : Symbol(method1, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 15, 12)) +>arg : Symbol(arg, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 16, 16)) + + arg.numProp = 10; +>arg.numProp : Symbol(A.numProp, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 1, 13)) +>arg : Symbol(arg, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 16, 16)) +>numProp : Symbol(A.numProp, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 1, 13)) + + }, + method2(arg) { +>method2 : Symbol(method2, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 18, 10)) +>arg : Symbol(arg, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 19, 16)) + + arg.strProp = "hello"; +>arg.strProp : Symbol(B.strProp, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 5, 14)) +>arg : Symbol(arg, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 19, 16)) +>strProp : Symbol(B.strProp, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 5, 14)) + } + } +} + +function getFoo2(): Foo { +>getFoo2 : Symbol(getFoo2, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 23, 1)) +>Foo : Symbol(Foo, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 7, 1)) + + return { + method1: (arg) => { +>method1 : Symbol(method1, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 26, 12)) +>arg : Symbol(arg, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 27, 18)) + + arg.numProp = 10; +>arg.numProp : Symbol(A.numProp, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 1, 13)) +>arg : Symbol(arg, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 27, 18)) +>numProp : Symbol(A.numProp, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 1, 13)) + + }, + method2: (arg) => { +>method2 : Symbol(method2, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 29, 10)) +>arg : Symbol(arg, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 30, 18)) + + arg.strProp = "hello"; +>arg.strProp : Symbol(B.strProp, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 5, 14)) +>arg : Symbol(arg, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 30, 18)) +>strProp : Symbol(B.strProp, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 5, 14)) + } + } +} + +function getFoo3(): Foo { +>getFoo3 : Symbol(getFoo3, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 34, 1)) +>Foo : Symbol(Foo, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 7, 1)) + + return { + method1: function (arg) { +>method1 : Symbol(method1, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 37, 12)) +>arg : Symbol(arg, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 38, 27)) + + arg.numProp = 10; +>arg.numProp : Symbol(A.numProp, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 1, 13)) +>arg : Symbol(arg, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 38, 27)) +>numProp : Symbol(A.numProp, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 1, 13)) + + }, + method2: function (arg) { +>method2 : Symbol(method2, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 40, 10)) +>arg : Symbol(arg, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 41, 27)) + + arg.strProp = "hello"; +>arg.strProp : Symbol(B.strProp, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 5, 14)) +>arg : Symbol(arg, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 41, 27)) +>strProp : Symbol(B.strProp, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 5, 14)) + } + } +} diff --git a/tests/baselines/reference/contextuallyTypedObjectLiteralMethodDeclaration01.types b/tests/baselines/reference/contextuallyTypedObjectLiteralMethodDeclaration01.types new file mode 100644 index 0000000000..dcb25792fe --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedObjectLiteralMethodDeclaration01.types @@ -0,0 +1,132 @@ +=== tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedObjectLiteralMethodDeclaration01.ts === + +interface A { +>A : A + + numProp: number; +>numProp : number +} + +interface B { +>B : B + + strProp: string; +>strProp : string +} + +interface Foo { +>Foo : Foo + + method1(arg: A): void; +>method1 : (arg: A) => void +>arg : A +>A : A + + method2(arg: B): void; +>method2 : (arg: B) => void +>arg : B +>B : B +} + +function getFoo1(): Foo { +>getFoo1 : () => Foo +>Foo : Foo + + return { +>{ method1(arg) { arg.numProp = 10; }, method2(arg) { arg.strProp = "hello"; } } : { method1(arg: A): void; method2(arg: B): void; } + + method1(arg) { +>method1 : (arg: A) => void +>arg : A + + arg.numProp = 10; +>arg.numProp = 10 : number +>arg.numProp : number +>arg : A +>numProp : number +>10 : number + + }, + method2(arg) { +>method2 : (arg: B) => void +>arg : B + + arg.strProp = "hello"; +>arg.strProp = "hello" : string +>arg.strProp : string +>arg : B +>strProp : string +>"hello" : string + } + } +} + +function getFoo2(): Foo { +>getFoo2 : () => Foo +>Foo : Foo + + return { +>{ method1: (arg) => { arg.numProp = 10; }, method2: (arg) => { arg.strProp = "hello"; } } : { method1: (arg: A) => void; method2: (arg: B) => void; } + + method1: (arg) => { +>method1 : (arg: A) => void +>(arg) => { arg.numProp = 10; } : (arg: A) => void +>arg : A + + arg.numProp = 10; +>arg.numProp = 10 : number +>arg.numProp : number +>arg : A +>numProp : number +>10 : number + + }, + method2: (arg) => { +>method2 : (arg: B) => void +>(arg) => { arg.strProp = "hello"; } : (arg: B) => void +>arg : B + + arg.strProp = "hello"; +>arg.strProp = "hello" : string +>arg.strProp : string +>arg : B +>strProp : string +>"hello" : string + } + } +} + +function getFoo3(): Foo { +>getFoo3 : () => Foo +>Foo : Foo + + return { +>{ method1: function (arg) { arg.numProp = 10; }, method2: function (arg) { arg.strProp = "hello"; } } : { method1: (arg: A) => void; method2: (arg: B) => void; } + + method1: function (arg) { +>method1 : (arg: A) => void +>function (arg) { arg.numProp = 10; } : (arg: A) => void +>arg : A + + arg.numProp = 10; +>arg.numProp = 10 : number +>arg.numProp : number +>arg : A +>numProp : number +>10 : number + + }, + method2: function (arg) { +>method2 : (arg: B) => void +>function (arg) { arg.strProp = "hello"; } : (arg: B) => void +>arg : B + + arg.strProp = "hello"; +>arg.strProp = "hello" : string +>arg.strProp : string +>arg : B +>strProp : string +>"hello" : string + } + } +}