Don't error on bigint literal used in type

This commit is contained in:
Caleb Sander
2018-11-05 12:23:02 -08:00
parent 6c59a3b890
commit bb99c41230
6 changed files with 35 additions and 22 deletions

View File

@@ -30471,13 +30471,17 @@ namespace ts {
}
function checkGrammarBigIntLiteral(node: BigIntLiteral): boolean {
if (languageVersion < ScriptTarget.ESNext) {
if (grammarErrorOnNode(node, Diagnostics.BigInt_literals_are_not_available_when_targetting_lower_than_ESNext)) {
return true;
const literalType = isLiteralTypeNode(node.parent) ||
isPrefixUnaryExpression(node.parent) && isLiteralTypeNode(node.parent.parent);
if (!literalType) {
if (languageVersion < ScriptTarget.ESNext) {
if (grammarErrorOnNode(node, Diagnostics.BigInt_literals_are_not_available_when_targetting_lower_than_ESNext)) {
return true;
}
}
if (!compilerOptions.experimentalBigInt) {
return grammarErrorOnNode(node, Diagnostics.Experimental_support_for_BigInt_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalBigInt_option_to_remove_this_warning);
}
}
if (!compilerOptions.experimentalBigInt) {
return grammarErrorOnNode(node, Diagnostics.Experimental_support_for_BigInt_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalBigInt_option_to_remove_this_warning);
}
return false;
}