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

Also add an assert to make future mismatches fail in an obvious place
instead of in a while loop.
This commit is contained in:
Nathan Shively-Sanders 2019-10-18 14:13:14 -07:00 committed by GitHub
parent fa1884ed1b
commit cdf1ab2dec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 58 additions and 3 deletions

View File

@ -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);
@ -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:

View File

@ -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);
}

View File

@ -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'?

View File

@ -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))

View File

@ -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
>{} : {}

View File

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