Skip to content

Commit

Permalink
Updates for item danvk#7.
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonlotz committed Nov 15, 2023
1 parent 085734f commit 846e952
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions samples/ch02-types/item-07-types-as-sets/types-as-sets-09.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ interface Lifespan {
}
type PersonSpan = Person & Lifespan;
const ps: PersonSpan = {
name: 'Alan Turing',
birth: new Date('1912/06/23'),
death: new Date('1954/06/07'),
}; // OK
name: "Alan Turing",
birth: new Date("1912/06/23"),
death: new Date("1954/06/07"),
}; // OK

type PersonSpan2 = keyof (Person & Lifespan); // "name" | "birth" | "death?"
type PersonSpan3 = keyof Person | keyof Lifespan; // "name" | "birth" | "death?"

type PersonSpan4 = keyof (Person | Lifespan); // never
type PersonSpan5 = keyof Person & keyof Lifespan; // never

0 comments on commit 846e952

Please sign in to comment.