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 {
4511445114 (isSyntacticallyString(right) || rightIsNumeric) &&
4511545115 (expr as BinaryExpression).operatorToken.kind === SyntaxKind.PlusToken
4511645116 );
45117- case SyntaxKind.TemplateExpression:
45118- return (expr as TemplateExpression).templateSpans.every(span => isSyntacticallyString(span.expression));
4511945117 case SyntaxKind.ParenthesizedExpression:
4512045118 return isSyntacticallyString((expr as ParenthesizedExpression).expression);
45119+ case SyntaxKind.TemplateExpression:
4512145120 case SyntaxKind.StringLiteral:
4512245121 case SyntaxKind.NoSubstitutionTemplateLiteral:
4512345122 return true;
@@ -48297,6 +48296,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4829748296 const node = getParseTreeNode(nodeIn, canHaveConstantValue);
4829848297 return node ? getConstantValue(node) : undefined;
4829948298 },
48299+ isSyntacticallyString,
4830048300 collectLinkedAliases,
4830148301 getReferencedValueDeclaration,
4830248302 getReferencedValueDeclarations,
Original file line number Diff line number Diff line change @@ -1158,6 +1158,7 @@ export const notImplementedResolver: EmitResolver = {
11581158 isEntityNameVisible : notImplemented ,
11591159 // Returns the constant value this property access resolves to: notImplemented, or 'undefined' for a non-constant
11601160 getConstantValue : notImplemented ,
1161+ isSyntacticallyString : notImplemented ,
11611162 getReferencedValueDeclaration : notImplemented ,
11621163 getReferencedValueDeclarations : notImplemented ,
11631164 getTypeReferenceSerializationKind : notImplemented ,
Original file line number Diff line number Diff line change @@ -1873,7 +1873,12 @@ export function transformTypeScript(context: TransformationContext) {
18731873 ) ,
18741874 valueExpression ,
18751875 ) ;
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 ?
18771882 innerAssignment :
18781883 factory . createAssignment (
18791884 factory . createElementAccessExpression (
Original file line number Diff line number Diff line change @@ -5691,6 +5691,7 @@ export interface EmitResolver {
56915691 isEntityNameVisible ( entityName : EntityNameOrEntityNameExpression , enclosingDeclaration : Node ) : SymbolVisibilityResult ;
56925692 // Returns the constant value this property access resolves to, or 'undefined' for a non-constant
56935693 getConstantValue ( node : EnumMember | PropertyAccessExpression | ElementAccessExpression ) : string | number | undefined ;
5694+ isSyntacticallyString ( node : Expression ) : boolean ;
56945695 getReferencedValueDeclaration ( reference : Identifier ) : Declaration | undefined ;
56955696 getReferencedValueDeclarations ( reference : Identifier ) : Declaration [ ] | undefined ;
56965697 getTypeReferenceSerializationKind ( typeName : EntityName , location ?: Node ) : TypeReferenceSerializationKind ;
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments