jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/391605 )

Change subject: Hygiene: Use AnyComponent from Preact always
......................................................................


Hygiene: Use AnyComponent from Preact always

With the previous patch to update to typescript 2.6 with strict function
types, we had to reintroduce our own AnyComponent definition because our
FunctionalComponents were causing troubles with the preact type
definitions on the PageComponent definition.

Instead of having around two definitions of AnyComponent floating
around, this patch uses the preact ones everywhere, but specifies on the
PageComponent type that the Component can be partial, so that our
FunctionalComponents fit in.

Change-Id: I4b51047078c9abe7bebe2286e606c870954bcd31
---
M src/common/components/preact-utils.ts
M src/common/routers/route.ts
2 files changed, 3 insertions(+), 24 deletions(-)

Approvals:
  Niedzielski: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/src/common/components/preact-utils.ts 
b/src/common/components/preact-utils.ts
index b73479c..256a2d5 100644
--- a/src/common/components/preact-utils.ts
+++ b/src/common/components/preact-utils.ts
@@ -1,27 +1,6 @@
-import {
-  ComponentProps,
-  ComponentConstructor,
-  FunctionalComponent as PreactFunctionalComponent
-} from "preact";
-
 // todo: delete pending https://github.com/developit/preact/pull/869.
 export type ComponentChild = JSX.Element | string;
 export type ComponentChildren = ComponentChild[];
-
-// Identical to PreactFunctionalComponent but props are required for
-// TypeScript strictFunctionTypes.
-interface FunctionalComponentWithProps<Props>
-  extends Partial<PreactFunctionalComponent<Props>> {
-  (props: Props & ComponentProps<this>, context?: any): JSX.Element;
-}
-
-export type FunctionalComponent<Props> =
-  | PreactFunctionalComponent<Props>
-  | FunctionalComponentWithProps<Props>;
-
-export type AnyComponent<PropsType, StateType> =
-  | FunctionalComponent<PropsType>
-  | ComponentConstructor<PropsType, StateType>;
 
 export interface ChildrenProps {
   children?: ComponentChildren;
diff --git a/src/common/routers/route.ts b/src/common/routers/route.ts
index 4192965..6da4e3b 100644
--- a/src/common/routers/route.ts
+++ b/src/common/routers/route.ts
@@ -1,5 +1,5 @@
 import * as pathToRegExp from "path-to-regexp";
-import { AnyComponent } from "../components/preact-utils";
+import { AnyComponent } from "preact";
 import HttpResponse from "../http/http-response";
 
 /**
@@ -38,7 +38,7 @@
       status?: undefined;
 
       /** A Preact view component. */
-      Component: AnyComponent<Props, any>;
+      Component: Partial<AnyComponent<Props, any>>;
     }
   | {
       getInitialProps?: undefined;
@@ -49,7 +49,7 @@
        */
       status?: number;
 
-      Component: AnyComponent<undefined, any>;
+      Component: Partial<AnyComponent<undefined, any>>;
     };
 
 export interface PageModule<

-- 
To view, visit https://gerrit.wikimedia.org/r/391605
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I4b51047078c9abe7bebe2286e606c870954bcd31
Gerrit-PatchSet: 1
Gerrit-Project: marvin
Gerrit-Branch: master
Gerrit-Owner: Jhernandez <[email protected]>
Gerrit-Reviewer: Niedzielski <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to