mirror of
https://github.com/swc-project/swc.git
synced 2024-12-01 01:13:56 +03:00
12 lines
492 B
TypeScript
12 lines
492 B
TypeScript
// @strict: true
|
|
|
|
declare function absorb<T>(): T;
|
|
declare const a: { m?<T>(obj: {x: T}): T } | undefined;
|
|
const n1: number = a?.m?.({x: 12 }); // should be an error (`undefined` is not assignable to `number`)
|
|
const n2: number = a?.m?.({x: absorb()}); // likewise
|
|
const n3: number | undefined = a?.m?.({x: 12}); // should be ok
|
|
const n4: number | undefined = a?.m?.({x: absorb()}); // likewise
|
|
|
|
// Also a test showing `!` vs `?` for good measure
|
|
let t1 = a?.m?.({x: 12});
|
|
t1 = a!.m!({x: 12}); |