json-undefined-schema.ts
This file
Path
test-d/json-undefined-schema.ts
19 lines · 751 bytes · TypeScript
Last changed by
Support readonly inputs and explicit undefined in TypeScript optionsSindre Sorhusbefore adoption51b3177
History of this fileTake it
Support readonly inputs and explicit undefined in TypeScript optionsSindre Sorhusbefore adoption51b3177
lines 1–19why, one step back1import {expectTypeOf} from 'expect-type';2import ky, {type StandardSchemaV1} from 'ky';34expectTypeOf(ky('https://example.com').json(undefined)).toEqualTypeOf<Promise<unknown>>();5expectTypeOf(ky<{name: string}>('https://example.com').json(undefined)).toEqualTypeOf<Promise<{name: string}>>();6expectTypeOf(ky('https://example.com').json<{name: string}>(undefined)).toEqualTypeOf<Promise<{name: string}>>();78const schema: StandardSchemaV1<unknown, number> = {9 '~standard': {10 version: 1,11 vendor: 'test',12 validate: () => ({value: 1}),13 },14};1516expectTypeOf(ky('https://example.com').json(schema)).toEqualTypeOf<Promise<number>>();1718// @ts-expect-error - Non-schema objects must not match either overload.19void ky('https://example.com').json({});