Skip to content

Instantly share code, notes, and snippets.

@tannerlinsley
Created August 9, 2022 03:25
Show Gist options
  • Save tannerlinsley/1011ebc06c89e9436e5e809734bc1608 to your computer and use it in GitHub Desktop.
Save tannerlinsley/1011ebc06c89e9436e5e809734bc1608 to your computer and use it in GitHub Desktop.
// my-core
interface FrameworkGenerics<TData = unknown> {
// Options: unknown
}
type GetFrameworkGeneric<
U,
TData = unknown,
> = U extends keyof FrameworkGenerics<TData>
? FrameworkGenerics<TData>[U]
: unknown
export function getCoreOptions (opts: GetFrameworkGeneric<'Options'>) {
return opts
}
// React Adapter
declare module 'my-core' {
interface FrameworkGenerics<TData = unknown> {
Options: {
react: true
}
}
}
// Vue Adapter
declare module 'my-core' {
interface FrameworkGenerics<TData = unknown> {
Options: {
vue: true
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment