Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Fix description of Exclude and Extract types #1307

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jennings
Copy link

The previous description was:

Constructs a type by excluding/extracting from T all properties that are assignable to U.

This sounds to me like Exclude and Extract would do this:

interface Person {
  id: number;
  name: string;
}

type NumbersOnly = Extract<Person, number>;  // { id: number }
type NoNumbers = Exclude<Person, number>;    // { name: string }

I think "Constructs a type by excluding/extracting from T all types that are assignable to U," more clearly describes removing types from the union, rather than affecting its properties.

These types actually remove types from a union type. The previous
description sounds like it removes/includes properties of the given type
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant