From 115accd09fb95936dea9b8b39c24ab25f2b1ab6a Mon Sep 17 00:00:00 2001 From: Zenkoh1 <76705864+Zenkoh1@users.noreply.github.com> Date: Mon, 4 Mar 2024 22:06:13 +0800 Subject: [PATCH] Typed Source: Fix error where template literals cannot be used (#1571) * Add case for template literals * Fix format --------- Co-authored-by: Martin Henz --- src/typeChecker/typeErrorChecker.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/typeChecker/typeErrorChecker.ts b/src/typeChecker/typeErrorChecker.ts index 9d627d594..277882750 100644 --- a/src/typeChecker/typeErrorChecker.ts +++ b/src/typeChecker/typeErrorChecker.ts @@ -148,6 +148,11 @@ function typeCheckAndReturnType(node: tsEs.Node): Type { // Casting is safe here as above check already narrows type to string, number or boolean return tPrimitive(typeof node.value as PrimitiveType, node.value) } + case 'TemplateLiteral': { + // Quasis array should only have one element as + // string interpolation is not allowed in Source + return tPrimitive('string', node.quasis[0].value.raw) + } case 'Identifier': { const varName = node.name const varType = lookupTypeAndRemoveForAllAndPredicateTypes(varName)