From 31ad79f88f711a9169a0adf54734f0bf6bd334d2 Mon Sep 17 00:00:00 2001 From: Tim Wang Date: Wed, 20 Dec 2017 13:36:22 +0800 Subject: [PATCH 1/7] Add MKComponent Builder property --- types/react-native-material-kit/index.d.ts | 32 ++++++++++++---------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/types/react-native-material-kit/index.d.ts b/types/react-native-material-kit/index.d.ts index d9564be179..dfb7317ca6 100644 --- a/types/react-native-material-kit/index.d.ts +++ b/types/react-native-material-kit/index.d.ts @@ -1,6 +1,7 @@ -// Type definitions for react-native-material-kit 0.4 +// Type definitions for react-native-material-kit 0.5 // Project: https://github.com/xinthink/react-native-material-kit // Definitions by: Kyle Roach +// Tim Wang // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 @@ -186,6 +187,10 @@ export interface TickProperties extends ViewProperties { // COMPONENTS /////////////////////////////// +export interface MKComponent extends React.Component { + Builder: () => any; +} + export interface MKColorStatic { Amber: string; Blue: string; @@ -374,32 +379,29 @@ export const MKColor: MKColorStatic; export function setTheme(theme: ThemeStatic): void; export function getTheme(): ThemeStatic; -export class MKButton extends React.Component {} +export class MKButton extends MKComponent {} -export class MKTextField extends React.Component {} +export class MKTextField extends MKComponent {} -export class MKSwitch extends React.Component {} +export class MKSwitch extends MKComponent {} -export class MKIconToggle extends - React.Component {} +export class MKIconToggle extends MKComponent {} -export class MKRipple extends React.Component {} +export class MKRipple extends MKComponent {} -export class MKProgress extends React.Component {} +export class MKProgress extends MKComponent {} export namespace MKProgress { class Indeterminate extends React.Component {} } -export class MKSlider extends React.Component {} +export class MKSlider extends MKComponent {} -export class MKRangeSlider extends - React.Component {} +export class MKRangeSlider extends MKComponent {} -export class MKSpinner extends React.Component {} +export class MKSpinner extends MKComponent {} -export class MKRadioButton extends -React.Component {} +export class MKRadioButton extends MKComponent {} export namespace MKRadioButton { class MKRadioButton {} @@ -416,4 +418,4 @@ export namespace MKRadioButton { } } -export class MKCheckbox extends React.Component {} +export class MKCheckbox extends MKComponent {} From 3acd595b9181b81462254385b0ad8cd770596654 Mon Sep 17 00:00:00 2001 From: Tim Wang Date: Wed, 20 Dec 2017 13:43:17 +0800 Subject: [PATCH 2/7] Add Builder test --- .../react-native-material-kit-tests.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/types/react-native-material-kit/react-native-material-kit-tests.tsx b/types/react-native-material-kit/react-native-material-kit-tests.tsx index e26abfe5fc..5971d397eb 100644 --- a/types/react-native-material-kit/react-native-material-kit-tests.tsx +++ b/types/react-native-material-kit/react-native-material-kit-tests.tsx @@ -27,6 +27,10 @@ const ButtonTest = () => ; +const ButtonBuilderTest = new MKButton.Builder() + .withBackgroundColor(MKColor.Teal) + .build(); + //// TEXT FIELD interface MKTextFieldTestState { From fb0400356cfe4031b1e0c0c6593e6c547e315fb4 Mon Sep 17 00:00:00 2001 From: Tim Wang Date: Wed, 20 Dec 2017 14:04:49 +0800 Subject: [PATCH 3/7] Fix interface to class --- types/react-native-material-kit/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-native-material-kit/index.d.ts b/types/react-native-material-kit/index.d.ts index dfb7317ca6..568b7b6bf4 100644 --- a/types/react-native-material-kit/index.d.ts +++ b/types/react-native-material-kit/index.d.ts @@ -187,7 +187,7 @@ export interface TickProperties extends ViewProperties { // COMPONENTS /////////////////////////////// -export interface MKComponent extends React.Component { +export class MKComponent extends React.Component { Builder: () => any; } From bac30ca0c35d2f7d2ee81d37b102c8928de643c0 Mon Sep 17 00:00:00 2001 From: Tim Wang Date: Wed, 20 Dec 2017 14:14:35 +0800 Subject: [PATCH 4/7] Update index.d.ts --- types/react-native-material-kit/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-native-material-kit/index.d.ts b/types/react-native-material-kit/index.d.ts index 568b7b6bf4..b01b22080a 100644 --- a/types/react-native-material-kit/index.d.ts +++ b/types/react-native-material-kit/index.d.ts @@ -188,7 +188,7 @@ export interface TickProperties extends ViewProperties { /////////////////////////////// export class MKComponent extends React.Component { - Builder: () => any; + Builder(): any; } export interface MKColorStatic { From b40a6ac0473038456a2f6ccffe86e6ae4e205f41 Mon Sep 17 00:00:00 2001 From: Tim Wang Date: Wed, 20 Dec 2017 14:20:00 +0800 Subject: [PATCH 5/7] Builder is static --- types/react-native-material-kit/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-native-material-kit/index.d.ts b/types/react-native-material-kit/index.d.ts index b01b22080a..e6b15cb9a5 100644 --- a/types/react-native-material-kit/index.d.ts +++ b/types/react-native-material-kit/index.d.ts @@ -188,7 +188,7 @@ export interface TickProperties extends ViewProperties { /////////////////////////////// export class MKComponent extends React.Component { - Builder(): any; + static Builder(): any; } export interface MKColorStatic { From 890cb36547a16dde3adef77d49edc850ab8fd08e Mon Sep 17 00:00:00 2001 From: Tim Wang Date: Wed, 20 Dec 2017 14:33:48 +0800 Subject: [PATCH 6/7] Builder return class itself --- types/react-native-material-kit/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-native-material-kit/index.d.ts b/types/react-native-material-kit/index.d.ts index e6b15cb9a5..0d38e23271 100644 --- a/types/react-native-material-kit/index.d.ts +++ b/types/react-native-material-kit/index.d.ts @@ -188,7 +188,7 @@ export interface TickProperties extends ViewProperties { /////////////////////////////// export class MKComponent extends React.Component { - static Builder(): any; + static Builder(): MKComponent; } export interface MKColorStatic { From 71f795500c068bd55eb78ad7c52796ab5f24e52a Mon Sep 17 00:00:00 2001 From: Tim Wang Date: Wed, 20 Dec 2017 14:38:28 +0800 Subject: [PATCH 7/7] Let's just call it any Static members cannot reference class type parameters. --- types/react-native-material-kit/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-native-material-kit/index.d.ts b/types/react-native-material-kit/index.d.ts index 0d38e23271..5dc9b63aff 100644 --- a/types/react-native-material-kit/index.d.ts +++ b/types/react-native-material-kit/index.d.ts @@ -188,7 +188,7 @@ export interface TickProperties extends ViewProperties { /////////////////////////////// export class MKComponent extends React.Component { - static Builder(): MKComponent; + static Builder: any; } export interface MKColorStatic {