-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(react-query): easier to know constraint @tanstack/react-query v4 …
…runtimely (#893) # Overview <!-- A clear and concise description of what this pr is about. --> We expect version of @tanstack/react-query's as only v4. so we warn it with this change to promote installing correct version ## PR Checklist - [x] I did below actions if need 1. I read the [Contributing Guide](https://github.com/suspensive/react/blob/main/CONTRIBUTING.md) 2. I added documents and tests.
- Loading branch information
Showing
5 changed files
with
40 additions
and
0 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,5 @@ | ||
--- | ||
"@suspensive/react-query": patch | ||
--- | ||
|
||
fix(react-query): easier to know constraint @tanstack/react-query v4 runtimely |
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 @@ | ||
export { isVersion } from './isVersion' |
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,17 @@ | ||
import { isVersion } from './isVersion' | ||
|
||
describe('isVersion', () => { | ||
it('should check the version correctly', () => { | ||
expect(isVersion(4).of('4.32.1')).toBe(true) | ||
expect(isVersion(4).of('5.32.1')).toBe(false) | ||
expect(isVersion(4).of('3.32.1')).toBe(false) | ||
|
||
expect(isVersion(4).of('4.32.1-beta.32')).toBe(true) | ||
expect(isVersion(4).of('5.32.1-beta.32')).toBe(false) | ||
expect(isVersion(4).of('3.32.1-beta.32')).toBe(false) | ||
|
||
expect(isVersion(4).of('4')).toBe(true) | ||
expect(isVersion(4).of('5')).toBe(false) | ||
expect(isVersion(4).of('3')).toBe(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export const isVersion = (version: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7) => ({ | ||
of: (packageVersion: string) => { | ||
const [major] = packageVersion.split('.').map(Number) | ||
return major === version | ||
}, | ||
}) |