Skip to content

Commit fdcb2ff

Browse files
authored
Fix services' type's isLiteral implementation (#50929)
* fix services' type's isLiteral * update literal completions tests * remove booleans from literals
1 parent c1e9afd commit fdcb2ff

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/services/services.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ namespace ts {
511511
return !!(this.flags & TypeFlags.UnionOrIntersection);
512512
}
513513
isLiteral(): this is LiteralType {
514-
return !!(this.flags & TypeFlags.StringOrNumberLiteral);
514+
return !!(this.flags & (TypeFlags.StringLiteral | TypeFlags.NumberLiteral | TypeFlags.BigIntLiteral));
515515
}
516516
isStringLiteral(): this is StringLiteralType {
517517
return !!(this.flags & TypeFlags.StringLiteral);

tests/cases/fourslash/completionsLiterals.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/// <reference path="fourslash.ts" />
22

33
////const x: 0 | "one" = /**/;
4+
////const y: 0 | "one" | 1n = /*1*/;
45

56
verify.completions({
67
marker: "",
@@ -10,3 +11,12 @@ verify.completions({
1011
],
1112
isNewIdentifierLocation: true,
1213
});
14+
verify.completions({
15+
marker: "1",
16+
includes: [
17+
{ name: "0", kind: "string", text: "0" },
18+
{ name: '"one"', kind: "string", text: '"one"' },
19+
{ name: "1n", kind: "string", text: "1n" },
20+
],
21+
isNewIdentifierLocation: true,
22+
});

0 commit comments

Comments
 (0)