Emojis as variant

Is it possible to create a variant type of emojis?

Im trying to emulate a ts type that looks like this:

type Emojis = "πŸ˜€" | "πŸ˜ƒ" | "πŸ˜„" 

This doesnt seem to work.

Maybe there is somewhere to get a named list of emojis that we could build a variant with?

type emojis = [ \"πŸ˜€" | \ "πŸ˜ƒ" ]

Any suggestions would be greatly appreciated.

Thank you.

The following works with the polymorphic variants. Not sure whether there’s a way to make it work with regular variants.

type emojis = [#"πŸ˜€" | #"πŸ˜ƒ"]
let x: emojis = #"πŸ˜€"

Edit: although, not sure. #"πŸ˜€" compiles to β€œ\xf0\x9f\x98\x80”, and console.log("\xf0\x9f\x98\x80") prints Γ°

1 Like