Skip to content

Commit

Permalink
Merge pull request #2 from xDivisionByZerox/suggestion-literal-union
Browse files Browse the repository at this point in the history
  • Loading branch information
chwoerz authored Nov 29, 2024
2 parents a2550bd + a13f3b1 commit 7cdeda0
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions literal_union.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
type LiteralUnion<Suggestions extends string> = Suggestions | (string & {});

type ImageMimiTypes =
"image/bmp" |
"image/gif" |
"image/png" |
"image/svg+xml" |
"image/tiff" |
"image/vnd.microsoft.icon" |
"image/webp";

let validValueWithMimeType: LiteralUnion<ImageMimiTypes> = 'image/bmp'; // this is valid and was suggested automatically
let validValueWithoutMimeType: LiteralUnion<ImageMimiTypes> = ''; // this is still valid

0 comments on commit 7cdeda0

Please sign in to comment.