fix(56562): Type with negative properties cause crash in infer return type (#56565)

This commit is contained in:
Oleksandr T
2023-12-07 11:09:53 -08:00
committed by GitHub
parent 5b7344ef52
commit fc30163bb4
2 changed files with 21 additions and 1 deletions
+1 -1
View File
@@ -8345,7 +8345,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
return factory.createStringLiteral(name, !!singleQuote);
}
if (isNumericLiteralName(name) && startsWith(name, "-")) {
return factory.createComputedPropertyName(factory.createNumericLiteral(+name));
return factory.createComputedPropertyName(factory.createPrefixUnaryExpression(SyntaxKind.MinusToken, factory.createNumericLiteral(-name)));
}
return createPropertyNameNodeForIdentifierOrLiteral(name, getEmitScriptTarget(compilerOptions), singleQuote, stringNamed, isMethod);
}