From b484f60b1009708a2bd131fbb4a45e19e3989292 Mon Sep 17 00:00:00 2001 From: Alexander T Date: Wed, 6 Nov 2019 19:06:51 +0200 Subject: [PATCH] theming: Provides its own types (#39555) --- notNeededPackages.json | 6 +++ types/theming/index.d.ts | 59 ------------------------ types/theming/theming-tests.tsx | 79 --------------------------------- types/theming/tsconfig.json | 24 ---------- types/theming/tslint.json | 1 - 5 files changed, 6 insertions(+), 163 deletions(-) delete mode 100644 types/theming/index.d.ts delete mode 100644 types/theming/theming-tests.tsx delete mode 100644 types/theming/tsconfig.json delete mode 100644 types/theming/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index ee7f1f74bc..05329625eb 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -4644,6 +4644,12 @@ "sourceRepoURL": "https://github.com/terser-js/terser", "asOfVersion": "3.12.0" }, + { + "libraryName": "theming", + "typingsPackageName": "theming", + "sourceRepoURL": "https://github.com/cssinjs/theming", + "asOfVersion": "2.0.0" + }, { "libraryName": "text-clipper", "typingsPackageName": "text-clipper", diff --git a/types/theming/index.d.ts b/types/theming/index.d.ts deleted file mode 100644 index 3de78a6434..0000000000 --- a/types/theming/index.d.ts +++ /dev/null @@ -1,59 +0,0 @@ -// Type definitions for theming 1.3 -// Project: https://github.com/cssinjs/theming -// Definitions by: Sebastian Silbermann -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.8 -import * as React from "react"; - -export type Channel = string; -export type Theme = object | ((outerTheme: object) => object); - -export const channel: "__THEMING__"; - -/** - * Returns a component with an already passed Theme listening on the default channel - */ -export function withTheme

( - component: React.ComponentType

-): React.ComponentType>>; - -export interface ThemeProviderProps { - theme: Theme; - children?: React.ReactElement; -} -/** - * Provide a theme to an entire react component listening on the default channel - */ -export class ThemeProvider extends React.Component {} - -export type SubscriptionId = number; -export interface Broadcast { - getState(): T; - subscribe(callback: () => void): SubscriptionId; - unsubscribe(id: SubscriptionId): void; -} -export type ContextWithTheme = Record>; -export interface ThemeListener { - initial(context: ContextWithTheme): Theme; - subscribe( - context: ContextWithTheme, - callback: (theme: Theme) => void - ): SubscriptionId; - unsubscribe(context: ContextWithTheme, id: SubscriptionId): void; - contextTypes: React.ValidationMap; -} -/** - * ThemeListener for the default channel - */ -export const themeListener: ThemeListener; - -export interface Theming { - channel: C; - withTheme: typeof withTheme; - ThemeProvider: ThemeProvider; - themeListener: ThemeListener; -} -/** - * creates a new Theming on the given channel - */ -export function createTheming(customChannel?: C): Theming; diff --git a/types/theming/theming-tests.tsx b/types/theming/theming-tests.tsx deleted file mode 100644 index 18d24923bf..0000000000 --- a/types/theming/theming-tests.tsx +++ /dev/null @@ -1,79 +0,0 @@ -import * as React from "react"; -import { - channel, - ContextWithTheme, - Theme, - themeListener, - ThemeProvider, - withTheme -} from "theming"; - -// Typings currently accept non-plain-objects while they get rejected at runtime. -// There exists currently no typing for plain objects. -const runtimeErrorTheme: Theme = []; - -const customTheme = { - color: { - primary: "red", - secondary: "blue" - } -}; -type CustomTheme = typeof customTheme; - -interface DemoBoxProps { - text: string; - theme: CustomTheme; -} -const DemoBox = ({ text, theme }: DemoBoxProps) => { - return

{text}
; -}; -const ThemedDemoBox = withTheme(DemoBox); -const renderDemoBox = () => ; - -const App = () => { - return ( - - - - ); -}; - -const AugmentedApp = () => { - return ( - - ({ ...outerTheme, augmented: true })}> - - - - ); -}; - -function customWithTheme

( - // tslint:disable-next-line: no-unnecessary-generics - Component: React.ComponentType

-) { - return class CustomWithTheme extends React.Component { - static contextTypes = themeListener.contextTypes; - - setTheme = (theme: object) => this.setState({ theme }); - subscription: number | undefined; - - constructor(props: P, context: ContextWithTheme) { - super(props, context); - this.state = { theme: themeListener.initial(context) }; - } - componentDidMount() { - this.subscription = themeListener.subscribe(this.context, this.setTheme); - } - componentWillUnmount() { - const { subscription } = this; - if (subscription != null) { - themeListener.unsubscribe(this.context, subscription); - } - } - render() { - const { theme } = this.state; - return ; - } - }; -} diff --git a/types/theming/tsconfig.json b/types/theming/tsconfig.json deleted file mode 100644 index 35fe4e7ffd..0000000000 --- a/types/theming/tsconfig.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true, - "jsx": "react", - "strictFunctionTypes": true - }, - "files": [ - "index.d.ts", - "theming-tests.tsx" - ] -} diff --git a/types/theming/tslint.json b/types/theming/tslint.json deleted file mode 100644 index 3db14f85ea..0000000000 --- a/types/theming/tslint.json +++ /dev/null @@ -1 +0,0 @@ -{ "extends": "dtslint/dt.json" }