-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implement typed
URLSearchParams
(#19)
- Loading branch information
1 parent
a8c6ceb
commit 749d4bb
Showing
11 changed files
with
363 additions
and
72 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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@denosaurs/typefetch", | ||
"version": "0.0.30", | ||
"version": "0.0.31", | ||
"exports": { | ||
".": "./main.ts" | ||
}, | ||
|
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
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,23 @@ | ||
import type { Equal, Expect, IsUnion, NotEqual } from "npm:type-testing"; | ||
import type { Error, Pets } from "./schemas/petstore.json.ts"; | ||
|
||
import { URLSearchParams } from "../../types/url_search_params.ts"; | ||
|
||
const urlSearchParams = new URLSearchParams<{ limit?: `${number}` }>({ | ||
limit: "10", | ||
}); | ||
const response = await fetch( | ||
`http://petstore.swagger.io/v1/pets?${urlSearchParams.toString()}`, | ||
); | ||
|
||
if (response.ok) { | ||
const json = await response.json(); | ||
type test_IsUnion = Expect<IsUnion<typeof json>>; | ||
type test_IsPetsOrError = Expect<Equal<typeof json, Pets | Error>>; | ||
} | ||
|
||
if (response.status === 200) { | ||
const pets = await response.json(); | ||
type test_IsPets = Expect<Equal<typeof pets, Pets>>; | ||
type test_IsNotError = Expect<NotEqual<typeof pets, Error>>; | ||
} |
Oops, something went wrong.