@@ -427,7 +427,7 @@ module ts {
427
427
if ( result . flags & SymbolFlags . BlockScopedVariable ) {
428
428
// Block-scoped variables cannot be used before their definition
429
429
var declaration = forEach ( result . declarations , d => d . flags & NodeFlags . BlockScoped ? d : undefined ) ;
430
- Debug . assert ( declaration , "Block-scoped variable declaration is undefined" ) ;
430
+ Debug . assert ( declaration !== undefined , "Block-scoped variable declaration is undefined" ) ;
431
431
var declarationSourceFile = getSourceFileOfNode ( declaration ) ;
432
432
var referenceSourceFile = getSourceFileOfNode ( errorLocation ) ;
433
433
if ( declarationSourceFile === referenceSourceFile ) {
@@ -472,7 +472,7 @@ module ts {
472
472
function getSymbolOfPartOfRightHandSideOfImport ( entityName : EntityName , importDeclaration ?: ImportDeclaration ) : Symbol {
473
473
if ( ! importDeclaration ) {
474
474
importDeclaration = getAncestor ( entityName , SyntaxKind . ImportDeclaration ) ;
475
- Debug . assert ( importDeclaration ) ;
475
+ Debug . assert ( importDeclaration !== undefined ) ;
476
476
}
477
477
// There are three things we might try to look for. In the following examples,
478
478
// the search term is enclosed in |...|:
@@ -3334,7 +3334,6 @@ module ts {
3334
3334
}
3335
3335
if ( reportErrors ) {
3336
3336
headMessage = headMessage || Diagnostics . Type_0_is_not_assignable_to_type_1 ;
3337
- Debug . assert ( headMessage ) ;
3338
3337
reportError ( headMessage , typeToString ( source ) , typeToString ( target ) ) ;
3339
3338
}
3340
3339
return Ternary . False ;
@@ -4912,7 +4911,7 @@ module ts {
4912
4911
}
4913
4912
return createArrayType ( getUnionType ( elementTypes ) ) ;
4914
4913
}
4915
-
4914
+
4916
4915
function isNumericName ( name : string ) {
4917
4916
// The intent of numeric names is that
4918
4917
// - they are names with text in a numeric form, and that
@@ -4937,7 +4936,7 @@ module ts {
4937
4936
// with the strings '"Infinity"', '"-Infinity"', and '"NaN"' respectively.
4938
4937
return ( + name ) . toString ( ) === name ;
4939
4938
}
4940
-
4939
+
4941
4940
function checkObjectLiteral ( node : ObjectLiteral , contextualMapper ?: TypeMapper ) : Type {
4942
4941
var members = node . symbol . members ;
4943
4942
var properties : SymbolTable = { } ;
@@ -5660,6 +5659,13 @@ module ts {
5660
5659
return getReturnTypeOfSignature ( signature ) ;
5661
5660
}
5662
5661
5662
+ function checkTaggedTemplateExpression ( node : TaggedTemplateExpression ) : Type {
5663
+ // TODO (drosen): Make sure substitutions are assignable to the tag's arguments.
5664
+ checkExpression ( node . tag ) ;
5665
+ checkExpression ( node . template ) ;
5666
+ return anyType ;
5667
+ }
5668
+
5663
5669
function checkTypeAssertion ( node : TypeAssertion ) : Type {
5664
5670
var exprType = checkExpression ( node . operand ) ;
5665
5671
var targetType = getTypeFromTypeNode ( node . type ) ;
@@ -6170,6 +6176,19 @@ module ts {
6170
6176
return getUnionType ( [ type1 , type2 ] ) ;
6171
6177
}
6172
6178
6179
+ function checkTemplateExpression ( node : TemplateExpression ) : Type {
6180
+ // We just want to check each expressions, but we are unconcerned with
6181
+ // the type of each expression, as any value may be coerced into a string.
6182
+ // It is worth asking whether this is what we really want though.
6183
+ // A place where we actually *are* concerned with the expressions' types are
6184
+ // in tagged templates.
6185
+ forEach ( ( < TemplateExpression > node ) . templateSpans , templateSpan => {
6186
+ checkExpression ( templateSpan . expression ) ;
6187
+ } ) ;
6188
+
6189
+ return stringType ;
6190
+ }
6191
+
6173
6192
function checkExpressionWithContextualType ( node : Expression , contextualType : Type , contextualMapper ?: TypeMapper ) : Type {
6174
6193
var saveContextualType = node . contextualType ;
6175
6194
node . contextualType = contextualType ;
@@ -6223,7 +6242,10 @@ module ts {
6223
6242
return booleanType ;
6224
6243
case SyntaxKind . NumericLiteral :
6225
6244
return numberType ;
6245
+ case SyntaxKind . TemplateExpression :
6246
+ return checkTemplateExpression ( < TemplateExpression > node ) ;
6226
6247
case SyntaxKind . StringLiteral :
6248
+ case SyntaxKind . NoSubstitutionTemplateLiteral :
6227
6249
return stringType ;
6228
6250
case SyntaxKind . RegularExpressionLiteral :
6229
6251
return globalRegExpType ;
@@ -6240,6 +6262,8 @@ module ts {
6240
6262
case SyntaxKind . CallExpression :
6241
6263
case SyntaxKind . NewExpression :
6242
6264
return checkCallExpression ( < CallExpression > node ) ;
6265
+ case SyntaxKind . TaggedTemplateExpression :
6266
+ return checkTaggedTemplateExpression ( < TaggedTemplateExpression > node ) ;
6243
6267
case SyntaxKind . TypeAssertion :
6244
6268
return checkTypeAssertion ( < TypeAssertion > node ) ;
6245
6269
case SyntaxKind . ParenExpression :
@@ -7549,17 +7573,17 @@ module ts {
7549
7573
errorMessage = Diagnostics . Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor ;
7550
7574
}
7551
7575
else {
7552
- Debug . assert ( derived . flags & SymbolFlags . Property ) ;
7576
+ Debug . assert ( ( derived . flags & SymbolFlags . Property ) !== 0 ) ;
7553
7577
errorMessage = Diagnostics . Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property ;
7554
7578
}
7555
7579
}
7556
7580
else if ( base . flags & SymbolFlags . Property ) {
7557
- Debug . assert ( derived . flags & SymbolFlags . Method ) ;
7581
+ Debug . assert ( ( derived . flags & SymbolFlags . Method ) !== 0 ) ;
7558
7582
errorMessage = Diagnostics . Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function ;
7559
7583
}
7560
7584
else {
7561
- Debug . assert ( base . flags & SymbolFlags . Accessor ) ;
7562
- Debug . assert ( derived . flags & SymbolFlags . Method ) ;
7585
+ Debug . assert ( ( base . flags & SymbolFlags . Accessor ) !== 0 ) ;
7586
+ Debug . assert ( ( derived . flags & SymbolFlags . Method ) !== 0 ) ;
7563
7587
errorMessage = Diagnostics . Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function ;
7564
7588
}
7565
7589
@@ -8016,6 +8040,7 @@ module ts {
8016
8040
case SyntaxKind . IndexedAccess :
8017
8041
case SyntaxKind . CallExpression :
8018
8042
case SyntaxKind . NewExpression :
8043
+ case SyntaxKind . TaggedTemplateExpression :
8019
8044
case SyntaxKind . TypeAssertion :
8020
8045
case SyntaxKind . ParenExpression :
8021
8046
case SyntaxKind . PrefixOperator :
@@ -8293,6 +8318,9 @@ module ts {
8293
8318
case SyntaxKind . CallExpression :
8294
8319
case SyntaxKind . NewExpression :
8295
8320
return ( < CallExpression > parent ) . typeArguments && ( < CallExpression > parent ) . typeArguments . indexOf ( node ) >= 0 ;
8321
+ case SyntaxKind . TaggedTemplateExpression :
8322
+ // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments.
8323
+ return false ;
8296
8324
}
8297
8325
}
8298
8326
0 commit comments