Skip to content

Commit

Permalink
Typed Source: Fix error where template literals cannot be used (#1571)
Browse files Browse the repository at this point in the history
* Add case for template literals

* Fix format

---------

Co-authored-by: Martin Henz <[email protected]>
  • Loading branch information
Zenkoh1 and martin-henz authored Mar 4, 2024
1 parent 0d5cdb9 commit 115accd
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/typeChecker/typeErrorChecker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 115accd

Please sign in to comment.