Skip to content

Commit

Permalink
test: typescript type
Browse files Browse the repository at this point in the history
  • Loading branch information
tsctx committed Nov 13, 2023
1 parent 46b98d3 commit 8bd9655
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion test/types/header.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
import { IncomingHttpHeaders as CoreIncomingHttpHeaders } from "http";
import { expectAssignable, expectNotAssignable } from "tsd";
import { IncomingHttpHeaders } from "../../types/header";
import {
IncomingHttpHeaders,
IncomingH2PseudoHeaders,
} from "../../types/header";

const headers = {
authorization: undefined,
["content-type"]: "application/json",
} satisfies CoreIncomingHttpHeaders;

const pseudoHeaders = {
":status": 200,
} satisfies IncomingH2PseudoHeaders;

expectAssignable<IncomingHttpHeaders>(headers);

expectAssignable<IncomingH2PseudoHeaders>(pseudoHeaders);

// It is why we do not need to add ` | null` to `IncomingHttpHeaders`:
expectNotAssignable<CoreIncomingHttpHeaders>({
authorization: null,
Expand Down

0 comments on commit 8bd9655

Please sign in to comment.