Skip to content

Commit d85a92d

Browse files
committed
Fixed conflicts
1 parent efb81c2 commit d85a92d

File tree

8 files changed

+158
-116
lines changed

8 files changed

+158
-116
lines changed

.prettierrc

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1-
semi: false
2-
singleQuote: true
3-
trailingComma: none
1+
{
2+
"semi": false,
3+
"singleQuote": true,
4+
"trailingComma": "none",
5+
"overrides": [
6+
{
7+
"files": [".prettierrc"],
8+
"options": { "parser": "json" }
9+
},
10+
{
11+
"files": ["*.ts*"],
12+
"options": {
13+
"semi": true
14+
}
15+
}
16+
]
17+
}

package-scripts.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ module.exports = {
5252
andTest: series.nps('build', 'test.size')
5353
},
5454
copyTypes: series(
55-
npsUtils.copy('src/*.js.flow src/*.d.ts dist'),
55+
npsUtils.copy('src/*.js.flow dist'),
5656
npsUtils.copy(
5757
'dist/index.js.flow dist --rename="react-final-form.cjs.js.flow"'
5858
),
@@ -73,8 +73,10 @@ module.exports = {
7373
script: 'flow check'
7474
},
7575
typescript: {
76-
description: 'typescript check the entire project',
77-
script: 'tsc'
76+
default: {
77+
description: 'typescript',
78+
script: 'dtslint --onlyTestTsNext ./typescript'
79+
}
7880
},
7981
validate: {
8082
description:

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
"main": "dist/react-final-form.cjs.js",
66
"jsnext:main": "dist/react-final-form.es.js",
77
"module": "dist/react-final-form.es.js",
8-
"typings": "dist/index.d.ts",
8+
"typings": "typescript/index.d.ts",
99
"files": [
1010
"dist",
11-
"scripts"
11+
"scripts",
12+
"typescript"
1213
],
1314
"scripts": {
1415
"start": "nps",
@@ -50,8 +51,9 @@
5051
"babel-jest": "^24.1.0",
5152
"bundlesize": "^0.17.1",
5253
"doctoc": "^1.4.0",
53-
"eslint": "^5.15.0",
54-
"eslint-config-react-app": "^3.0.7",
54+
"dtslint": "^0.4.4",
55+
"eslint": "^5.13.0",
56+
"eslint-config-react-app": "^3.0.6",
5557
"eslint-plugin-babel": "^5.2.1",
5658
"eslint-plugin-flowtype": "^3.4.2",
5759
"eslint-plugin-import": "^2.16.0",

src/index.d.ts

Lines changed: 0 additions & 96 deletions
This file was deleted.

tsconfig.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

typescript/index.d.ts

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import * as React from 'react';
2+
import {
3+
FormApi,
4+
Config,
5+
Decorator,
6+
FormState,
7+
FormSubscription,
8+
FieldSubscription
9+
} from 'final-form';
10+
11+
export interface ReactContext {
12+
reactFinalForm: FormApi;
13+
}
14+
15+
export interface FieldRenderProps<T extends HTMLElement> {
16+
input: {
17+
name: string;
18+
onBlur: (event?: React.FocusEvent<T>) => void;
19+
onChange: (event: React.ChangeEvent<T>) => void;
20+
onFocus: (event?: React.FocusEvent<T>) => void;
21+
value: any;
22+
checked?: boolean;
23+
};
24+
meta: Partial<{
25+
// TODO: Make a diff of `FieldState` without all the functions
26+
active: boolean;
27+
data: object;
28+
dirty: boolean;
29+
dirtySinceLastSubmit: boolean;
30+
error: any;
31+
initial: any;
32+
invalid: boolean;
33+
pristine: boolean;
34+
submitError: any;
35+
submitFailed: boolean;
36+
submitSucceeded: boolean;
37+
submitting: boolean;
38+
touched: boolean;
39+
valid: boolean;
40+
visited: boolean;
41+
}>;
42+
}
43+
44+
export interface SubsetFormApi {
45+
batch: (fn: () => void) => void;
46+
blur: (name: string) => void;
47+
change: (name: string, value: any) => void;
48+
focus: (name: string) => void;
49+
initialize: (values: object) => void;
50+
mutators: { [key: string]: (...args: any[]) => any };
51+
reset: () => void;
52+
}
53+
54+
export interface FormRenderProps extends FormState, SubsetFormApi {
55+
batch: (fn: () => void) => void;
56+
form: FormApi;
57+
handleSubmit: (
58+
event?: React.SyntheticEvent<HTMLFormElement>
59+
) => Promise<object | undefined> | undefined;
60+
}
61+
62+
export interface FormSpyRenderProps extends FormState, SubsetFormApi {
63+
form: FormApi;
64+
}
65+
66+
export interface RenderableProps<T> {
67+
children?: ((props: T) => React.ReactNode) | React.ReactNode;
68+
component?: React.ComponentType<T> | string;
69+
render?: (props: T) => React.ReactNode;
70+
}
71+
72+
export interface FormProps extends Config, RenderableProps<FormRenderProps> {
73+
subscription?: FormSubscription;
74+
decorators?: Decorator[];
75+
initialValuesEqual?: (a?: object, b?: object) => boolean;
76+
}
77+
78+
export interface FieldProps<T extends HTMLElement>
79+
extends RenderableProps<FieldRenderProps<T>> {
80+
allowNull?: boolean;
81+
format?: ((value: any, name: string) => any) | null;
82+
formatOnBlur?: boolean;
83+
parse?: ((value: any, name: string) => any) | null;
84+
name: string;
85+
isEqual?: (a: any, b: any) => boolean;
86+
subscription?: FieldSubscription;
87+
validate?: (value: any, allValues: object) => any;
88+
value?: any;
89+
[otherProp: string]: any;
90+
}
91+
92+
export interface FormSpyProps extends RenderableProps<FormSpyRenderProps> {
93+
onChange?: (formState: FormState) => void;
94+
subscription?: FormSubscription;
95+
}
96+
97+
export const Field: React.ComponentType<FieldProps<any>>;
98+
export const Form: React.ComponentType<FormProps>;
99+
export const FormSpy: React.ComponentType<FormSpyProps>;
100+
export const version: string;
101+
102+
export function withReactFinalForm<T>(
103+
component: React.ComponentType<T>
104+
): React.ComponentType<T & ReactContext>;

typescript/index.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import * as React from 'react';
2+
import { Form } from 'react-final-form';
3+
4+
const noop = () => {};
5+
// missing required props
6+
const C1 = () => {
7+
// $ExpectError
8+
return <Form />;
9+
};
10+
11+
// provided required props
12+
const C2 = () => <Form onSubmit={noop} />;

typescript/tsconfig.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"compilerOptions": {
3+
"lib": ["es2015", "dom"],
4+
"jsx": "react",
5+
"baseUrl": ".",
6+
"noEmit": true,
7+
"strict": true,
8+
"moduleResolution": "node",
9+
"paths": {
10+
"react-final-form": [".."]
11+
}
12+
},
13+
"include": ["."]
14+
}

0 commit comments

Comments
 (0)