I want to be able to define custom, reusable type defintions to avoid error prone reusable definitions inside functions.
Based on the following error:
Error:
cause: Type `String` is not a subtype of `"Github" | "Facebook" | "Passkey" | "Google"`
› at src/lib/db/schema/fsl/functions/auth/signUpWithSocialProvider.fsl:2:112
› |
› 2 | function signUpWithSocialProvider(firstName: String, lastName: String, email: String, image: String, provider: String, providerAccountId: String): Account {
› | ^^^^^^
› |
Collection account:
collection Account {
user: Ref<User>
provider: "Github" | "Google" | "Facebook" | "Passkey"
providerAccountId: String | Null
unique [.user, .provider]
}
If String is not a subtype of a string literal union, I need to add the string literal type directly. Any best practices? Because as far as I know it’s not yet possible to create custom types to reuse types e.g.
type Provider: "Github" | "Facebook" | "Passkey" | "Google"
function signUpWithSocialProvider([...], provider: Provider): Account
And duplicating the string literal union is quite error prone
function signUpWithSocialProvider([...], provider: "Github" | "Facebook" | "Passkey" | "Google"): Account