Skip to content

Commit 7cdeda0

Browse files
authored
Merge pull request #2 from xDivisionByZerox/suggestion-literal-union
2 parents a2550bd + a13f3b1 commit 7cdeda0

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

literal_union.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
type LiteralUnion<Suggestions extends string> = Suggestions | (string & {});
2+
3+
type ImageMimiTypes =
4+
"image/bmp" |
5+
"image/gif" |
6+
"image/png" |
7+
"image/svg+xml" |
8+
"image/tiff" |
9+
"image/vnd.microsoft.icon" |
10+
"image/webp";
11+
12+
let validValueWithMimeType: LiteralUnion<ImageMimiTypes> = 'image/bmp'; // this is valid and was suggested automatically
13+
let validValueWithoutMimeType: LiteralUnion<ImageMimiTypes> = ''; // this is still valid

0 commit comments

Comments
 (0)