mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
55 lines
1.8 KiB
TypeScript
55 lines
1.8 KiB
TypeScript
//// [tests/cases/conformance/expressions/optionalChaining/optionalChainingInference.ts] ////
|
|
|
|
//// [optionalChainingInference.ts]
|
|
// https://github.com/microsoft/TypeScript/issues/34579
|
|
declare function unbox<T>(box: { value: T | undefined }): T;
|
|
declare const su: string | undefined;
|
|
declare const fnu: (() => number) | undefined;
|
|
declare const osu: { prop: string } | undefined;
|
|
declare const ofnu: { prop: () => number } | undefined;
|
|
|
|
const b1 = { value: su?.length };
|
|
const v1: number = unbox(b1);
|
|
|
|
const b2 = { value: su?.length as number | undefined };
|
|
const v2: number = unbox(b2);
|
|
|
|
const b3: { value: number | undefined } = { value: su?.length };
|
|
const v3: number = unbox(b3);
|
|
|
|
const b4 = { value: fnu?.() };
|
|
const v4: number = unbox(b4);
|
|
|
|
const b5 = { value: su?.["length"] };
|
|
const v5: number = unbox(b5);
|
|
|
|
const b6 = { value: osu?.prop.length };
|
|
const v6: number = unbox(b6);
|
|
|
|
const b7 = { value: osu?.prop["length"] };
|
|
const v7: number = unbox(b7);
|
|
|
|
const b8 = { value: ofnu?.prop() };
|
|
const v8: number = unbox(b8);
|
|
|
|
|
|
|
|
//// [optionalChainingInference.js]
|
|
"use strict";
|
|
const b1 = { value: su === null || su === void 0 ? void 0 : su.length };
|
|
const v1 = unbox(b1);
|
|
const b2 = { value: su === null || su === void 0 ? void 0 : su.length };
|
|
const v2 = unbox(b2);
|
|
const b3 = { value: su === null || su === void 0 ? void 0 : su.length };
|
|
const v3 = unbox(b3);
|
|
const b4 = { value: fnu === null || fnu === void 0 ? void 0 : fnu() };
|
|
const v4 = unbox(b4);
|
|
const b5 = { value: su === null || su === void 0 ? void 0 : su["length"] };
|
|
const v5 = unbox(b5);
|
|
const b6 = { value: osu === null || osu === void 0 ? void 0 : osu.prop.length };
|
|
const v6 = unbox(b6);
|
|
const b7 = { value: osu === null || osu === void 0 ? void 0 : osu.prop["length"] };
|
|
const v7 = unbox(b7);
|
|
const b8 = { value: ofnu === null || ofnu === void 0 ? void 0 : ofnu.prop() };
|
|
const v8 = unbox(b8);
|