Fix services' type's isLiteral implementation (#50929)

* fix services' type's isLiteral

* update literal completions tests

* remove booleans from literals
This commit is contained in:
Gabriela Araujo Britto 2022-11-02 15:28:10 -03:00 committed by GitHub
parent c1e9afd542
commit fdcb2ffd1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -511,7 +511,7 @@ namespace ts {
return !!(this.flags & TypeFlags.UnionOrIntersection);
}
isLiteral(): this is LiteralType {
return !!(this.flags & TypeFlags.StringOrNumberLiteral);
return !!(this.flags & (TypeFlags.StringLiteral | TypeFlags.NumberLiteral | TypeFlags.BigIntLiteral));
}
isStringLiteral(): this is StringLiteralType {
return !!(this.flags & TypeFlags.StringLiteral);

View File

@ -1,6 +1,7 @@
/// <reference path="fourslash.ts" />
////const x: 0 | "one" = /**/;
////const y: 0 | "one" | 1n = /*1*/;
verify.completions({
marker: "",
@ -10,3 +11,12 @@ verify.completions({
],
isNewIdentifierLocation: true,
});
verify.completions({
marker: "1",
includes: [
{ name: "0", kind: "string", text: "0" },
{ name: '"one"', kind: "string", text: '"one"' },
{ name: "1n", kind: "string", text: "1n" },
],
isNewIdentifierLocation: true,
});