Skip to content

Bind @class in the right place -- bindWorker not bindChildrenWorker #34575

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 18, 2019
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: 2 additions & 3 deletions src/compiler/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -821,9 +821,6 @@ namespace ts {
case SyntaxKind.JSDocEnumTag:
bindJSDocTypeAlias(node as JSDocTypedefTag | JSDocCallbackTag | JSDocEnumTag);
break;
case SyntaxKind.JSDocClassTag:
bindJSDocClassTag(node as JSDocClassTag);
break;
// In source files and blocks, bind functions first to match hoisting that occurs at runtime
case SyntaxKind.SourceFile: {
bindEachFunctionsFirst((node as SourceFile).statements);
Expand Down Expand Up @@ -2454,6 +2451,8 @@ namespace ts {
case SyntaxKind.JSDocTypeLiteral:
case SyntaxKind.MappedType:
return bindAnonymousTypeWorker(node as TypeLiteralNode | MappedTypeNode | JSDocTypeLiteral);
case SyntaxKind.JSDocClassTag:
return bindJSDocClassTag(node as JSDocClassTag);
case SyntaxKind.ObjectLiteralExpression:
return bindObjectLiteralExpression(<ObjectLiteralExpression>node);
case SyntaxKind.FunctionExpression:
Expand Down
1 change: 1 addition & 0 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7688,6 +7688,7 @@ namespace ts {
// The outer type parameters are those defined by enclosing generic classes, methods, or functions.
function getOuterTypeParametersOfClassOrInterface(symbol: Symbol): TypeParameter[] | undefined {
const declaration = symbol.flags & SymbolFlags.Class ? symbol.valueDeclaration : getDeclarationOfKind(symbol, SyntaxKind.InterfaceDeclaration)!;
Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations");
return getOuterTypeParameters(declaration);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
tests/cases/conformance/jsdoc/callOfPropertylessConstructorFunction.js(7,1): error TS2348: Value of type 'typeof Dependency' is not callable. Did you mean to include 'new'?


==== tests/cases/conformance/jsdoc/callOfPropertylessConstructorFunction.js (1 errors) ====
/**
* @constructor
*/
function Dependency(j) {
return j
}
Dependency({})
~~~~~~~~~~~~~~
!!! error TS2348: Value of type 'typeof Dependency' is not callable. Did you mean to include 'new'?

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
=== tests/cases/conformance/jsdoc/callOfPropertylessConstructorFunction.js ===
/**
* @constructor
*/
function Dependency(j) {
>Dependency : Symbol(Dependency, Decl(callOfPropertylessConstructorFunction.js, 0, 0))
>j : Symbol(j, Decl(callOfPropertylessConstructorFunction.js, 3, 20))

return j
>j : Symbol(j, Decl(callOfPropertylessConstructorFunction.js, 3, 20))
}
Dependency({})
>Dependency : Symbol(Dependency, Decl(callOfPropertylessConstructorFunction.js, 0, 0))

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
=== tests/cases/conformance/jsdoc/callOfPropertylessConstructorFunction.js ===
/**
* @constructor
*/
function Dependency(j) {
>Dependency : typeof Dependency
>j : any

return j
>j : any
}
Dependency({})
>Dependency({}) : any
>Dependency : typeof Dependency
>{} : {}

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// @allowJs: true
// @checkJs: true
// @noEmit: true
// @Filename: callOfPropertylessConstructorFunction.js
/**
* @constructor
*/
function Dependency(j) {
return j
}
Dependency({})