Skip to content

Commit 202eff7

Browse files
committed
fix an issue with no declarated setter param in JS files
1 parent 9509273 commit 202eff7

File tree

5 files changed

+56
-2
lines changed

5 files changed

+56
-2
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9805,7 +9805,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
98059805
});
98069806

98079807
Debug.assert(setter && isFunctionLikeDeclaration(setter));
9808-
const paramSymbol = getSignatureFromDeclaration(setter).parameters[0];
9808+
const paramSymbol: Symbol | undefined = getSignatureFromDeclaration(setter).parameters[0];
98099809

98109810
result.push(setTextRange(
98119811
factory.createSetAccessorDeclaration(
@@ -9814,7 +9814,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
98149814
[factory.createParameterDeclaration(
98159815
/*modifiers*/ undefined,
98169816
/*dotDotDotToken*/ undefined,
9817-
parameterToParameterDeclarationName(paramSymbol, getEffectiveParameterDeclaration(paramSymbol), context),
9817+
paramSymbol ? parameterToParameterDeclarationName(paramSymbol, getEffectiveParameterDeclaration(paramSymbol), context) : "value",
98189818
/*questionToken*/ undefined,
98199819
isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled),
98209820
)],

tests/baselines/reference/jsDeclarationsGetterSetter.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ Object.defineProperty(G.prototype, "x", {
5656
*/
5757
set(...args) {}
5858
});
59+
60+
export class H {}
61+
Object.defineProperty(H.prototype, "x", {
62+
set() {}
63+
});
5964

6065

6166
//// [index.js]
@@ -112,6 +117,11 @@ Object.defineProperty(G.prototype, "x", {
112117
*/
113118
set(...args) { }
114119
});
120+
export class H {
121+
}
122+
Object.defineProperty(H.prototype, "x", {
123+
set() { }
124+
});
115125

116126

117127
//// [index.d.ts]
@@ -141,3 +151,6 @@ export class F {
141151
export class G {
142152
set x(args: number);
143153
}
154+
export class H {
155+
set x(value: any);
156+
}

tests/baselines/reference/jsDeclarationsGetterSetter.symbols

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,20 @@ Object.defineProperty(G.prototype, "x", {
124124

125125
});
126126

127+
export class H {}
128+
>H : Symbol(H, Decl(index.js, 54, 3))
129+
130+
Object.defineProperty(H.prototype, "x", {
131+
>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
132+
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
133+
>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
134+
>H.prototype : Symbol(H.prototype)
135+
>H : Symbol(H, Decl(index.js, 54, 3))
136+
>prototype : Symbol(H.prototype)
137+
>"x" : Symbol(H.x, Decl(index.js, 56, 17))
138+
139+
set() {}
140+
>set : Symbol(set, Decl(index.js, 57, 41))
141+
142+
});
143+

tests/baselines/reference/jsDeclarationsGetterSetter.types

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,22 @@ Object.defineProperty(G.prototype, "x", {
137137

138138
});
139139

140+
export class H {}
141+
>H : H
142+
143+
Object.defineProperty(H.prototype, "x", {
144+
>Object.defineProperty(H.prototype, "x", { set() {}}) : H
145+
>Object.defineProperty : <T>(o: T, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => T
146+
>Object : ObjectConstructor
147+
>defineProperty : <T>(o: T, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => T
148+
>H.prototype : H
149+
>H : typeof H
150+
>prototype : H
151+
>"x" : "x"
152+
>{ set() {}} : { set(): void; }
153+
154+
set() {}
155+
>set : () => void
156+
157+
});
158+

tests/cases/conformance/jsdoc/declarations/jsDeclarationsGetterSetter.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,8 @@ Object.defineProperty(G.prototype, "x", {
5959
*/
6060
set(...args) {}
6161
});
62+
63+
export class H {}
64+
Object.defineProperty(H.prototype, "x", {
65+
set() {}
66+
});

0 commit comments

Comments
 (0)