mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[final-form-focus] Add Typescript definitions. (#38200)
This commit is contained in:
parent
2ef13b1431
commit
acb3cb292b
12
types/final-form-focus/final-form-focus-tests.tsx
Normal file
12
types/final-form-focus/final-form-focus-tests.tsx
Normal file
@ -0,0 +1,12 @@
|
||||
import { Decorator, getIn } from 'final-form';
|
||||
import createDecorator, { FindInput, FocusableInput, getFormInputs, GetInputs } from 'final-form-focus';
|
||||
|
||||
createDecorator(); // $ExpectType Decorator<object>
|
||||
|
||||
const inputs = getFormInputs('formName'); // $ExpectType GetInputs
|
||||
createDecorator(inputs); // $ExpectType Decorator<object>
|
||||
|
||||
const findInput: FindInput = (inputs: FocusableInput[], errors: object) =>
|
||||
inputs.find(input => input.name && getIn(errors, input.name));
|
||||
|
||||
createDecorator(inputs, findInput); // $ExpectType Decorator<object>
|
||||
23
types/final-form-focus/index.d.ts
vendored
Normal file
23
types/final-form-focus/index.d.ts
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
// Type definitions for final-form-focus 1.1
|
||||
// Project: https://github.com/final-form/final-form-focus
|
||||
// Definitions by: Jeow Li Huan <https://github.com/huan086>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import { Decorator } from 'final-form';
|
||||
|
||||
export interface FocusableInput {
|
||||
name: string;
|
||||
focus: () => void;
|
||||
}
|
||||
|
||||
export type GetInputs = () => FocusableInput[];
|
||||
|
||||
export type FindInput = (inputs: FocusableInput[], errors: object) => FocusableInput | undefined;
|
||||
|
||||
export default function createDecorator(
|
||||
getInputs?: GetInputs,
|
||||
findInput?: FindInput,
|
||||
): Decorator;
|
||||
|
||||
export function getFormInputs(formName: string): GetInputs;
|
||||
6
types/final-form-focus/package.json
Normal file
6
types/final-form-focus/package.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"final-form": "4.x.x"
|
||||
}
|
||||
}
|
||||
25
types/final-form-focus/tsconfig.json
Normal file
25
types/final-form-focus/tsconfig.json
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"jsx": "react",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"final-form-focus-tests.tsx"
|
||||
]
|
||||
}
|
||||
1
types/final-form-focus/tslint.json
Normal file
1
types/final-form-focus/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user