Hi!
I am binding an external module, specifically a function that accepts 3 possible string values at runtime, I want to type it correctly by only allowing those 3 values, but I can’t find a way to do it.
This is what I have right now, which works but its type is string, not environment.
:
@deriving(jsConverter)
type environment = [
| @as("dev") #Dev
| @as("stage") #Stage
| @as("prod") #Prod
]
type configuration = {environment: string} // It should type `environment`
@module("data-sdk") external setConfiguration: configuration => unit = "setConfiguration
setConfiguration({
environment: environmentToJs(#Stage),
})
It is there a way where I can use a type different than string
for the environment key?
Thanks!
Edit: The data-sdk
dependency is an ES6 module, which also have TS .d.ts
typings available.