File tree Expand file tree Collapse file tree 5 files changed +10
-25
lines changed
tests/baselines/reference Expand file tree Collapse file tree 5 files changed +10
-25
lines changed Original file line number Diff line number Diff line change @@ -45114,10 +45114,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
45114
45114
(isSyntacticallyString(right) || rightIsNumeric) &&
45115
45115
(expr as BinaryExpression).operatorToken.kind === SyntaxKind.PlusToken
45116
45116
);
45117
- case SyntaxKind.TemplateExpression:
45118
- return (expr as TemplateExpression).templateSpans.every(span => isSyntacticallyString(span.expression));
45119
45117
case SyntaxKind.ParenthesizedExpression:
45120
45118
return isSyntacticallyString((expr as ParenthesizedExpression).expression);
45119
+ case SyntaxKind.TemplateExpression:
45121
45120
case SyntaxKind.StringLiteral:
45122
45121
case SyntaxKind.NoSubstitutionTemplateLiteral:
45123
45122
return true;
@@ -48297,6 +48296,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
48297
48296
const node = getParseTreeNode(nodeIn, canHaveConstantValue);
48298
48297
return node ? getConstantValue(node) : undefined;
48299
48298
},
48299
+ isSyntacticallyString,
48300
48300
collectLinkedAliases,
48301
48301
getReferencedValueDeclaration,
48302
48302
getReferencedValueDeclarations,
Original file line number Diff line number Diff line change @@ -1158,6 +1158,7 @@ export const notImplementedResolver: EmitResolver = {
1158
1158
isEntityNameVisible : notImplemented ,
1159
1159
// Returns the constant value this property access resolves to: notImplemented, or 'undefined' for a non-constant
1160
1160
getConstantValue : notImplemented ,
1161
+ isSyntacticallyString : notImplemented ,
1161
1162
getReferencedValueDeclaration : notImplemented ,
1162
1163
getReferencedValueDeclarations : notImplemented ,
1163
1164
getTypeReferenceSerializationKind : notImplemented ,
Original file line number Diff line number Diff line change @@ -1873,7 +1873,12 @@ export function transformTypeScript(context: TransformationContext) {
1873
1873
) ,
1874
1874
valueExpression ,
1875
1875
) ;
1876
- const outerAssignment = valueExpression . kind === SyntaxKind . StringLiteral ?
1876
+ const isString = valueExpression . kind === SyntaxKind . StringLiteral ||
1877
+ // Fix ts.transpileModule() emit: we may not have been able to determine a known string due
1878
+ // to missing type information, but we know syntactically that it's a string. The checker
1879
+ // ensures that only syntactically determined strings are allowed under isolatedModules.
1880
+ ( member . initializer && resolver . isSyntacticallyString ( member . initializer ) ) ;
1881
+ const outerAssignment = isString ?
1877
1882
innerAssignment :
1878
1883
factory . createAssignment (
1879
1884
factory . createElementAccessExpression (
Original file line number Diff line number Diff line change @@ -5691,6 +5691,7 @@ export interface EmitResolver {
5691
5691
isEntityNameVisible ( entityName : EntityNameOrEntityNameExpression , enclosingDeclaration : Node ) : SymbolVisibilityResult ;
5692
5692
// Returns the constant value this property access resolves to, or 'undefined' for a non-constant
5693
5693
getConstantValue ( node : EnumMember | PropertyAccessExpression | ElementAccessExpression ) : string | number | undefined ;
5694
+ isSyntacticallyString ( node : Expression ) : boolean ;
5694
5695
getReferencedValueDeclaration ( reference : Identifier ) : Declaration | undefined ;
5695
5696
getReferencedValueDeclarations ( reference : Identifier ) : Declaration [ ] | undefined ;
5696
5697
getTypeReferenceSerializationKind ( typeName : EntityName , location ?: Node ) : TypeReferenceSerializationKind ;
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments