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
2 changes: 1 addition & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10519,7 +10519,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
// function/class/{} initializers are themselves containers, so they won't merge in the same way as other initializers
const container = getAssignedExpandoInitializer(symbol.valueDeclaration);
if (container) {
const tag = getJSDocTypeTag(container);
const tag = isInJSFile(container) ? getJSDocTypeTag(container) : undefined;
if (tag && tag.typeExpression) {
return getTypeFromTypeNode(tag.typeExpression);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//// [expandoFunctionContextualTypesJSDocInTs.ts]
export function Foo() { }

// This comment should have no effect; this is a TS file.
/** @type {never} */
Foo.bar = () => { };


//// [expandoFunctionContextualTypesJSDocInTs.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Foo = void 0;
function Foo() { }
exports.Foo = Foo;
// This comment should have no effect; this is a TS file.
/** @type {never} */
Foo.bar = function () { };
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
=== tests/cases/compiler/expandoFunctionContextualTypesJSDocInTs.ts ===
export function Foo() { }
>Foo : Symbol(Foo, Decl(expandoFunctionContextualTypesJSDocInTs.ts, 0, 0), Decl(expandoFunctionContextualTypesJSDocInTs.ts, 0, 25))

// This comment should have no effect; this is a TS file.
/** @type {never} */
Foo.bar = () => { };
>Foo.bar : Symbol(Foo.bar, Decl(expandoFunctionContextualTypesJSDocInTs.ts, 0, 25))
>Foo : Symbol(Foo, Decl(expandoFunctionContextualTypesJSDocInTs.ts, 0, 0), Decl(expandoFunctionContextualTypesJSDocInTs.ts, 0, 25))
>bar : Symbol(Foo.bar, Decl(expandoFunctionContextualTypesJSDocInTs.ts, 0, 25))

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
=== tests/cases/compiler/expandoFunctionContextualTypesJSDocInTs.ts ===
export function Foo() { }
>Foo : typeof Foo

// This comment should have no effect; this is a TS file.
/** @type {never} */
Foo.bar = () => { };
>Foo.bar = () => { } : () => void
>Foo.bar : () => void
>Foo : typeof Foo
>bar : () => void
>() => { } : () => void

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export function Foo() { }

// This comment should have no effect; this is a TS file.
/** @type {never} */
Foo.bar = () => { };