Created
June 10, 2021 00:57
-
-
Save karol-majewski/7098f0ba47a790811c10b27e091bd82d to your computer and use it in GitHub Desktop.
Dependent types for https://github.com/JoseRFelix/react-css-theme-switcher
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
type DeferTypeInference<T> = [T][T extends any ? 0 : never]; | |
interface Props<T extends string> { | |
themeMap: Record<T, any> | |
defaultTheme?: DeferTypeInference<T>; | |
} | |
class ThemeSwitcherProvider<T extends string> extends React.Component<Props<T>> { } | |
const themes = { | |
light: 'public/light.css', | |
dark: 'public/dark.css', | |
}; | |
<ThemeSwitcherProvider defaultTheme="dark" themeMap={themes} /> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment