File: conditionalTypesExcessProperties.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 (18 lines) | stat: -rw-r--r-- 570 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//// [conditionalTypesExcessProperties.ts]
type Something<T> = { test: string } &  (T extends object ? {
    arg: T
} : {
    arg?: undefined
    });

function testFunc2<A extends object>(a: A, sa: Something<A>) {
    sa = { test: 'hi', arg: a }; // not excess (but currently still not assignable)
    sa = { test: 'bye', arg: a, arr: a } // excess
}


//// [conditionalTypesExcessProperties.js]
function testFunc2(a, sa) {
    sa = { test: 'hi', arg: a }; // not excess (but currently still not assignable)
    sa = { test: 'bye', arg: a, arr: a }; // excess
}