-
-
Notifications
You must be signed in to change notification settings - Fork 40
typescript tests and fixes #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2a736d8
[typescript] test and fixes for index.d.ts
rosskevin 77d51f3
fix reference to typings file #7
rosskevin 7fab324
a bit simpler usage depending on https://github.com/final-form/final-…
rosskevin 6699402
export a default type
rosskevin 6827e9d
Upgraded final-form dep to v4.0.4
erikras 28035c5
fix default import
rosskevin 345c801
npm install
rosskevin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,5 @@ lib | |
es | ||
npm-debug.log | ||
.DS_Store | ||
.idea | ||
yarn.lock |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,15 +5,16 @@ | |
"main": "dist/final-form-arrays.cjs.js", | ||
"jsnext:main": "dist/final-form-arrays.es.js", | ||
"module": "dist/final-form-arrays.es.js", | ||
"typings": "dist/index.d.js", | ||
"files": ["dist"], | ||
"typings": "dist/index.d.ts", | ||
"files": [ | ||
"dist" | ||
], | ||
"scripts": { | ||
"start": "nps", | ||
"test": "nps test", | ||
"precommit": "lint-staged && npm start validate" | ||
}, | ||
"author": | ||
"Erik Rasmussen <[email protected]> (http://github.com/erikras)", | ||
"author": "Erik Rasmussen <[email protected]> (http://github.com/erikras)", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
|
@@ -39,7 +40,7 @@ | |
"eslint-plugin-import": "^2.8.0", | ||
"eslint-plugin-jsx-a11y": "^6.0.3", | ||
"eslint-plugin-react": "^7.5.1", | ||
"final-form": "^1.3.5", | ||
"final-form": "^4.0.3", | ||
"flow": "^0.2.3", | ||
"flow-bin": "^0.61.0", | ||
"husky": "^0.14.3", | ||
|
@@ -55,13 +56,17 @@ | |
"rollup-plugin-flow": "^1.1.1", | ||
"rollup-plugin-node-resolve": "^3.0.0", | ||
"rollup-plugin-replace": "^2.0.0", | ||
"rollup-plugin-uglify": "^2.0.1" | ||
"rollup-plugin-uglify": "^2.0.1", | ||
"typescript": "^2.6.2" | ||
}, | ||
"peerDependencies": { | ||
"final-form": ">=1.2.0" | ||
}, | ||
"lint-staged": { | ||
"*.{js*,ts,json,md,css}": ["prettier --write", "git add"] | ||
"*.{js*,ts*,json,md,css}": [ | ||
"prettier --write", | ||
"git add" | ||
] | ||
}, | ||
"bundlesize": [ | ||
{ | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// tslint:disable no-console | ||
|
||
import { Config, createForm, AnyObject } from 'final-form' | ||
import * as arrayMutators from './index' | ||
import { Mutators } from './index' | ||
|
||
const onSubmit: Config['onSubmit'] = (values, callback) => {} | ||
|
||
const form = createForm({ | ||
mutators: { ...arrayMutators }, | ||
onSubmit | ||
}) | ||
|
||
// Get form.mutators (default as object) and cast to Mutators | ||
const mutators: Mutators = ((form.mutators || {}) as any) as Mutators | ||
|
||
mutators.insert('customers', 0, { firstName: '', lastName: '' }) | ||
mutators.move('customers', 0, 1) | ||
const customer = mutators.pop('customers') | ||
mutators.push('customers', { firstName: '', lastName: '' }) | ||
const removed = mutators.remove('customers', 0) | ||
const shifted = mutators.shift('customers') | ||
mutators.swap('customers', 0, 1) | ||
mutators.unshift('customers', { firstName: '', lastName: '' }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"noEmit": true, | ||
"strict": true | ||
}, | ||
"include": ["./src/**/*"] | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI - This casting is a bit gross, but unless we allow parameterized types in the form and expose it all the way through, this is the way it needs to be done. Parameterized types in jsx is already painful so this is not any worse by any means.