mirror of
https://github.com/swc-project/swc.git
synced 2024-12-25 06:36:08 +03:00
b887b30092
**Description:** This is required for https://github.com/swc-project/swc/pull/6981 and https://github.com/swc-project/swc/pull/6950
35 lines
622 B
TypeScript
35 lines
622 B
TypeScript
// @strictNullChecks: true
|
|
// @allowUnreachableCode: false
|
|
function f1(
|
|
required: unknown = (() => {
|
|
throw new Error("bad");
|
|
})()
|
|
) {
|
|
console.log("ok"); // should not trigger 'Unreachable code detected.'
|
|
}
|
|
|
|
function f2(
|
|
a: number | string | undefined,
|
|
required: unknown = (() => {
|
|
a = 1;
|
|
})()
|
|
) {
|
|
a; // should be number | string | undefined
|
|
}
|
|
|
|
function f3(
|
|
a: number | string | undefined = 1,
|
|
required: unknown = (() => {
|
|
a = "";
|
|
})()
|
|
) {
|
|
a; // should be number | string
|
|
}
|
|
|
|
function f4(
|
|
a: number | string | undefined = 1,
|
|
{ [(a = "")]: b } = {} as any
|
|
) {
|
|
a; // should be string
|
|
}
|