The Playground lets you write TypeScript or JavaScript online in a safe and sharable way.
#Check an obj field against the keys of a field from the same object without providing generic.
1 messages · Page 1 of 1 (latest)
@naive niche Here's a shortened URL of your playground link! You can remove the full link from your message.
Preview:```ts
export interface Provider {
fire: () => void
}
export class ProductionProvider implements Provider {
private readonly apiKey: string
constructor(apiKey: string) {
this.apiKey = apiKey
}
fire() {
console.log("Rocket")
}
}
export class DevProvider implements Provider {
...```
You can choose specific lines to embed by selecting them before copying the link.
seem that no good way if using a pure variable variable define statement, but u can try define a function like defineConfig?
hm ok,
No way to do this without a generic - satisfies isn't good enough since you have associated types
Preview:```ts
...
function defineConfig<
T extends SupportedNetwork
(config: {
providers: Record<T, Provider>
defaultProvider: NoInfer<T>
}) {
return config
}
...```