File: indexedAccessRetainsIndexSignature.js

package info (click to toggle)
node-typescript 3.3.3333-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 324,548 kB
  • sloc: makefile: 6; sh: 3
file content (15 lines) | stat: -rw-r--r-- 533 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//// [indexedAccessRetainsIndexSignature.ts]
type Diff<T extends keyof any, U extends keyof any> =
    ({ [P in T]: P } & { [P in U]: never } & { [x: string]: never })[T]
type Omit<U, K extends keyof U> = Pick<U, Diff<keyof U, K>>
type Omit1<U, K extends keyof U> = Pick<U, Diff<keyof U, K>>;
// is in fact an equivalent of

type Omit2<T, K extends keyof T> = {[P in Diff<keyof T, K>]: T[P]};

type O = Omit<{ a: number, b: string }, 'a'>
const o: O = { b: '' }


//// [indexedAccessRetainsIndexSignature.js]
var o = { b: '' };