From 95fe9b36c1e9b68dd8f5dd58bc0bb4b7d2d930a8 Mon Sep 17 00:00:00 2001 From: Muhammad Fawwaz Orabi Date: Sat, 2 Dec 2017 23:12:37 +0200 Subject: [PATCH 1/3] Allow better TS inference for imported module type Example: ```typescript export const NotablePerson = universal(import('./NotablePerson'), { key: module => module.NotablePerson, }); ``` With this change, TypeScript is able to infer the type of `module` and provide auto completion, type checking and refactoring support. --- index.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/index.d.ts b/index.d.ts index 46227ed..675f9bc 100644 --- a/index.d.ts +++ b/index.d.ts @@ -72,7 +72,7 @@ declare module 'react-universal-component' { * It can be a string corresponding to the export key, or a function that's * passed the entire module and returns the export that will become the component. */ - key: string | ((module: Module) => ComponentType

); + key: string | ((module: Export) => ComponentType

); /** * Allows you to specify a maximum amount of time before the error component @@ -153,13 +153,13 @@ declare module 'react-universal-component' { export default function universal< P, C extends ComponentType

= ComponentType

, - Export extends Module

= Module

+ Export extends Module = Module >( loadSpec: - | PromiseLike> - | ((props: P) => PromiseLike>) + | PromiseLike + | ((props: P) => PromiseLike) | { - load(props: P): PromiseLike>; + load(props: P): PromiseLike; }, options?: Options, ): UniversalComponent

; From 0294b31a2d9efe7221ff4ff175013e6b874ab1da Mon Sep 17 00:00:00 2001 From: Muhammad Fawwaz Orabi Date: Sat, 2 Dec 2017 23:23:54 +0200 Subject: [PATCH 2/3] Add backticks around code in comments --- index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.d.ts b/index.d.ts index 675f9bc..826cf4a 100644 --- a/index.d.ts +++ b/index.d.ts @@ -40,7 +40,7 @@ declare module 'react-universal-component' { onAfter(info: Info): void; /** - * onError is similar to the onError static option, except it operates at the component + * `onError` is similar to the onError static option, except it operates at the component * level. Therefore you can bind to this of the parent component and call * `this.setState()` or `this.props.dispatch()`. * Again, it's use case is for when you want to show error information elsewhere in the @@ -91,8 +91,8 @@ declare module 'react-universal-component' { minDelay: number; /** - * alwaysDelay is a boolean you can set to true (default: false) to guarantee the - * minDelay is always used (i.e. even when components cached from previous imports + * `alwaysDelay` is a boolean you can set to true (default: false) to guarantee the + * `minDelay` is always used (i.e. even when components cached from previous imports * and therefore synchronously and instantly required). This can be useful for * guaranteeing animations operate as you want without having to wire up other * components to perform the task. @@ -105,7 +105,7 @@ declare module 'react-universal-component' { alwaysDelay: boolean; /** - * When set to false allows you to keep showing the current component when the + * When set to `false` allows you to keep showing the current component when the * loading component would otherwise show during transitions from one component to * the next. */ From 62aee98ce8fcf8a7b5e9629725ce686a9f72d7a6 Mon Sep 17 00:00:00 2001 From: Muhammad Fawwaz Orabi Date: Sun, 3 Dec 2017 00:12:23 +0200 Subject: [PATCH 3/3] Fix more comments --- index.d.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/index.d.ts b/index.d.ts index 826cf4a..93237cf 100644 --- a/index.d.ts +++ b/index.d.ts @@ -15,8 +15,9 @@ declare module 'react-universal-component' { isSync: boolean; /* - * Very rarely will you want to do stuff on the server; - * Note: server will always be sync) + * Very rarely will you want to do stuff on the server. + * + * _Note: server will always be sync_ */ isServer: boolean; }; @@ -91,7 +92,7 @@ declare module 'react-universal-component' { minDelay: number; /** - * `alwaysDelay` is a boolean you can set to true (default: false) to guarantee the + * `alwaysDelay` is a boolean you can set to true (default: `false`) to guarantee the * `minDelay` is always used (i.e. even when components cached from previous imports * and therefore synchronously and instantly required). This can be useful for * guaranteeing animations operate as you want without having to wire up other