Skip to content

Commit

Permalink
Add test for #858
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Apr 8, 2024
1 parent 7768ed6 commit 2547a00
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test-d/override-properties.ts
@@ -1,4 +1,5 @@
import {expectType} from 'tsd';
import {expectTypeOf} from 'expect-type';
import type {OverrideProperties} from '../source/override-properties';

type Foo = {
Expand All @@ -14,3 +15,20 @@ type Bar = OverrideProperties<Foo, {c: number}>;

// @ts-expect-error
type Bar = OverrideProperties<Foo, {b: number; c: number}>;

// Test for https://github.com/sindresorhus/type-fest/issues/858
{ // eslint-disable-line no-lone-blocks
type Original = {
foo: string;
bar: string;
};

type Modified = {
foo: string | undefined;
bar: string;
};

type Final = OverrideProperties<Original, Modified>;

expectTypeOf<Final>().toMatchTypeOf<{foo: string | undefined; bar: string}>();
}

0 comments on commit 2547a00

Please sign in to comment.