Skip to content

Commit 3e85015

Browse files
authored
Propagate isRestParameter through symbol instantiation (#18087)
* Add repro from #17666 * Actually use repro from issue, propegate isRestParameter on instantiation
1 parent e294b23 commit 3e85015

File tree

5 files changed

+116
-0
lines changed

5 files changed

+116
-0
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8168,6 +8168,9 @@ namespace ts {
81688168
if (symbol.valueDeclaration) {
81698169
result.valueDeclaration = symbol.valueDeclaration;
81708170
}
8171+
if ((symbol as TransientSymbol).isRestParameter) {
8172+
result.isRestParameter = (symbol as TransientSymbol).isRestParameter;
8173+
}
81718174
return result;
81728175
}
81738176

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//// [File.js]
2+
class Parent {
3+
initialize() {
4+
super.initialize(...arguments)
5+
return this.asdf = ''
6+
}
7+
}
8+
9+
class Child extends Parent {
10+
initialize() {
11+
}
12+
}
13+
14+
//// [File.js]
15+
var __extends = (this && this.__extends) || (function () {
16+
var extendStatics = Object.setPrototypeOf ||
17+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
18+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
19+
return function (d, b) {
20+
extendStatics(d, b);
21+
function __() { this.constructor = d; }
22+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23+
};
24+
})();
25+
var Parent = /** @class */ (function () {
26+
function Parent() {
27+
}
28+
Parent.prototype.initialize = function () {
29+
_super.prototype.initialize.apply(this, arguments);
30+
return this.asdf = '';
31+
};
32+
return Parent;
33+
}());
34+
var Child = /** @class */ (function (_super) {
35+
__extends(Child, _super);
36+
function Child() {
37+
return _super !== null && _super.apply(this, arguments) || this;
38+
}
39+
Child.prototype.initialize = function () {
40+
};
41+
return Child;
42+
}(Parent));
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
=== tests/cases/compiler/File.js ===
2+
class Parent {
3+
>Parent : Symbol(Parent, Decl(File.js, 0, 0))
4+
5+
initialize() {
6+
>initialize : Symbol(Parent.initialize, Decl(File.js, 0, 14))
7+
8+
super.initialize(...arguments)
9+
>arguments : Symbol(arguments)
10+
11+
return this.asdf = ''
12+
>this.asdf : Symbol(Parent.asdf, Decl(File.js, 3, 14))
13+
>this : Symbol(Parent, Decl(File.js, 0, 0))
14+
>asdf : Symbol(Parent.asdf, Decl(File.js, 3, 14))
15+
}
16+
}
17+
18+
class Child extends Parent {
19+
>Child : Symbol(Child, Decl(File.js, 5, 3))
20+
>Parent : Symbol(Parent, Decl(File.js, 0, 0))
21+
22+
initialize() {
23+
>initialize : Symbol(Child.initialize, Decl(File.js, 7, 28))
24+
}
25+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
=== tests/cases/compiler/File.js ===
2+
class Parent {
3+
>Parent : Parent
4+
5+
initialize() {
6+
>initialize : (...args: any[]) => string
7+
8+
super.initialize(...arguments)
9+
>super.initialize(...arguments) : any
10+
>super.initialize : any
11+
>super : any
12+
>initialize : any
13+
>...arguments : any
14+
>arguments : IArguments
15+
16+
return this.asdf = ''
17+
>this.asdf = '' : ""
18+
>this.asdf : string
19+
>this : this
20+
>asdf : string
21+
>'' : ""
22+
}
23+
}
24+
25+
class Child extends Parent {
26+
>Child : Child
27+
>Parent : Parent
28+
29+
initialize() {
30+
>initialize : () => void
31+
}
32+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// @allowjs: true
2+
// @outDir: ../
3+
// @filename: File.js
4+
class Parent {
5+
initialize() {
6+
super.initialize(...arguments)
7+
return this.asdf = ''
8+
}
9+
}
10+
11+
class Child extends Parent {
12+
initialize() {
13+
}
14+
}

0 commit comments

Comments
 (0)