Read the base construct signature from the static base type, not the instance base (#41767)

This commit is contained in:
Wesley Wigham 2020-12-02 13:30:46 -08:00 committed by GitHub
parent 9a957e7b9c
commit 9f9eed400c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 130 additions and 5 deletions

View file

@ -6772,7 +6772,7 @@ namespace ts {
!some(getSignaturesOfType(staticType, SignatureKind.Construct));
const constructors = isNonConstructableClassLikeInJsFile ?
[factory.createConstructorDeclaration(/*decorators*/ undefined, factory.createModifiersFromModifierFlags(ModifierFlags.Private), [], /*body*/ undefined)] :
serializeSignatures(SignatureKind.Construct, staticType, baseTypes[0], SyntaxKind.Constructor) as ConstructorDeclaration[];
serializeSignatures(SignatureKind.Construct, staticType, staticBaseType, SyntaxKind.Constructor) as ConstructorDeclaration[];
const indexSignatures = serializeIndexSignatures(classType, baseTypes[0]);
addResult(setTextRange(factory.createClassDeclaration(
/*decorators*/ undefined,

View file

@ -579,10 +579,6 @@ export class N<T> extends L {
* @extends {N<U>}
*/
export class O<U> extends N<U> {
/**
* @param {U} param
*/
constructor(param: U);
another2: U;
}
declare const VariableBase_base: any;

View file

@ -0,0 +1,63 @@
//// [index.js]
export class Super {
/**
* @param {string} firstArg
* @param {string} secondArg
*/
constructor(firstArg, secondArg) { }
}
export class Sub extends Super {
constructor() {
super('first', 'second');
}
}
//// [index.js]
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
exports.__esModule = true;
exports.Sub = exports.Super = void 0;
var Super = /** @class */ (function () {
/**
* @param {string} firstArg
* @param {string} secondArg
*/
function Super(firstArg, secondArg) {
}
return Super;
}());
exports.Super = Super;
var Sub = /** @class */ (function (_super) {
__extends(Sub, _super);
function Sub() {
return _super.call(this, 'first', 'second') || this;
}
return Sub;
}(Super));
exports.Sub = Sub;
//// [index.d.ts]
export class Super {
/**
* @param {string} firstArg
* @param {string} secondArg
*/
constructor(firstArg: string, secondArg: string);
}
export class Sub extends Super {
constructor();
}

View file

@ -0,0 +1,22 @@
=== tests/cases/conformance/jsdoc/declarations/index.js ===
export class Super {
>Super : Symbol(Super, Decl(index.js, 0, 0))
/**
* @param {string} firstArg
* @param {string} secondArg
*/
constructor(firstArg, secondArg) { }
>firstArg : Symbol(firstArg, Decl(index.js, 5, 16))
>secondArg : Symbol(secondArg, Decl(index.js, 5, 25))
}
export class Sub extends Super {
>Sub : Symbol(Sub, Decl(index.js, 6, 1))
>Super : Symbol(Super, Decl(index.js, 0, 0))
constructor() {
super('first', 'second');
>super : Symbol(Super, Decl(index.js, 0, 0))
}
}

View file

@ -0,0 +1,25 @@
=== tests/cases/conformance/jsdoc/declarations/index.js ===
export class Super {
>Super : Super
/**
* @param {string} firstArg
* @param {string} secondArg
*/
constructor(firstArg, secondArg) { }
>firstArg : string
>secondArg : string
}
export class Sub extends Super {
>Sub : Sub
>Super : Super
constructor() {
super('first', 'second');
>super('first', 'second') : void
>super : typeof Super
>'first' : "first"
>'second' : "second"
}
}

View file

@ -0,0 +1,19 @@
// @allowJs: true
// @checkJs: true
// @outDir: /out
// @lib: es6
// @declaration: true
// @filename: index.js
export class Super {
/**
* @param {string} firstArg
* @param {string} secondArg
*/
constructor(firstArg, secondArg) { }
}
export class Sub extends Super {
constructor() {
super('first', 'second');
}
}