-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: fix types in
@formspree/core
(#44)
`@formspree/core`\ - fix `SubmissionData` has a type of `any` causing everything after it to opt-out typechecking - remove a no-op `teardown` method on `Client` and `Session` - remove `utils.now` and use `Date.now` instead - remove unused functions from `utils` module: `append`, `toCamel`, `camelizeTopKeys` - add tests for `utils.appendExtraData` and convert the test file to typescript - add tests for `session.data()` - no longer export `Session` type `@formspree/react` - update types as a result of `SubmissionData` is no longer `any` - fix `createPaymentMethod` does not properly map payload when the submission data is a type of `FormData` - fix the `Client` is not updated when project changes
- Loading branch information
Showing
13 changed files
with
259 additions
and
143 deletions.
There are no files selected for viewing
This file contains 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,22 @@ | ||
--- | ||
'@formspree/react': minor | ||
'@formspree/core': minor | ||
--- | ||
|
||
# Fix types in @formspree/core | ||
|
||
## `@formspree/core` | ||
|
||
- fix `SubmissionData` has a type of `any` causing everything after it to opt-out typechecking | ||
- remove a no-op `teardown` method on `Client` and `Session` | ||
- remove `utils.now` and use `Date.now` instead | ||
- remove unused functions from `utils` module: `append`, `toCamel`, `camelizeTopKeys` | ||
- add tests for `utils.appendExtraData` and convert the test file to typescript | ||
- add tests for `session.data()` | ||
- no longer export `Session` type | ||
|
||
## `@formspree/react` | ||
|
||
- update types as a result of `SubmissionData` is no longer `any` | ||
- fix `createPaymentMethod` does not properly map payload when the submission data is a type of `FormData` | ||
- fix the `Client` is not updated when project changes |
This file contains 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 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,5 @@ | ||
// declare PhantomJS properties that we check in session webdriver. | ||
declare interface Window { | ||
_phantom?: unknown; | ||
callPhantom?: unknown; | ||
} |
This file contains 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 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 |
---|---|---|
|
@@ -7,4 +7,3 @@ export { | |
type ErrorBody, | ||
type FieldError, | ||
} from './forms'; | ||
export { type Session } from './session'; |
This file contains 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 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 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,42 @@ | ||
import { Session } from '../src/session'; | ||
|
||
describe('Session', () => { | ||
const now = Date.now(); | ||
|
||
beforeEach(() => { | ||
jest.useFakeTimers({ now }); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.useRealTimers(); | ||
}); | ||
|
||
describe('with webdriver', () => { | ||
beforeEach(() => { | ||
// pretend running in PhantomJS | ||
window._phantom = {}; | ||
}); | ||
|
||
afterEach(() => { | ||
window._phantom = undefined; | ||
}); | ||
|
||
it('returns the correct data', () => { | ||
const sess = new Session(); | ||
expect(sess.data()).toEqual({ | ||
loadedAt: now, | ||
webdriver: true, | ||
}); | ||
}); | ||
}); | ||
|
||
describe('without webdriver', () => { | ||
it('returns the correct data', () => { | ||
const sess = new Session(); | ||
expect(sess.data()).toEqual({ | ||
loadedAt: now, | ||
webdriver: false, | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains 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 was deleted.
Oops, something went wrong.
Oops, something went wrong.
4c40e1b
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.
Successfully deployed to the following URLs:
formspree-react-demo – ./
formspree-react-demo-git-main-formspree.vercel.app
formspree-react.vercel.app
react-demo.formspree.io
formspree-react-demo-formspree.vercel.app