fetch-extensions.ts
This file
Path
test-d/fetch-extensions.ts
21 lines · 821 bytes · TypeScript
Last changed by
Fix CISindre Sorhusbefore adoptiond9ddb03
History of this fileTake it
Explain both causes of a missing response and document the new validationSindre Sorhusbefore adoption58233f1
line 1why, one step back1import {expectTypeOf} from 'expect-type';Fix docsSindre Sorhusbefore adoptiond4ce7b1
lines 2–3why, one step back2import type {Options} from 'ky';3Explain both causes of a missing response and document the new validationSindre Sorhusbefore adoption58233f1
lines 4–16why, one step back4type NextFetchRequestConfig = {5 revalidate?: number | false;6 tags?: string[];7};89// Frameworks and runtimes declare their fetch-only extensions on the global `RequestInit`, the way Next.js declares `next` and `@types/node` declares `dispatcher`. Ky must pick up that type rather than redeclare the option, which conflicts with the ambient declaration.10declare global {11 // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- Global augmentation requires an interface.12 interface RequestInit {13 next?: NextFetchRequestConfig;14 }15}16Fix docsSindre Sorhusbefore adoptiond4ce7b1
lines 17–18why, one step back17const withNext: Options = {next: {revalidate: 0}};18Explain both causes of a missing response and document the new validationSindre Sorhusbefore adoption58233f1
lines 19–20why, one step back19expectTypeOf<Options['next']>().toEqualTypeOf<NextFetchRequestConfig | undefined>();20Fix CISindre Sorhusbefore adoptiond9ddb03
line 21why, one step back21expectTypeOf(withNext).toEqualTypeOf<Options>();