Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14541,8 +14541,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
}
}

const classType = declaration.kind === SyntaxKind.Constructor ?
getDeclaredTypeOfClassOrInterface(getMergedSymbol((declaration.parent as ClassDeclaration).symbol))
const hostDeclaration = isJSDocSignature(declaration) ? getEffectiveJSDocHost(declaration) : declaration;
const classType = hostDeclaration && isConstructorDeclaration(hostDeclaration) ?
getDeclaredTypeOfClassOrInterface(getMergedSymbol((hostDeclaration.parent as ClassDeclaration).symbol))
: undefined;
const typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration);
if (hasRestParameter(declaration) || isInJSFile(declaration) && maybeAddJsSyntheticRestParameter(declaration, parameters)) {
Expand Down
29 changes: 29 additions & 0 deletions tests/baselines/reference/overloadTag3.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
=== /a.js ===
/**
* @template T
*/
export class Foo {
>Foo : Symbol(Foo, Decl(a.js, 0, 0))

/**
* @constructor
* @overload
*/
constructor() { }

/**
* @param {T} value
*/
bar(value) { }
>bar : Symbol(Foo.bar, Decl(a.js, 8, 21))
>value : Symbol(value, Decl(a.js, 13, 8))
}

/** @type {Foo<number>} */
let foo;
>foo : Symbol(foo, Decl(a.js, 17, 3))

foo = new Foo();
>foo : Symbol(foo, Decl(a.js, 17, 3))
>Foo : Symbol(Foo, Decl(a.js, 0, 0))

31 changes: 31 additions & 0 deletions tests/baselines/reference/overloadTag3.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
=== /a.js ===
/**
* @template T
*/
export class Foo {
>Foo : Foo<T>

/**
* @constructor
* @overload
*/
constructor() { }

/**
* @param {T} value
*/
bar(value) { }
>bar : (value: T) => void
>value : T
}

/** @type {Foo<number>} */
let foo;
>foo : Foo<number>

foo = new Foo();
>foo = new Foo() : Foo<number>
>foo : Foo<number>
>new Foo() : Foo<number>
>Foo : typeof Foo

24 changes: 24 additions & 0 deletions tests/cases/conformance/jsdoc/overloadTag3.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// @checkJs: true
// @allowJs: true
// @strict: true
// @noEmit: true
// @filename: /a.js
/**
* @template T
*/
export class Foo {
/**
* @constructor
* @overload
*/
constructor() { }

/**
* @param {T} value
*/
bar(value) { }
}

/** @type {Foo<number>} */
let foo;
foo = new Foo();