Skip to content

Commit cdf1ab2

Browse files
authored
Bind @Class in the right place -- bindWorker not bindChildrenWorker (microsoft#34575)
Also add an assert to make future mismatches fail in an obvious place instead of in a while loop.
1 parent fa1884e commit cdf1ab2

6 files changed

+58
-3
lines changed

src/compiler/binder.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -821,9 +821,6 @@ namespace ts {
821821
case SyntaxKind.JSDocEnumTag:
822822
bindJSDocTypeAlias(node as JSDocTypedefTag | JSDocCallbackTag | JSDocEnumTag);
823823
break;
824-
case SyntaxKind.JSDocClassTag:
825-
bindJSDocClassTag(node as JSDocClassTag);
826-
break;
827824
// In source files and blocks, bind functions first to match hoisting that occurs at runtime
828825
case SyntaxKind.SourceFile: {
829826
bindEachFunctionsFirst((node as SourceFile).statements);
@@ -2454,6 +2451,8 @@ namespace ts {
24542451
case SyntaxKind.JSDocTypeLiteral:
24552452
case SyntaxKind.MappedType:
24562453
return bindAnonymousTypeWorker(node as TypeLiteralNode | MappedTypeNode | JSDocTypeLiteral);
2454+
case SyntaxKind.JSDocClassTag:
2455+
return bindJSDocClassTag(node as JSDocClassTag);
24572456
case SyntaxKind.ObjectLiteralExpression:
24582457
return bindObjectLiteralExpression(<ObjectLiteralExpression>node);
24592458
case SyntaxKind.FunctionExpression:

src/compiler/checker.ts

+1
Original file line numberDiff line numberDiff line change
@@ -7688,6 +7688,7 @@ namespace ts {
76887688
// The outer type parameters are those defined by enclosing generic classes, methods, or functions.
76897689
function getOuterTypeParametersOfClassOrInterface(symbol: Symbol): TypeParameter[] | undefined {
76907690
const declaration = symbol.flags & SymbolFlags.Class ? symbol.valueDeclaration : getDeclarationOfKind(symbol, SyntaxKind.InterfaceDeclaration)!;
7691+
Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations");
76917692
return getOuterTypeParameters(declaration);
76927693
}
76937694

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
tests/cases/conformance/jsdoc/callOfPropertylessConstructorFunction.js(7,1): error TS2348: Value of type 'typeof Dependency' is not callable. Did you mean to include 'new'?
2+
3+
4+
==== tests/cases/conformance/jsdoc/callOfPropertylessConstructorFunction.js (1 errors) ====
5+
/**
6+
* @constructor
7+
*/
8+
function Dependency(j) {
9+
return j
10+
}
11+
Dependency({})
12+
~~~~~~~~~~~~~~
13+
!!! error TS2348: Value of type 'typeof Dependency' is not callable. Did you mean to include 'new'?
14+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
=== tests/cases/conformance/jsdoc/callOfPropertylessConstructorFunction.js ===
2+
/**
3+
* @constructor
4+
*/
5+
function Dependency(j) {
6+
>Dependency : Symbol(Dependency, Decl(callOfPropertylessConstructorFunction.js, 0, 0))
7+
>j : Symbol(j, Decl(callOfPropertylessConstructorFunction.js, 3, 20))
8+
9+
return j
10+
>j : Symbol(j, Decl(callOfPropertylessConstructorFunction.js, 3, 20))
11+
}
12+
Dependency({})
13+
>Dependency : Symbol(Dependency, Decl(callOfPropertylessConstructorFunction.js, 0, 0))
14+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
=== tests/cases/conformance/jsdoc/callOfPropertylessConstructorFunction.js ===
2+
/**
3+
* @constructor
4+
*/
5+
function Dependency(j) {
6+
>Dependency : typeof Dependency
7+
>j : any
8+
9+
return j
10+
>j : any
11+
}
12+
Dependency({})
13+
>Dependency({}) : any
14+
>Dependency : typeof Dependency
15+
>{} : {}
16+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// @allowJs: true
2+
// @checkJs: true
3+
// @noEmit: true
4+
// @Filename: callOfPropertylessConstructorFunction.js
5+
/**
6+
* @constructor
7+
*/
8+
function Dependency(j) {
9+
return j
10+
}
11+
Dependency({})

0 commit comments

Comments
 (0)