diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 07996e0bcdd..c8cfcaae081 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11709,7 +11709,7 @@ namespace ts { if (!node) return false; switch (node.kind) { case SyntaxKind.Identifier: - return (node).escapedText === "arguments" && isExpressionNode(node); + return (node).escapedText === argumentsSymbol.escapedName && getResolvedSymbol(node) === argumentsSymbol; case SyntaxKind.PropertyDeclaration: case SyntaxKind.MethodDeclaration: @@ -11718,6 +11718,10 @@ namespace ts { return (node).name!.kind === SyntaxKind.ComputedPropertyName && traverse((node).name!); + case SyntaxKind.PropertyAccessExpression: + case SyntaxKind.ElementAccessExpression: + return traverse((node).expression); + default: return !nodeStartsNewLexicalEnvironment(node) && !isPartOfTypeNode(node) && !!forEachChild(node, traverse); } diff --git a/tests/baselines/reference/argumentsReferenceInConstructor1_Js.js b/tests/baselines/reference/argumentsReferenceInConstructor1_Js.js new file mode 100644 index 00000000000..d5e50ae78cb --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInConstructor1_Js.js @@ -0,0 +1,31 @@ +//// [a.js] +class A { + /** + * Constructor + * + * @param {object} [foo={}] + */ + constructor(foo = {}) { + /** + * @type object + */ + this.arguments = foo; + } +} + + + + +//// [a.d.ts] +declare class A { + /** + * Constructor + * + * @param {object} [foo={}] + */ + constructor(foo?: object); + /** + * @type object + */ + arguments: object; +} diff --git a/tests/baselines/reference/argumentsReferenceInConstructor1_Js.symbols b/tests/baselines/reference/argumentsReferenceInConstructor1_Js.symbols new file mode 100644 index 00000000000..93a05fdae9f --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInConstructor1_Js.symbols @@ -0,0 +1,23 @@ +=== /a.js === +class A { +>A : Symbol(A, Decl(a.js, 0, 0)) + + /** + * Constructor + * + * @param {object} [foo={}] + */ + constructor(foo = {}) { +>foo : Symbol(foo, Decl(a.js, 6, 13)) + + /** + * @type object + */ + this.arguments = foo; +>this.arguments : Symbol(A.arguments, Decl(a.js, 6, 24)) +>this : Symbol(A, Decl(a.js, 0, 0)) +>arguments : Symbol(A.arguments, Decl(a.js, 6, 24)) +>foo : Symbol(foo, Decl(a.js, 6, 13)) + } +} + diff --git a/tests/baselines/reference/argumentsReferenceInConstructor1_Js.types b/tests/baselines/reference/argumentsReferenceInConstructor1_Js.types new file mode 100644 index 00000000000..e5af557f694 --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInConstructor1_Js.types @@ -0,0 +1,25 @@ +=== /a.js === +class A { +>A : A + + /** + * Constructor + * + * @param {object} [foo={}] + */ + constructor(foo = {}) { +>foo : any +>{} : {} + + /** + * @type object + */ + this.arguments = foo; +>this.arguments = foo : any +>this.arguments : any +>this : this +>arguments : any +>foo : any + } +} + diff --git a/tests/baselines/reference/argumentsReferenceInConstructor2_Js.js b/tests/baselines/reference/argumentsReferenceInConstructor2_Js.js new file mode 100644 index 00000000000..b9ff6f1f95f --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInConstructor2_Js.js @@ -0,0 +1,31 @@ +//// [a.js] +class A { + /** + * Constructor + * + * @param {object} [foo={}] + */ + constructor(foo = {}) { + /** + * @type object + */ + this["arguments"] = foo; + } +} + + + + +//// [a.d.ts] +declare class A { + /** + * Constructor + * + * @param {object} [foo={}] + */ + constructor(foo?: object); + /** + * @type object + */ + arguments: object; +} diff --git a/tests/baselines/reference/argumentsReferenceInConstructor2_Js.symbols b/tests/baselines/reference/argumentsReferenceInConstructor2_Js.symbols new file mode 100644 index 00000000000..8c57e897897 --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInConstructor2_Js.symbols @@ -0,0 +1,22 @@ +=== /a.js === +class A { +>A : Symbol(A, Decl(a.js, 0, 0)) + + /** + * Constructor + * + * @param {object} [foo={}] + */ + constructor(foo = {}) { +>foo : Symbol(foo, Decl(a.js, 6, 13)) + + /** + * @type object + */ + this["arguments"] = foo; +>this : Symbol(A, Decl(a.js, 0, 0)) +>"arguments" : Symbol(A["arguments"], Decl(a.js, 6, 24)) +>foo : Symbol(foo, Decl(a.js, 6, 13)) + } +} + diff --git a/tests/baselines/reference/argumentsReferenceInConstructor2_Js.types b/tests/baselines/reference/argumentsReferenceInConstructor2_Js.types new file mode 100644 index 00000000000..11d31ed941d --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInConstructor2_Js.types @@ -0,0 +1,25 @@ +=== /a.js === +class A { +>A : A + + /** + * Constructor + * + * @param {object} [foo={}] + */ + constructor(foo = {}) { +>foo : any +>{} : {} + + /** + * @type object + */ + this["arguments"] = foo; +>this["arguments"] = foo : any +>this["arguments"] : any +>this : this +>"arguments" : "arguments" +>foo : any + } +} + diff --git a/tests/baselines/reference/argumentsReferenceInConstructor3_Js.js b/tests/baselines/reference/argumentsReferenceInConstructor3_Js.js new file mode 100644 index 00000000000..6c2fd18136b --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInConstructor3_Js.js @@ -0,0 +1,53 @@ +//// [a.js] +class A { + get arguments() { + return { bar: {} }; + } +} + +class B extends A { + /** + * Constructor + * + * @param {object} [foo={}] + */ + constructor(foo = {}) { + super(); + + /** + * @type object + */ + this.foo = foo; + + /** + * @type object + */ + this.bar = super.arguments.foo; + } +} + + + + +//// [a.d.ts] +declare class A { + get arguments(): { + bar: {}; + }; +} +declare class B extends A { + /** + * Constructor + * + * @param {object} [foo={}] + */ + constructor(foo?: object); + /** + * @type object + */ + foo: object; + /** + * @type object + */ + bar: object; +} diff --git a/tests/baselines/reference/argumentsReferenceInConstructor3_Js.symbols b/tests/baselines/reference/argumentsReferenceInConstructor3_Js.symbols new file mode 100644 index 00000000000..1daf9971624 --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInConstructor3_Js.symbols @@ -0,0 +1,49 @@ +=== /a.js === +class A { +>A : Symbol(A, Decl(a.js, 0, 0)) + + get arguments() { +>arguments : Symbol(A.arguments, Decl(a.js, 0, 9)) + + return { bar: {} }; +>bar : Symbol(bar, Decl(a.js, 2, 10)) + } +} + +class B extends A { +>B : Symbol(B, Decl(a.js, 4, 1)) +>A : Symbol(A, Decl(a.js, 0, 0)) + + /** + * Constructor + * + * @param {object} [foo={}] + */ + constructor(foo = {}) { +>foo : Symbol(foo, Decl(a.js, 12, 13)) + + super(); +>super : Symbol(A, Decl(a.js, 0, 0)) + + /** + * @type object + */ + this.foo = foo; +>this.foo : Symbol(B.foo, Decl(a.js, 13, 10)) +>this : Symbol(B, Decl(a.js, 4, 1)) +>foo : Symbol(B.foo, Decl(a.js, 13, 10)) +>foo : Symbol(foo, Decl(a.js, 12, 13)) + + /** + * @type object + */ + this.bar = super.arguments.foo; +>this.bar : Symbol(B.bar, Decl(a.js, 18, 17)) +>this : Symbol(B, Decl(a.js, 4, 1)) +>bar : Symbol(B.bar, Decl(a.js, 18, 17)) +>super.arguments : Symbol(A.arguments, Decl(a.js, 0, 9)) +>super : Symbol(A, Decl(a.js, 0, 0)) +>arguments : Symbol(A.arguments, Decl(a.js, 0, 9)) + } +} + diff --git a/tests/baselines/reference/argumentsReferenceInConstructor3_Js.types b/tests/baselines/reference/argumentsReferenceInConstructor3_Js.types new file mode 100644 index 00000000000..ccdf9b66067 --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInConstructor3_Js.types @@ -0,0 +1,57 @@ +=== /a.js === +class A { +>A : A + + get arguments() { +>arguments : { bar: {}; } + + return { bar: {} }; +>{ bar: {} } : { bar: {}; } +>bar : {} +>{} : {} + } +} + +class B extends A { +>B : B +>A : A + + /** + * Constructor + * + * @param {object} [foo={}] + */ + constructor(foo = {}) { +>foo : any +>{} : {} + + super(); +>super() : void +>super : typeof A + + /** + * @type object + */ + this.foo = foo; +>this.foo = foo : any +>this.foo : any +>this : this +>foo : any +>foo : any + + /** + * @type object + */ + this.bar = super.arguments.foo; +>this.bar = super.arguments.foo : any +>this.bar : any +>this : this +>bar : any +>super.arguments.foo : any +>super.arguments : { bar: {}; } +>super : A +>arguments : { bar: {}; } +>foo : any + } +} + diff --git a/tests/baselines/reference/argumentsReferenceInConstructor4_Js.js b/tests/baselines/reference/argumentsReferenceInConstructor4_Js.js new file mode 100644 index 00000000000..ae51fceeca1 --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInConstructor4_Js.js @@ -0,0 +1,72 @@ +//// [a.js] +class A { + /** + * Constructor + * + * @param {object} [foo={}] + */ + constructor(foo = {}) { + const key = "bar"; + + /** + * @type object + */ + this.foo = foo; + + /** + * @type object + */ + const arguments = this.arguments; + + /** + * @type object + */ + this.bar = arguments.bar; + + /** + * @type object + */ + this.baz = arguments[key]; + + /** + * @type object + */ + this.options = arguments; + } + + get arguments() { + return { bar: {} }; + } +} + + + + +//// [a.d.ts] +declare class A { + /** + * Constructor + * + * @param {object} [foo={}] + */ + constructor(foo?: object); + /** + * @type object + */ + foo: object; + /** + * @type object + */ + bar: object; + /** + * @type object + */ + baz: object; + /** + * @type object + */ + options: object; + get arguments(): { + bar: {}; + }; +} diff --git a/tests/baselines/reference/argumentsReferenceInConstructor4_Js.symbols b/tests/baselines/reference/argumentsReferenceInConstructor4_Js.symbols new file mode 100644 index 00000000000..131426bfe2c --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInConstructor4_Js.symbols @@ -0,0 +1,70 @@ +=== /a.js === +class A { +>A : Symbol(A, Decl(a.js, 0, 0)) + + /** + * Constructor + * + * @param {object} [foo={}] + */ + constructor(foo = {}) { +>foo : Symbol(foo, Decl(a.js, 6, 13)) + + const key = "bar"; +>key : Symbol(key, Decl(a.js, 7, 7)) + + /** + * @type object + */ + this.foo = foo; +>this.foo : Symbol(A.foo, Decl(a.js, 7, 20)) +>this : Symbol(A, Decl(a.js, 0, 0)) +>foo : Symbol(A.foo, Decl(a.js, 7, 20)) +>foo : Symbol(foo, Decl(a.js, 6, 13)) + + /** + * @type object + */ + const arguments = this.arguments; +>arguments : Symbol(arguments, Decl(a.js, 17, 7)) +>this.arguments : Symbol(A.arguments, Decl(a.js, 33, 2)) +>this : Symbol(A, Decl(a.js, 0, 0)) +>arguments : Symbol(A.arguments, Decl(a.js, 33, 2)) + + /** + * @type object + */ + this.bar = arguments.bar; +>this.bar : Symbol(A.bar, Decl(a.js, 17, 35)) +>this : Symbol(A, Decl(a.js, 0, 0)) +>bar : Symbol(A.bar, Decl(a.js, 17, 35)) +>arguments : Symbol(arguments, Decl(a.js, 17, 7)) + + /** + * @type object + */ + this.baz = arguments[key]; +>this.baz : Symbol(A.baz, Decl(a.js, 22, 27)) +>this : Symbol(A, Decl(a.js, 0, 0)) +>baz : Symbol(A.baz, Decl(a.js, 22, 27)) +>arguments : Symbol(arguments, Decl(a.js, 17, 7)) +>key : Symbol(key, Decl(a.js, 7, 7)) + + /** + * @type object + */ + this.options = arguments; +>this.options : Symbol(A.options, Decl(a.js, 27, 28)) +>this : Symbol(A, Decl(a.js, 0, 0)) +>options : Symbol(A.options, Decl(a.js, 27, 28)) +>arguments : Symbol(arguments, Decl(a.js, 17, 7)) + } + + get arguments() { +>arguments : Symbol(A.arguments, Decl(a.js, 33, 2)) + + return { bar: {} }; +>bar : Symbol(bar, Decl(a.js, 36, 10)) + } +} + diff --git a/tests/baselines/reference/argumentsReferenceInConstructor4_Js.types b/tests/baselines/reference/argumentsReferenceInConstructor4_Js.types new file mode 100644 index 00000000000..8b43e3d7ddb --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInConstructor4_Js.types @@ -0,0 +1,81 @@ +=== /a.js === +class A { +>A : A + + /** + * Constructor + * + * @param {object} [foo={}] + */ + constructor(foo = {}) { +>foo : any +>{} : {} + + const key = "bar"; +>key : "bar" +>"bar" : "bar" + + /** + * @type object + */ + this.foo = foo; +>this.foo = foo : any +>this.foo : any +>this : this +>foo : any +>foo : any + + /** + * @type object + */ + const arguments = this.arguments; +>arguments : any +>this.arguments : { bar: {}; } +>this : this +>arguments : { bar: {}; } + + /** + * @type object + */ + this.bar = arguments.bar; +>this.bar = arguments.bar : any +>this.bar : any +>this : this +>bar : any +>arguments.bar : any +>arguments : any +>bar : any + + /** + * @type object + */ + this.baz = arguments[key]; +>this.baz = arguments[key] : any +>this.baz : any +>this : this +>baz : any +>arguments[key] : any +>arguments : any +>key : "bar" + + /** + * @type object + */ + this.options = arguments; +>this.options = arguments : any +>this.options : any +>this : this +>options : any +>arguments : any + } + + get arguments() { +>arguments : { bar: {}; } + + return { bar: {} }; +>{ bar: {} } : { bar: {}; } +>bar : {} +>{} : {} + } +} + diff --git a/tests/baselines/reference/argumentsReferenceInConstructor5_Js.js b/tests/baselines/reference/argumentsReferenceInConstructor5_Js.js new file mode 100644 index 00000000000..84f6472d318 --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInConstructor5_Js.js @@ -0,0 +1,47 @@ +//// [a.js] +const bar = { + arguments: {} +} + +class A { + /** + * Constructor + * + * @param {object} [foo={}] + */ + constructor(foo = {}) { + /** + * @type object + */ + this.foo = foo; + + /** + * @type object + */ + this.bar = bar.arguments; + } +} + + + + +//// [a.d.ts] +declare namespace bar { + const arguments: {}; +} +declare class A { + /** + * Constructor + * + * @param {object} [foo={}] + */ + constructor(foo?: object); + /** + * @type object + */ + foo: object; + /** + * @type object + */ + bar: object; +} diff --git a/tests/baselines/reference/argumentsReferenceInConstructor5_Js.symbols b/tests/baselines/reference/argumentsReferenceInConstructor5_Js.symbols new file mode 100644 index 00000000000..3ed1c58a4a0 --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInConstructor5_Js.symbols @@ -0,0 +1,41 @@ +=== /a.js === +const bar = { +>bar : Symbol(bar, Decl(a.js, 0, 5)) + + arguments: {} +>arguments : Symbol(arguments, Decl(a.js, 0, 13)) +} + +class A { +>A : Symbol(A, Decl(a.js, 2, 1)) + + /** + * Constructor + * + * @param {object} [foo={}] + */ + constructor(foo = {}) { +>foo : Symbol(foo, Decl(a.js, 10, 13)) + + /** + * @type object + */ + this.foo = foo; +>this.foo : Symbol(A.foo, Decl(a.js, 10, 24)) +>this : Symbol(A, Decl(a.js, 2, 1)) +>foo : Symbol(A.foo, Decl(a.js, 10, 24)) +>foo : Symbol(foo, Decl(a.js, 10, 13)) + + /** + * @type object + */ + this.bar = bar.arguments; +>this.bar : Symbol(A.bar, Decl(a.js, 14, 17)) +>this : Symbol(A, Decl(a.js, 2, 1)) +>bar : Symbol(A.bar, Decl(a.js, 14, 17)) +>bar.arguments : Symbol(arguments, Decl(a.js, 0, 13)) +>bar : Symbol(bar, Decl(a.js, 0, 5)) +>arguments : Symbol(arguments, Decl(a.js, 0, 13)) + } +} + diff --git a/tests/baselines/reference/argumentsReferenceInConstructor5_Js.types b/tests/baselines/reference/argumentsReferenceInConstructor5_Js.types new file mode 100644 index 00000000000..0629cc868c2 --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInConstructor5_Js.types @@ -0,0 +1,46 @@ +=== /a.js === +const bar = { +>bar : { arguments: {}; } +>{ arguments: {}} : { arguments: {}; } + + arguments: {} +>arguments : {} +>{} : {} +} + +class A { +>A : A + + /** + * Constructor + * + * @param {object} [foo={}] + */ + constructor(foo = {}) { +>foo : any +>{} : {} + + /** + * @type object + */ + this.foo = foo; +>this.foo = foo : any +>this.foo : any +>this : this +>foo : any +>foo : any + + /** + * @type object + */ + this.bar = bar.arguments; +>this.bar = bar.arguments : {} +>this.bar : any +>this : this +>bar : any +>bar.arguments : {} +>bar : { arguments: {}; } +>arguments : {} + } +} + diff --git a/tests/baselines/reference/argumentsReferenceInConstructor6_Js.js b/tests/baselines/reference/argumentsReferenceInConstructor6_Js.js new file mode 100644 index 00000000000..14ea6dfb8f4 --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInConstructor6_Js.js @@ -0,0 +1,21 @@ +//// [a.js] +class A { + constructor() { + /** + * @type object + */ + this.foo = arguments; + } +} + + + + +//// [a.d.ts] +declare class A { + constructor(...args: any[]); + /** + * @type object + */ + foo: object; +} diff --git a/tests/baselines/reference/argumentsReferenceInConstructor6_Js.symbols b/tests/baselines/reference/argumentsReferenceInConstructor6_Js.symbols new file mode 100644 index 00000000000..09608b772c5 --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInConstructor6_Js.symbols @@ -0,0 +1,16 @@ +=== /a.js === +class A { +>A : Symbol(A, Decl(a.js, 0, 0)) + + constructor() { + /** + * @type object + */ + this.foo = arguments; +>this.foo : Symbol(A.foo, Decl(a.js, 1, 16)) +>this : Symbol(A, Decl(a.js, 0, 0)) +>foo : Symbol(A.foo, Decl(a.js, 1, 16)) +>arguments : Symbol(arguments) + } +} + diff --git a/tests/baselines/reference/argumentsReferenceInConstructor6_Js.types b/tests/baselines/reference/argumentsReferenceInConstructor6_Js.types new file mode 100644 index 00000000000..af93a74e105 --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInConstructor6_Js.types @@ -0,0 +1,17 @@ +=== /a.js === +class A { +>A : A + + constructor() { + /** + * @type object + */ + this.foo = arguments; +>this.foo = arguments : IArguments +>this.foo : any +>this : this +>foo : any +>arguments : IArguments + } +} + diff --git a/tests/baselines/reference/argumentsReferenceInConstructor7_Js.js b/tests/baselines/reference/argumentsReferenceInConstructor7_Js.js new file mode 100644 index 00000000000..d94ec834445 --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInConstructor7_Js.js @@ -0,0 +1,21 @@ +//// [a.js] +class A { + constructor() { + /** + * @type Function + */ + this.callee = arguments.callee; + } +} + + + + +//// [a.d.ts] +declare class A { + constructor(...args: any[]); + /** + * @type Function + */ + callee: Function; +} diff --git a/tests/baselines/reference/argumentsReferenceInConstructor7_Js.symbols b/tests/baselines/reference/argumentsReferenceInConstructor7_Js.symbols new file mode 100644 index 00000000000..35ee8a81d98 --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInConstructor7_Js.symbols @@ -0,0 +1,18 @@ +=== /a.js === +class A { +>A : Symbol(A, Decl(a.js, 0, 0)) + + constructor() { + /** + * @type Function + */ + this.callee = arguments.callee; +>this.callee : Symbol(A.callee, Decl(a.js, 1, 16)) +>this : Symbol(A, Decl(a.js, 0, 0)) +>callee : Symbol(A.callee, Decl(a.js, 1, 16)) +>arguments.callee : Symbol(IArguments.callee, Decl(lib.es5.d.ts, --, --)) +>arguments : Symbol(arguments) +>callee : Symbol(IArguments.callee, Decl(lib.es5.d.ts, --, --)) + } +} + diff --git a/tests/baselines/reference/argumentsReferenceInConstructor7_Js.types b/tests/baselines/reference/argumentsReferenceInConstructor7_Js.types new file mode 100644 index 00000000000..bf4fb7d4a7b --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInConstructor7_Js.types @@ -0,0 +1,19 @@ +=== /a.js === +class A { +>A : A + + constructor() { + /** + * @type Function + */ + this.callee = arguments.callee; +>this.callee = arguments.callee : Function +>this.callee : Function +>this : this +>callee : Function +>arguments.callee : Function +>arguments : IArguments +>callee : Function + } +} + diff --git a/tests/baselines/reference/argumentsReferenceInMethod1_Js.js b/tests/baselines/reference/argumentsReferenceInMethod1_Js.js new file mode 100644 index 00000000000..1daff0bb9d1 --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInMethod1_Js.js @@ -0,0 +1,27 @@ +//// [a.js] +class A { + /** + * @param {object} [foo={}] + */ + m(foo = {}) { + /** + * @type object + */ + this.arguments = foo; + } +} + + + + +//// [a.d.ts] +declare class A { + /** + * @param {object} [foo={}] + */ + m(foo?: object): void; + /** + * @type object + */ + arguments: object; +} diff --git a/tests/baselines/reference/argumentsReferenceInMethod1_Js.symbols b/tests/baselines/reference/argumentsReferenceInMethod1_Js.symbols new file mode 100644 index 00000000000..3f32602d9c5 --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInMethod1_Js.symbols @@ -0,0 +1,22 @@ +=== /a.js === +class A { +>A : Symbol(A, Decl(a.js, 0, 0)) + + /** + * @param {object} [foo={}] + */ + m(foo = {}) { +>m : Symbol(A.m, Decl(a.js, 0, 9)) +>foo : Symbol(foo, Decl(a.js, 4, 3)) + + /** + * @type object + */ + this.arguments = foo; +>this.arguments : Symbol(A.arguments, Decl(a.js, 4, 14)) +>this : Symbol(A, Decl(a.js, 0, 0)) +>arguments : Symbol(A.arguments, Decl(a.js, 4, 14)) +>foo : Symbol(foo, Decl(a.js, 4, 3)) + } +} + diff --git a/tests/baselines/reference/argumentsReferenceInMethod1_Js.types b/tests/baselines/reference/argumentsReferenceInMethod1_Js.types new file mode 100644 index 00000000000..828e96065df --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInMethod1_Js.types @@ -0,0 +1,24 @@ +=== /a.js === +class A { +>A : A + + /** + * @param {object} [foo={}] + */ + m(foo = {}) { +>m : (foo?: object) => void +>foo : any +>{} : {} + + /** + * @type object + */ + this.arguments = foo; +>this.arguments = foo : any +>this.arguments : any +>this : this +>arguments : any +>foo : any + } +} + diff --git a/tests/baselines/reference/argumentsReferenceInMethod2_Js.js b/tests/baselines/reference/argumentsReferenceInMethod2_Js.js new file mode 100644 index 00000000000..2f7a5f5dbc6 --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInMethod2_Js.js @@ -0,0 +1,27 @@ +//// [a.js] +class A { + /** + * @param {object} [foo={}] + */ + m(foo = {}) { + /** + * @type object + */ + this["arguments"] = foo; + } +} + + + + +//// [a.d.ts] +declare class A { + /** + * @param {object} [foo={}] + */ + m(foo?: object): void; + /** + * @type object + */ + arguments: object; +} diff --git a/tests/baselines/reference/argumentsReferenceInMethod2_Js.symbols b/tests/baselines/reference/argumentsReferenceInMethod2_Js.symbols new file mode 100644 index 00000000000..5d01debb660 --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInMethod2_Js.symbols @@ -0,0 +1,21 @@ +=== /a.js === +class A { +>A : Symbol(A, Decl(a.js, 0, 0)) + + /** + * @param {object} [foo={}] + */ + m(foo = {}) { +>m : Symbol(A.m, Decl(a.js, 0, 9)) +>foo : Symbol(foo, Decl(a.js, 4, 3)) + + /** + * @type object + */ + this["arguments"] = foo; +>this : Symbol(A, Decl(a.js, 0, 0)) +>"arguments" : Symbol(A["arguments"], Decl(a.js, 4, 14)) +>foo : Symbol(foo, Decl(a.js, 4, 3)) + } +} + diff --git a/tests/baselines/reference/argumentsReferenceInMethod2_Js.types b/tests/baselines/reference/argumentsReferenceInMethod2_Js.types new file mode 100644 index 00000000000..dae5b75fe5d --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInMethod2_Js.types @@ -0,0 +1,24 @@ +=== /a.js === +class A { +>A : A + + /** + * @param {object} [foo={}] + */ + m(foo = {}) { +>m : (foo?: object) => void +>foo : any +>{} : {} + + /** + * @type object + */ + this["arguments"] = foo; +>this["arguments"] = foo : any +>this["arguments"] : any +>this : this +>"arguments" : "arguments" +>foo : any + } +} + diff --git a/tests/baselines/reference/argumentsReferenceInMethod3_Js.js b/tests/baselines/reference/argumentsReferenceInMethod3_Js.js new file mode 100644 index 00000000000..b1833920174 --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInMethod3_Js.js @@ -0,0 +1,47 @@ +//// [a.js] +class A { + get arguments() { + return { bar: {} }; + } +} + +class B extends A { + /** + * @param {object} [foo={}] + */ + m(foo = {}) { + /** + * @type object + */ + this.x = foo; + + /** + * @type object + */ + this.y = super.arguments.bar; + } +} + + + + +//// [a.d.ts] +declare class A { + get arguments(): { + bar: {}; + }; +} +declare class B extends A { + /** + * @param {object} [foo={}] + */ + m(foo?: object): void; + /** + * @type object + */ + x: object; + /** + * @type object + */ + y: object; +} diff --git a/tests/baselines/reference/argumentsReferenceInMethod3_Js.symbols b/tests/baselines/reference/argumentsReferenceInMethod3_Js.symbols new file mode 100644 index 00000000000..580e9aa98e8 --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInMethod3_Js.symbols @@ -0,0 +1,47 @@ +=== /a.js === +class A { +>A : Symbol(A, Decl(a.js, 0, 0)) + + get arguments() { +>arguments : Symbol(A.arguments, Decl(a.js, 0, 9)) + + return { bar: {} }; +>bar : Symbol(bar, Decl(a.js, 2, 10)) + } +} + +class B extends A { +>B : Symbol(B, Decl(a.js, 4, 1)) +>A : Symbol(A, Decl(a.js, 0, 0)) + + /** + * @param {object} [foo={}] + */ + m(foo = {}) { +>m : Symbol(B.m, Decl(a.js, 6, 19)) +>foo : Symbol(foo, Decl(a.js, 10, 3)) + + /** + * @type object + */ + this.x = foo; +>this.x : Symbol(B.x, Decl(a.js, 10, 14)) +>this : Symbol(B, Decl(a.js, 4, 1)) +>x : Symbol(B.x, Decl(a.js, 10, 14)) +>foo : Symbol(foo, Decl(a.js, 10, 3)) + + /** + * @type object + */ + this.y = super.arguments.bar; +>this.y : Symbol(B.y, Decl(a.js, 14, 15)) +>this : Symbol(B, Decl(a.js, 4, 1)) +>y : Symbol(B.y, Decl(a.js, 14, 15)) +>super.arguments.bar : Symbol(bar, Decl(a.js, 2, 10)) +>super.arguments : Symbol(A.arguments, Decl(a.js, 0, 9)) +>super : Symbol(A, Decl(a.js, 0, 0)) +>arguments : Symbol(A.arguments, Decl(a.js, 0, 9)) +>bar : Symbol(bar, Decl(a.js, 2, 10)) + } +} + diff --git a/tests/baselines/reference/argumentsReferenceInMethod3_Js.types b/tests/baselines/reference/argumentsReferenceInMethod3_Js.types new file mode 100644 index 00000000000..641078846e7 --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInMethod3_Js.types @@ -0,0 +1,52 @@ +=== /a.js === +class A { +>A : A + + get arguments() { +>arguments : { bar: {}; } + + return { bar: {} }; +>{ bar: {} } : { bar: {}; } +>bar : {} +>{} : {} + } +} + +class B extends A { +>B : B +>A : A + + /** + * @param {object} [foo={}] + */ + m(foo = {}) { +>m : (foo?: object) => void +>foo : any +>{} : {} + + /** + * @type object + */ + this.x = foo; +>this.x = foo : any +>this.x : any +>this : this +>x : any +>foo : any + + /** + * @type object + */ + this.y = super.arguments.bar; +>this.y = super.arguments.bar : {} +>this.y : any +>this : this +>y : any +>super.arguments.bar : {} +>super.arguments : { bar: {}; } +>super : A +>arguments : { bar: {}; } +>bar : {} + } +} + diff --git a/tests/baselines/reference/argumentsReferenceInMethod4_Js.js b/tests/baselines/reference/argumentsReferenceInMethod4_Js.js new file mode 100644 index 00000000000..3b2c0f71da3 --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInMethod4_Js.js @@ -0,0 +1,68 @@ +//// [a.js] +class A { + /** + * @param {object} [foo={}] + */ + m(foo = {}) { + const key = "bar"; + + /** + * @type object + */ + this.foo = foo; + + /** + * @type object + */ + const arguments = this.arguments; + + /** + * @type object + */ + this.bar = arguments.bar; + + /** + * @type object + */ + this.baz = arguments[key]; + + /** + * @type object + */ + this.options = arguments; + } + + get arguments() { + return { bar: {} }; + } +} + + + + +//// [a.d.ts] +declare class A { + /** + * @param {object} [foo={}] + */ + m(foo?: object): void; + /** + * @type object + */ + foo: object; + /** + * @type object + */ + bar: object; + /** + * @type object + */ + baz: object; + /** + * @type object + */ + options: object; + get arguments(): { + bar: {}; + }; +} diff --git a/tests/baselines/reference/argumentsReferenceInMethod4_Js.symbols b/tests/baselines/reference/argumentsReferenceInMethod4_Js.symbols new file mode 100644 index 00000000000..cbbecd4989b --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInMethod4_Js.symbols @@ -0,0 +1,69 @@ +=== /a.js === +class A { +>A : Symbol(A, Decl(a.js, 0, 0)) + + /** + * @param {object} [foo={}] + */ + m(foo = {}) { +>m : Symbol(A.m, Decl(a.js, 0, 9)) +>foo : Symbol(foo, Decl(a.js, 4, 3)) + + const key = "bar"; +>key : Symbol(key, Decl(a.js, 5, 7)) + + /** + * @type object + */ + this.foo = foo; +>this.foo : Symbol(A.foo, Decl(a.js, 5, 20)) +>this : Symbol(A, Decl(a.js, 0, 0)) +>foo : Symbol(A.foo, Decl(a.js, 5, 20)) +>foo : Symbol(foo, Decl(a.js, 4, 3)) + + /** + * @type object + */ + const arguments = this.arguments; +>arguments : Symbol(arguments, Decl(a.js, 15, 7)) +>this.arguments : Symbol(A.arguments, Decl(a.js, 31, 2)) +>this : Symbol(A, Decl(a.js, 0, 0)) +>arguments : Symbol(A.arguments, Decl(a.js, 31, 2)) + + /** + * @type object + */ + this.bar = arguments.bar; +>this.bar : Symbol(A.bar, Decl(a.js, 15, 35)) +>this : Symbol(A, Decl(a.js, 0, 0)) +>bar : Symbol(A.bar, Decl(a.js, 15, 35)) +>arguments : Symbol(arguments, Decl(a.js, 15, 7)) + + /** + * @type object + */ + this.baz = arguments[key]; +>this.baz : Symbol(A.baz, Decl(a.js, 20, 27)) +>this : Symbol(A, Decl(a.js, 0, 0)) +>baz : Symbol(A.baz, Decl(a.js, 20, 27)) +>arguments : Symbol(arguments, Decl(a.js, 15, 7)) +>key : Symbol(key, Decl(a.js, 5, 7)) + + /** + * @type object + */ + this.options = arguments; +>this.options : Symbol(A.options, Decl(a.js, 25, 28)) +>this : Symbol(A, Decl(a.js, 0, 0)) +>options : Symbol(A.options, Decl(a.js, 25, 28)) +>arguments : Symbol(arguments, Decl(a.js, 15, 7)) + } + + get arguments() { +>arguments : Symbol(A.arguments, Decl(a.js, 31, 2)) + + return { bar: {} }; +>bar : Symbol(bar, Decl(a.js, 34, 10)) + } +} + diff --git a/tests/baselines/reference/argumentsReferenceInMethod4_Js.types b/tests/baselines/reference/argumentsReferenceInMethod4_Js.types new file mode 100644 index 00000000000..0e913014741 --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInMethod4_Js.types @@ -0,0 +1,80 @@ +=== /a.js === +class A { +>A : A + + /** + * @param {object} [foo={}] + */ + m(foo = {}) { +>m : (foo?: object) => void +>foo : any +>{} : {} + + const key = "bar"; +>key : "bar" +>"bar" : "bar" + + /** + * @type object + */ + this.foo = foo; +>this.foo = foo : any +>this.foo : any +>this : this +>foo : any +>foo : any + + /** + * @type object + */ + const arguments = this.arguments; +>arguments : any +>this.arguments : { bar: {}; } +>this : this +>arguments : { bar: {}; } + + /** + * @type object + */ + this.bar = arguments.bar; +>this.bar = arguments.bar : any +>this.bar : any +>this : this +>bar : any +>arguments.bar : any +>arguments : any +>bar : any + + /** + * @type object + */ + this.baz = arguments[key]; +>this.baz = arguments[key] : any +>this.baz : any +>this : this +>baz : any +>arguments[key] : any +>arguments : any +>key : "bar" + + /** + * @type object + */ + this.options = arguments; +>this.options = arguments : any +>this.options : any +>this : this +>options : any +>arguments : any + } + + get arguments() { +>arguments : { bar: {}; } + + return { bar: {} }; +>{ bar: {} } : { bar: {}; } +>bar : {} +>{} : {} + } +} + diff --git a/tests/baselines/reference/argumentsReferenceInMethod5_Js.js b/tests/baselines/reference/argumentsReferenceInMethod5_Js.js new file mode 100644 index 00000000000..076bdd2f4d7 --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInMethod5_Js.js @@ -0,0 +1,43 @@ +//// [a.js] +const bar = { + arguments: {} +} + +class A { + /** + * @param {object} [foo={}] + */ + m(foo = {}) { + /** + * @type object + */ + this.foo = foo; + + /** + * @type object + */ + this.bar = bar.arguments; + } +} + + + + +//// [a.d.ts] +declare namespace bar { + const arguments: {}; +} +declare class A { + /** + * @param {object} [foo={}] + */ + m(foo?: object): void; + /** + * @type object + */ + foo: object; + /** + * @type object + */ + bar: object; +} diff --git a/tests/baselines/reference/argumentsReferenceInMethod5_Js.symbols b/tests/baselines/reference/argumentsReferenceInMethod5_Js.symbols new file mode 100644 index 00000000000..22d7f105550 --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInMethod5_Js.symbols @@ -0,0 +1,40 @@ +=== /a.js === +const bar = { +>bar : Symbol(bar, Decl(a.js, 0, 5)) + + arguments: {} +>arguments : Symbol(arguments, Decl(a.js, 0, 13)) +} + +class A { +>A : Symbol(A, Decl(a.js, 2, 1)) + + /** + * @param {object} [foo={}] + */ + m(foo = {}) { +>m : Symbol(A.m, Decl(a.js, 4, 9)) +>foo : Symbol(foo, Decl(a.js, 8, 3)) + + /** + * @type object + */ + this.foo = foo; +>this.foo : Symbol(A.foo, Decl(a.js, 8, 14)) +>this : Symbol(A, Decl(a.js, 2, 1)) +>foo : Symbol(A.foo, Decl(a.js, 8, 14)) +>foo : Symbol(foo, Decl(a.js, 8, 3)) + + /** + * @type object + */ + this.bar = bar.arguments; +>this.bar : Symbol(A.bar, Decl(a.js, 12, 17)) +>this : Symbol(A, Decl(a.js, 2, 1)) +>bar : Symbol(A.bar, Decl(a.js, 12, 17)) +>bar.arguments : Symbol(arguments, Decl(a.js, 0, 13)) +>bar : Symbol(bar, Decl(a.js, 0, 5)) +>arguments : Symbol(arguments, Decl(a.js, 0, 13)) + } +} + diff --git a/tests/baselines/reference/argumentsReferenceInMethod5_Js.types b/tests/baselines/reference/argumentsReferenceInMethod5_Js.types new file mode 100644 index 00000000000..edc563a2a27 --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInMethod5_Js.types @@ -0,0 +1,45 @@ +=== /a.js === +const bar = { +>bar : { arguments: {}; } +>{ arguments: {}} : { arguments: {}; } + + arguments: {} +>arguments : {} +>{} : {} +} + +class A { +>A : A + + /** + * @param {object} [foo={}] + */ + m(foo = {}) { +>m : (foo?: object) => void +>foo : any +>{} : {} + + /** + * @type object + */ + this.foo = foo; +>this.foo = foo : any +>this.foo : any +>this : this +>foo : any +>foo : any + + /** + * @type object + */ + this.bar = bar.arguments; +>this.bar = bar.arguments : {} +>this.bar : any +>this : this +>bar : any +>bar.arguments : {} +>bar : { arguments: {}; } +>arguments : {} + } +} + diff --git a/tests/baselines/reference/argumentsReferenceInMethod6_Js.js b/tests/baselines/reference/argumentsReferenceInMethod6_Js.js new file mode 100644 index 00000000000..904981e5e46 --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInMethod6_Js.js @@ -0,0 +1,21 @@ +//// [a.js] +class A { + m() { + /** + * @type object + */ + this.foo = arguments; + } +} + + + + +//// [a.d.ts] +declare class A { + m(...args: any[]): void; + /** + * @type object + */ + foo: object; +} diff --git a/tests/baselines/reference/argumentsReferenceInMethod6_Js.symbols b/tests/baselines/reference/argumentsReferenceInMethod6_Js.symbols new file mode 100644 index 00000000000..a38774b6795 --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInMethod6_Js.symbols @@ -0,0 +1,18 @@ +=== /a.js === +class A { +>A : Symbol(A, Decl(a.js, 0, 0)) + + m() { +>m : Symbol(A.m, Decl(a.js, 0, 9)) + + /** + * @type object + */ + this.foo = arguments; +>this.foo : Symbol(A.foo, Decl(a.js, 1, 6)) +>this : Symbol(A, Decl(a.js, 0, 0)) +>foo : Symbol(A.foo, Decl(a.js, 1, 6)) +>arguments : Symbol(arguments) + } +} + diff --git a/tests/baselines/reference/argumentsReferenceInMethod6_Js.types b/tests/baselines/reference/argumentsReferenceInMethod6_Js.types new file mode 100644 index 00000000000..6874875e316 --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInMethod6_Js.types @@ -0,0 +1,19 @@ +=== /a.js === +class A { +>A : A + + m() { +>m : (...args: any[]) => void + + /** + * @type object + */ + this.foo = arguments; +>this.foo = arguments : IArguments +>this.foo : any +>this : this +>foo : any +>arguments : IArguments + } +} + diff --git a/tests/baselines/reference/argumentsReferenceInMethod7_Js.js b/tests/baselines/reference/argumentsReferenceInMethod7_Js.js new file mode 100644 index 00000000000..a7926a3252d --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInMethod7_Js.js @@ -0,0 +1,21 @@ +//// [a.js] +class A { + m() { + /** + * @type Function + */ + this.callee = arguments.callee; + } +} + + + + +//// [a.d.ts] +declare class A { + m(...args: any[]): void; + /** + * @type Function + */ + callee: Function; +} diff --git a/tests/baselines/reference/argumentsReferenceInMethod7_Js.symbols b/tests/baselines/reference/argumentsReferenceInMethod7_Js.symbols new file mode 100644 index 00000000000..630ffe9c05f --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInMethod7_Js.symbols @@ -0,0 +1,20 @@ +=== /a.js === +class A { +>A : Symbol(A, Decl(a.js, 0, 0)) + + m() { +>m : Symbol(A.m, Decl(a.js, 0, 9)) + + /** + * @type Function + */ + this.callee = arguments.callee; +>this.callee : Symbol(A.callee, Decl(a.js, 1, 6)) +>this : Symbol(A, Decl(a.js, 0, 0)) +>callee : Symbol(A.callee, Decl(a.js, 1, 6)) +>arguments.callee : Symbol(IArguments.callee, Decl(lib.es5.d.ts, --, --)) +>arguments : Symbol(arguments) +>callee : Symbol(IArguments.callee, Decl(lib.es5.d.ts, --, --)) + } +} + diff --git a/tests/baselines/reference/argumentsReferenceInMethod7_Js.types b/tests/baselines/reference/argumentsReferenceInMethod7_Js.types new file mode 100644 index 00000000000..eda08df6a3e --- /dev/null +++ b/tests/baselines/reference/argumentsReferenceInMethod7_Js.types @@ -0,0 +1,21 @@ +=== /a.js === +class A { +>A : A + + m() { +>m : (...args: any[]) => void + + /** + * @type Function + */ + this.callee = arguments.callee; +>this.callee = arguments.callee : Function +>this.callee : Function +>this : this +>callee : Function +>arguments.callee : Function +>arguments : IArguments +>callee : Function + } +} + diff --git a/tests/cases/compiler/argumentsReferenceInConstructor1_Js.ts b/tests/cases/compiler/argumentsReferenceInConstructor1_Js.ts new file mode 100644 index 00000000000..daf45fc228b --- /dev/null +++ b/tests/cases/compiler/argumentsReferenceInConstructor1_Js.ts @@ -0,0 +1,18 @@ +// @declaration: true +// @allowJs: true +// @emitDeclarationOnly: true + +// @filename: /a.js +class A { + /** + * Constructor + * + * @param {object} [foo={}] + */ + constructor(foo = {}) { + /** + * @type object + */ + this.arguments = foo; + } +} diff --git a/tests/cases/compiler/argumentsReferenceInConstructor2_Js.ts b/tests/cases/compiler/argumentsReferenceInConstructor2_Js.ts new file mode 100644 index 00000000000..a7b4f3dc445 --- /dev/null +++ b/tests/cases/compiler/argumentsReferenceInConstructor2_Js.ts @@ -0,0 +1,18 @@ +// @declaration: true +// @allowJs: true +// @emitDeclarationOnly: true + +// @filename: /a.js +class A { + /** + * Constructor + * + * @param {object} [foo={}] + */ + constructor(foo = {}) { + /** + * @type object + */ + this["arguments"] = foo; + } +} diff --git a/tests/cases/compiler/argumentsReferenceInConstructor3_Js.ts b/tests/cases/compiler/argumentsReferenceInConstructor3_Js.ts new file mode 100644 index 00000000000..07e8df0f533 --- /dev/null +++ b/tests/cases/compiler/argumentsReferenceInConstructor3_Js.ts @@ -0,0 +1,31 @@ +// @declaration: true +// @allowJs: true +// @emitDeclarationOnly: true + +// @filename: /a.js +class A { + get arguments() { + return { bar: {} }; + } +} + +class B extends A { + /** + * Constructor + * + * @param {object} [foo={}] + */ + constructor(foo = {}) { + super(); + + /** + * @type object + */ + this.foo = foo; + + /** + * @type object + */ + this.bar = super.arguments.foo; + } +} diff --git a/tests/cases/compiler/argumentsReferenceInConstructor4_Js.ts b/tests/cases/compiler/argumentsReferenceInConstructor4_Js.ts new file mode 100644 index 00000000000..b1adaa4d37d --- /dev/null +++ b/tests/cases/compiler/argumentsReferenceInConstructor4_Js.ts @@ -0,0 +1,44 @@ +// @declaration: true +// @allowJs: true +// @emitDeclarationOnly: true + +// @filename: /a.js +class A { + /** + * Constructor + * + * @param {object} [foo={}] + */ + constructor(foo = {}) { + const key = "bar"; + + /** + * @type object + */ + this.foo = foo; + + /** + * @type object + */ + const arguments = this.arguments; + + /** + * @type object + */ + this.bar = arguments.bar; + + /** + * @type object + */ + this.baz = arguments[key]; + + /** + * @type object + */ + this.options = arguments; + } + + get arguments() { + return { bar: {} }; + } +} diff --git a/tests/cases/compiler/argumentsReferenceInConstructor5_Js.ts b/tests/cases/compiler/argumentsReferenceInConstructor5_Js.ts new file mode 100644 index 00000000000..d90cd38609d --- /dev/null +++ b/tests/cases/compiler/argumentsReferenceInConstructor5_Js.ts @@ -0,0 +1,27 @@ +// @declaration: true +// @allowJs: true +// @emitDeclarationOnly: true + +// @filename: /a.js +const bar = { + arguments: {} +} + +class A { + /** + * Constructor + * + * @param {object} [foo={}] + */ + constructor(foo = {}) { + /** + * @type object + */ + this.foo = foo; + + /** + * @type object + */ + this.bar = bar.arguments; + } +} diff --git a/tests/cases/compiler/argumentsReferenceInConstructor6_Js.ts b/tests/cases/compiler/argumentsReferenceInConstructor6_Js.ts new file mode 100644 index 00000000000..9a836616e97 --- /dev/null +++ b/tests/cases/compiler/argumentsReferenceInConstructor6_Js.ts @@ -0,0 +1,13 @@ +// @declaration: true +// @allowJs: true +// @emitDeclarationOnly: true + +// @filename: /a.js +class A { + constructor() { + /** + * @type object + */ + this.foo = arguments; + } +} diff --git a/tests/cases/compiler/argumentsReferenceInConstructor7_Js.ts b/tests/cases/compiler/argumentsReferenceInConstructor7_Js.ts new file mode 100644 index 00000000000..49a3aad4572 --- /dev/null +++ b/tests/cases/compiler/argumentsReferenceInConstructor7_Js.ts @@ -0,0 +1,13 @@ +// @declaration: true +// @allowJs: true +// @emitDeclarationOnly: true + +// @filename: /a.js +class A { + constructor() { + /** + * @type Function + */ + this.callee = arguments.callee; + } +} diff --git a/tests/cases/compiler/argumentsReferenceInMethod1_Js.ts b/tests/cases/compiler/argumentsReferenceInMethod1_Js.ts new file mode 100644 index 00000000000..0fdb2cac533 --- /dev/null +++ b/tests/cases/compiler/argumentsReferenceInMethod1_Js.ts @@ -0,0 +1,16 @@ +// @declaration: true +// @allowJs: true +// @emitDeclarationOnly: true + +// @filename: /a.js +class A { + /** + * @param {object} [foo={}] + */ + m(foo = {}) { + /** + * @type object + */ + this.arguments = foo; + } +} diff --git a/tests/cases/compiler/argumentsReferenceInMethod2_Js.ts b/tests/cases/compiler/argumentsReferenceInMethod2_Js.ts new file mode 100644 index 00000000000..ba73dd9ea62 --- /dev/null +++ b/tests/cases/compiler/argumentsReferenceInMethod2_Js.ts @@ -0,0 +1,16 @@ +// @declaration: true +// @allowJs: true +// @emitDeclarationOnly: true + +// @filename: /a.js +class A { + /** + * @param {object} [foo={}] + */ + m(foo = {}) { + /** + * @type object + */ + this["arguments"] = foo; + } +} diff --git a/tests/cases/compiler/argumentsReferenceInMethod3_Js.ts b/tests/cases/compiler/argumentsReferenceInMethod3_Js.ts new file mode 100644 index 00000000000..17231ff1d61 --- /dev/null +++ b/tests/cases/compiler/argumentsReferenceInMethod3_Js.ts @@ -0,0 +1,27 @@ +// @declaration: true +// @allowJs: true +// @emitDeclarationOnly: true + +// @filename: /a.js +class A { + get arguments() { + return { bar: {} }; + } +} + +class B extends A { + /** + * @param {object} [foo={}] + */ + m(foo = {}) { + /** + * @type object + */ + this.x = foo; + + /** + * @type object + */ + this.y = super.arguments.bar; + } +} diff --git a/tests/cases/compiler/argumentsReferenceInMethod4_Js.ts b/tests/cases/compiler/argumentsReferenceInMethod4_Js.ts new file mode 100644 index 00000000000..5c50b3aa451 --- /dev/null +++ b/tests/cases/compiler/argumentsReferenceInMethod4_Js.ts @@ -0,0 +1,42 @@ +// @declaration: true +// @allowJs: true +// @emitDeclarationOnly: true + +// @filename: /a.js +class A { + /** + * @param {object} [foo={}] + */ + m(foo = {}) { + const key = "bar"; + + /** + * @type object + */ + this.foo = foo; + + /** + * @type object + */ + const arguments = this.arguments; + + /** + * @type object + */ + this.bar = arguments.bar; + + /** + * @type object + */ + this.baz = arguments[key]; + + /** + * @type object + */ + this.options = arguments; + } + + get arguments() { + return { bar: {} }; + } +} diff --git a/tests/cases/compiler/argumentsReferenceInMethod5_Js.ts b/tests/cases/compiler/argumentsReferenceInMethod5_Js.ts new file mode 100644 index 00000000000..ecfce3a2293 --- /dev/null +++ b/tests/cases/compiler/argumentsReferenceInMethod5_Js.ts @@ -0,0 +1,25 @@ +// @declaration: true +// @allowJs: true +// @emitDeclarationOnly: true + +// @filename: /a.js +const bar = { + arguments: {} +} + +class A { + /** + * @param {object} [foo={}] + */ + m(foo = {}) { + /** + * @type object + */ + this.foo = foo; + + /** + * @type object + */ + this.bar = bar.arguments; + } +} diff --git a/tests/cases/compiler/argumentsReferenceInMethod6_Js.ts b/tests/cases/compiler/argumentsReferenceInMethod6_Js.ts new file mode 100644 index 00000000000..84abb5c5c68 --- /dev/null +++ b/tests/cases/compiler/argumentsReferenceInMethod6_Js.ts @@ -0,0 +1,13 @@ +// @declaration: true +// @allowJs: true +// @emitDeclarationOnly: true + +// @filename: /a.js +class A { + m() { + /** + * @type object + */ + this.foo = arguments; + } +} diff --git a/tests/cases/compiler/argumentsReferenceInMethod7_Js.ts b/tests/cases/compiler/argumentsReferenceInMethod7_Js.ts new file mode 100644 index 00000000000..b0093a3ae3f --- /dev/null +++ b/tests/cases/compiler/argumentsReferenceInMethod7_Js.ts @@ -0,0 +1,13 @@ +// @declaration: true +// @allowJs: true +// @emitDeclarationOnly: true + +// @filename: /a.js +class A { + m() { + /** + * @type Function + */ + this.callee = arguments.callee; + } +}