From dd20246d107d0eba89cfd0fdcdac7fca2dc4ed46 Mon Sep 17 00:00:00 2001 From: Huy Nguyen Date: Thu, 24 Jan 2019 11:31:29 -0500 Subject: [PATCH] Address reviewer's comments - Export functions instead of interfaces. - Remove unnecessary generics. --- types/fluent-langneg/index.d.ts | 5 +---- types/fluent-react/fluent-react-tests.tsx | 13 +++++++++++++ types/fluent-react/index.d.ts | 15 +++++---------- types/fluent-react/tslint.json | 5 +---- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/types/fluent-langneg/index.d.ts b/types/fluent-langneg/index.d.ts index f289f0415b..28abe2c2d9 100644 --- a/types/fluent-langneg/index.d.ts +++ b/types/fluent-langneg/index.d.ts @@ -7,8 +7,5 @@ export interface LanguageNegotiationOptions { strategy?: 'filtering' | 'matching' | 'lookup'; defaultLocale?: string; } -export interface NegotiateLanguages { - (requestedLocales: ReadonlyArray, availableLocales: ReadonlyArray, options?: LanguageNegotiationOptions): string[]; -} -export const negotiateLanguages: NegotiateLanguages; +export function negotiateLanguages(requestedLocales: ReadonlyArray, availableLocales: ReadonlyArray, options?: LanguageNegotiationOptions): string[]; diff --git a/types/fluent-react/fluent-react-tests.tsx b/types/fluent-react/fluent-react-tests.tsx index 15fbfe41b9..225749d64e 100644 --- a/types/fluent-react/fluent-react-tests.tsx +++ b/types/fluent-react/fluent-react-tests.tsx @@ -29,6 +29,7 @@ ReactDOM.render( interface Props { getString: GetString; otherProp: number; + someOtherProp: string; } function HelloButton(props: Props) { const { getString } = props; @@ -42,6 +43,18 @@ function HelloButton(props: Props) { const LocalizedHelloButton = withLocalization(HelloButton); +// Remove `getString` from list of required props: const Test2 = () => ( + +); +// Should not allow `getString` prop: +const Test3 = () => ( + // $ExpectError + {}}/> +); + +// Should not allow any other props to be omitted: +const Test4 = () => ( + // $ExpectError ); diff --git a/types/fluent-react/index.d.ts b/types/fluent-react/index.d.ts index a2b0e88b7b..5ffc93d874 100644 --- a/types/fluent-react/index.d.ts +++ b/types/fluent-react/index.d.ts @@ -94,13 +94,8 @@ export interface InjectedProps { // https://github.com/Microsoft/TypeScript/wiki/What%27s-new-in-TypeScript#predefined-conditional-types export type Omit = Pick>; -// Injects `getString` and removes it from the prop requirements. -// Will not pass through `getString` if it's passed in during -// render. -export interface WithLocalization { - >>>( - component: C - ): React.ComponentType, keyof Shared>> & TNeedProps>; -} - -export const withLocalization: WithLocalization; +// Injects `getString` and removes it from the prop requirements. Will not pass +// through `getString` if it's passed in during render. +export function withLocalization>>>( + component: C +): React.ComponentType, keyof Shared>>>; diff --git a/types/fluent-react/tslint.json b/types/fluent-react/tslint.json index e27ad90359..d88586e5bd 100644 --- a/types/fluent-react/tslint.json +++ b/types/fluent-react/tslint.json @@ -1,6 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "no-unnecessary-generics": false - } + "extends": "dtslint/dt.json" }