mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Address reviewer's comments
- Export functions instead of interfaces. - Remove unnecessary generics.
This commit is contained in:
parent
4457d1bd8c
commit
dd20246d10
5
types/fluent-langneg/index.d.ts
vendored
5
types/fluent-langneg/index.d.ts
vendored
@ -7,8 +7,5 @@ export interface LanguageNegotiationOptions {
|
||||
strategy?: 'filtering' | 'matching' | 'lookup';
|
||||
defaultLocale?: string;
|
||||
}
|
||||
export interface NegotiateLanguages {
|
||||
(requestedLocales: ReadonlyArray<string>, availableLocales: ReadonlyArray<string>, options?: LanguageNegotiationOptions): string[];
|
||||
}
|
||||
|
||||
export const negotiateLanguages: NegotiateLanguages;
|
||||
export function negotiateLanguages(requestedLocales: ReadonlyArray<string>, availableLocales: ReadonlyArray<string>, options?: LanguageNegotiationOptions): string[];
|
||||
|
||||
@ -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 = () => (
|
||||
<LocalizedHelloButton otherProp={2} someOtherProp='abc'/>
|
||||
);
|
||||
// Should not allow `getString` prop:
|
||||
const Test3 = () => (
|
||||
// $ExpectError
|
||||
<LocalizedHelloButton otherProp={2} someOtherProp='abc' getString={() => {}}/>
|
||||
);
|
||||
|
||||
// Should not allow any other props to be omitted:
|
||||
const Test4 = () => (
|
||||
// $ExpectError
|
||||
<LocalizedHelloButton otherProp={2}/>
|
||||
);
|
||||
|
||||
15
types/fluent-react/index.d.ts
vendored
15
types/fluent-react/index.d.ts
vendored
@ -94,13 +94,8 @@ export interface InjectedProps {
|
||||
// https://github.com/Microsoft/TypeScript/wiki/What%27s-new-in-TypeScript#predefined-conditional-types
|
||||
export type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
|
||||
|
||||
// Injects `getString` and removes it from the prop requirements.
|
||||
// Will not pass through `getString` if it's passed in during
|
||||
// render.
|
||||
export interface WithLocalization {
|
||||
<TNeedProps, C extends React.ComponentType<Matching<InjectedProps, GetProps<C>>>>(
|
||||
component: C
|
||||
): React.ComponentType<Omit< GetProps<C>, keyof Shared<InjectedProps, GetProps<C>>> & 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<C extends React.ComponentType<Matching<InjectedProps, GetProps<C>>>>(
|
||||
component: C
|
||||
): React.ComponentType<Omit< GetProps<C>, keyof Shared<InjectedProps, GetProps<C>>>>;
|
||||
|
||||
@ -1,6 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-unnecessary-generics": false
|
||||
}
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user