Added tests and for-of/for-in down-leveling

This commit is contained in:
Ron Buckton
2017-02-24 17:31:21 -08:00
parent f8f3ba75e8
commit 6a9e7e50e5
28 changed files with 15993 additions and 161 deletions
+2 -2
View File
@@ -15818,8 +15818,8 @@ namespace ts {
}
let leftType = checkExpression(left, contextualMapper);
let rightType = checkExpression(right, contextualMapper);
let propagateNull = operator >= SyntaxKind.FirstAssignment && operator <= SyntaxKind.LastAssignment && left.flags & NodeFlags.PropagateNull;
let propagatingType = propagateNull ? getNullPropagatingType(leftType) : neverType;
const propagateNull = operator >= SyntaxKind.FirstAssignment && operator <= SyntaxKind.LastAssignment && left.flags & NodeFlags.PropagateNull;
const propagatingType = propagateNull ? getNullPropagatingType(leftType) : neverType;
if (propagateNull) {
leftType = getNonNullableType(leftType);
}
+118 -154
View File
@@ -2376,12 +2376,21 @@ namespace ts {
}
}
export function insertLeadingStatement(dest: Statement, source: Statement) {
if (isBlock(dest)) {
return updateBlock(dest, setTextRange(createNodeArray([source, ...dest.statements]), dest.statements));
export function insertLeadingStatement(embeddedStatement: Statement, newStatement: Statement) {
if (isBlock(embeddedStatement)) {
return updateBlock(
embeddedStatement,
setTextRange(
createNodeArray([newStatement, ...embeddedStatement.statements]),
embeddedStatement.statements
)
);
}
else {
return createBlock(createNodeArray([dest, source]), /*multiLine*/ true);
return createBlock(
createNodeArray([newStatement, embeddedStatement]),
/*multiLine*/ true
);
}
}
@@ -2402,67 +2411,28 @@ namespace ts {
return updated;
}
export const enum CreateRefFlags {
Readable = 1 << 0,
Writable = 1 << 1,
ReadWrite = Readable | Writable,
}
/**
* Creates an expression that can be used to bind a reference to an identifier or property.
* Creates an expression that can be used to bind a reference to an identifier, property access, or element access.
*
* For an identifier `x`, this creates an expression similar to the following:
* This creates an expression similar to the following:
*
* ({
* get value() { return x; },
* set value(_a) { x = _a; }
* })
*
* For a property `x.y`, this creates an expression similar to the following:
*
* (_a = x, {
* get value() { return _a.y; },
* set value(_b) { _a.y = _b; }
* })
*
* For an element access `x[y()]`, this creates an expression similar to the following:
*
* (_a = x, _b = y(), {
* get value() { return _a[_b]; },
* set value(_c) { _a[_b] = _c; }
* })
* @param node The referenced expression.
* @param recordTempVariable A callback used to record temporary variables.
* @param writeOnly A value indicating whether to omit the `value` getter on the ref object.
*/
export function createRef(node: PropertyAccessExpression | ElementAccessExpression | Identifier, recordTempVariable: (node: Identifier) => void, flags?: CreateRefFlags) {
if (!flags) flags = CreateRefFlags.ReadWrite;
const paramName = flags & CreateRefFlags.Writable ? createTempVariable(/*recordTempVariable*/ undefined) : undefined;
let expressions: Expression[];
let getValue: Expression;
let putValue: Expression;
if (isPropertyAccessOrElementAccess(node)) {
expressions = [];
const { reference } = createPropertyReference(node, recordTempVariable, expressions, /*captureArgumentExpression*/ true);
// Copy null propagation flags
if (node.flags & NodeFlags.PropagateNull) {
reference.flags |= NodeFlags.PropagateNull;
}
if (flags & CreateRefFlags.Readable) {
getValue = reference
}
if (flags & CreateRefFlags.Writable) {
putValue = setSourceMapRange(createAssignment(reference, paramName), node);
}
}
else {
if (flags & CreateRefFlags.Readable) {
getValue = node;
}
if (flags & CreateRefFlags.Writable) {
putValue = setSourceMapRange(createAssignment(node, paramName), node);
}
}
export function createRefObject(node: PropertyAccessExpression | ElementAccessExpression | Identifier, recordTempVariable: (temp: Identifier) => void, writeOnly?: boolean) {
const expressions: Expression[] = [];
const paramName = createTempVariable(/*recordTempVariable*/ undefined);
const reference = isPropertyAccessOrElementAccess(node)
? createPropertyReference(node, recordTempVariable, expressions, /*captureIdentifiers*/ false, /*captureArgumentExpression*/ true, /*copyNullPropagation*/ true).reference
: node;
const properties: ObjectLiteralElementLike[] = [];
if (getValue) {
if (!writeOnly) {
properties.push(
setSourceMapRange(
createGetAccessor(
@@ -2471,38 +2441,34 @@ namespace ts {
"value",
/*parameters*/ [],
/*type*/ undefined,
createBlock([setSourceMapRange(createReturn(getValue), node)])
createBlock([setSourceMapRange(createReturn(reference), node)])
),
node
)
);
}
if (putValue) {
properties.push(
setSourceMapRange(
createSetAccessor(
/*decorators*/ undefined,
/*modifiers*/ undefined,
"value",
[createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, paramName)],
createBlock([setSourceMapRange(createStatement(putValue), node)])
),
node
)
);
}
const refExpression = setSourceMapRange(
setCommentRange(
createObjectLiteral(properties, /*multiLine*/ false),
properties.push(
setSourceMapRange(
createSetAccessor(
/*decorators*/ undefined,
/*modifiers*/ undefined,
"value",
[createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, paramName)],
createBlock([setSourceMapRange(createStatement(setSourceMapRange(createAssignment(reference, paramName), node)), node)])
),
node
),
node
)
);
if (expressions) {
expressions.push(refExpression);
return inlineExpressions(expressions);
}
return refExpression;
expressions.push(
setSourceMapRange(
setCommentRange(
createObjectLiteral(properties, /*multiLine*/ false),
node
),
node
)
);
return setTextRange(inlineExpressions(expressions), node);
}
/**
@@ -2518,6 +2484,7 @@ namespace ts {
case SyntaxKind.Identifier:
return captureIdentifiers;
case SyntaxKind.ThisKeyword:
case SyntaxKind.SuperKeyword:
case SyntaxKind.NullKeyword:
case SyntaxKind.TrueKeyword:
case SyntaxKind.FalseKeyword:
@@ -2566,39 +2533,77 @@ namespace ts {
export interface PropertyReference {
baseValue: Expression;
reference: PropertyAccessExpression | ElementAccessExpression;
thisValue?: Expression;
}
/**
* Creates an approximation of an ECMAScript `Reference` specification type.
* @param lhsReference The property or element access expression from which to create the reference.
* @param referenceExpression The expression from which to create the reference.
* @param recordTempVariable A callback used to record new temp variables.
* @param expressions The array of expressions into which capturing assignments should be added.
* @param captureArgumentExpression A value indicating whether to capture the argumentExpression of an ElementAccessExpression.
* @param expressions The array of expressions into which capturing assignments should be
* added. If not supplied, expression capturing occurs in-line in the reference.
* @param captureArgumentExpression A value indicating whether to capture the
* argumentExpression of an ElementAccessExpression.
* @param copyNullPropagation A value indicating whether to preserve null propagation flags.
*/
export function createPropertyReference(referenceExpression: PropertyAccessExpression | ElementAccessExpression, recordTempVariable: (temp: Identifier) => void, expressions: Expression[], captureArgumentExpression?: boolean): PropertyReference {
const baseValue = captureExpressionIfNeeded(referenceExpression.expression, recordTempVariable, expressions);
let reference: PropertyAccessExpression | ElementAccessExpression;
if (isPropertyAccessExpression(referenceExpression)) {
reference = setTextRange(
createPropertyAccess(
baseValue,
referenceExpression.name
),
referenceExpression
);
export function createPropertyReference(node: PropertyAccessExpression | ElementAccessExpression, recordTempVariable: (temp: Identifier) => void, expressions?: Expression[], captureIdentifiers?: boolean, captureArgumentExpression?: boolean, copyNullPropagation?: boolean): PropertyReference {
let baseExpression: Expression = node.expression;
let baseValue = baseExpression;
let reference = node;
let thisValue: Expression;
if (shouldBeCapturedInTempVariable(baseExpression, captureIdentifiers)) {
if (expressions) {
baseValue = baseExpression = captureExpression(baseValue, recordTempVariable, expressions);
}
else {
baseValue = createTempVariable(recordTempVariable);
baseExpression = setTextRange(createAssignment(baseValue, baseExpression), baseExpression);
}
}
if (isPropertyAccessExpression(node)) {
reference = updatePropertyAccess(node, baseExpression, node.name);
}
else {
reference = setTextRange(
createElementAccess(
baseValue,
captureArgumentExpression
? captureExpressionIfNeeded(referenceExpression.argumentExpression, recordTempVariable, expressions)
: referenceExpression.argumentExpression
),
referenceExpression
let argumentExpression = node.argumentExpression;
let argumentValue = argumentExpression;
if (captureArgumentExpression && shouldBeCapturedInTempVariable(argumentExpression, captureIdentifiers)) {
if (expressions) {
argumentValue = argumentExpression = captureExpression(argumentExpression, recordTempVariable, expressions);
}
else {
argumentValue = createTempVariable(recordTempVariable);
argumentExpression = setTextRange(createAssignment(argumentValue, argumentExpression), argumentExpression);
baseExpression = baseValue === baseExpression
? inlineExpressions([argumentExpression, baseValue]) // simple literal or identifier
: inlineExpressions([baseExpression, argumentExpression, baseValue]); // complex expression
}
}
reference = updateElementAccess(
node,
baseExpression,
argumentValue
);
}
return { baseValue, reference };
if (reference === node && !copyNullPropagation && reference.flags & NodeFlags.PropagateNull) {
reference = setTextRange(
isPropertyAccessExpression(reference)
? createPropertyAccess(
reference.expression,
reference.name,
copyNullPropagation ? node.flags & NodeFlags.PropagateNull : 0
)
: createElementAccess(
reference.expression,
reference.argumentExpression,
copyNullPropagation ? node.flags & NodeFlags.PropagateNull : 0
),
node
);
}
if (node.expression.kind === SyntaxKind.SuperKeyword) {
thisValue = createThis();
}
return { baseValue, reference, thisValue };
}
export interface CallBinding {
@@ -2618,9 +2623,16 @@ namespace ts {
const callee = skipOuterExpressions(expression);
let thisArg: Expression;
let target: LeftHandSideExpression;
if (isSuperProperty(callee)) {
thisArg = createThis();
target = callee;
if (isPropertyAccessOrElementAccess(callee)) {
const { baseValue, reference, thisValue } = createPropertyReference(
callee,
recordTempVariable,
/*expressions*/ undefined,
captureIdentifiers,
/*captureArgumentExpression*/ false,
/*copyNullPropagation*/ true);
thisArg = thisValue || baseValue;
target = reference;
}
else if (isSuper(callee)) {
thisArg = createThis();
@@ -2632,54 +2644,6 @@ namespace ts {
thisArg = createVoidZero();
target = parenthesizeForAccess(callee);
}
else if (isPropertyAccessExpression(callee)) {
if (shouldBeCapturedInTempVariable(callee.expression, captureIdentifiers)) {
// for `a.b()` target is `(_a = a).b` and thisArg is `_a`
thisArg = createTempVariable(recordTempVariable);
target = setTextRange(
createPropertyAccess(
setTextRange(
createAssignment(
thisArg,
callee.expression
),
callee.expression
),
callee.name,
callee.flags & NodeFlags.PropagateNull
),
callee
);
}
else {
thisArg = callee.expression;
target = callee;
}
}
else if (isElementAccessExpression(callee)) {
if (shouldBeCapturedInTempVariable(callee.expression, captureIdentifiers)) {
// for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a`
thisArg = createTempVariable(recordTempVariable);
target = setTextRange(
createElementAccess(
setTextRange(
createAssignment(
thisArg,
callee.expression
),
callee.expression
),
callee.argumentExpression,
callee.flags & NodeFlags.PropagateNull
),
callee
);
}
else {
thisArg = callee.expression;
target = callee;
}
}
else {
// for `a()` target is `a` and thisArg is `void 0`
thisArg = createVoidZero();
+87 -4
View File
@@ -79,6 +79,8 @@ namespace ts {
return visitVariableDeclaration(node as VariableDeclaration);
case SyntaxKind.ForOfStatement:
return visitForOfStatement(node as ForOfStatement, /*outermostLabeledStatement*/ undefined);
case SyntaxKind.ForInStatement:
return visitForInStatement(node as ForInStatement, /*outermostLabeledStatement*/ undefined);
case SyntaxKind.ForStatement:
return visitForStatement(node as ForStatement);
case SyntaxKind.VoidExpression:
@@ -160,8 +162,11 @@ namespace ts {
function visitLabeledStatement(node: LabeledStatement) {
if (enclosingFunctionFlags & FunctionFlags.Async && enclosingFunctionFlags & FunctionFlags.Generator) {
const statement = unwrapInnermostStatementOfLabel(node);
if (statement.kind === SyntaxKind.ForOfStatement && (<ForOfStatement>statement).awaitModifier) {
return visitForOfStatement(<ForOfStatement>statement, node);
switch (statement.kind) {
case SyntaxKind.ForOfStatement:
return visitForOfStatement(<ForOfStatement>statement, /*outermostLabeledStatement*/ node);
case SyntaxKind.ForInStatement:
return visitForInStatement(<ForInStatement>statement, /*outermostLabeledStatement*/ node);
}
return restoreEnclosingLabel(visitEachChild(node, visitor, context), node);
}
@@ -262,7 +267,7 @@ namespace ts {
case SyntaxKind.PropertyAccessExpression:
case SyntaxKind.ElementAccessExpression:
if (node.flags & NodeFlags.PropagateNull) {
const ref = createRef(<PropertyAccessExpression | ElementAccessExpression>node, hoistVariableDeclaration, CreateRefFlags.Writable);
const ref = createRefObject(<PropertyAccessExpression | ElementAccessExpression>node, hoistVariableDeclaration, /*writeOnly*/ true);
return setTextRange(createPropertyAccess(ref, "value"), node);
}
@@ -389,6 +394,9 @@ namespace ts {
if (node.initializer.transformFlags & TransformFlags.ContainsObjectRest) {
node = transformForOfStatementWithObjectRest(node);
}
if (isPropertyAccessOrElementAccess(node.initializer) && node.initializer.flags & NodeFlags.PropagateNull) {
node = transformForOfStatementWithNullPropagatingInitializer(node, node.initializer);
}
if (node.awaitModifier) {
return transformForAwaitOfStatement(node, outermostLabeledStatement);
}
@@ -434,6 +442,39 @@ namespace ts {
return node;
}
function transformForOfStatementWithNullPropagatingInitializer(node: ForOfStatement, initializer: PropertyAccessExpression | ElementAccessExpression) {
if (languageVersion >= ScriptTarget.ES2015) {
return updateForOf(
node,
node.awaitModifier,
createPropertyAccess(createRefObject(initializer, hoistVariableDeclaration, /*writeOnly*/ true), "value"),
node.expression,
node.statement
);
}
else {
const temp = createTempVariable(hoistVariableDeclaration);
return updateForOf(
node,
node.awaitModifier,
createVariableDeclarationList([createVariableDeclaration(temp)]),
node.expression,
insertLeadingStatement(
node.statement,
setTextRange(
createStatement(
setTextRange(
createAssignment(initializer, temp),
node.initializer
)
),
node.initializer
)
)
);
}
}
function convertForOfStatementHead(node: ForOfStatement, boundValue: Expression) {
const binding = createForOfBindingStatement(node.initializer, boundValue);
@@ -580,6 +621,48 @@ namespace ts {
);
}
function visitForInStatement(node: ForInStatement, outermostLabeledStatement: LabeledStatement): VisitResult<Statement> {
if (isPropertyAccessOrElementAccess(node.initializer) && node.initializer.flags & NodeFlags.PropagateNull) {
node = transformForInStatementWithNullPropagatingInitializer(node, node.initializer);
}
return restoreEnclosingLabel(visitEachChild(node, visitor, context), outermostLabeledStatement);
}
function transformForInStatementWithNullPropagatingInitializer(node: ForInStatement, initializer: PropertyAccessExpression | ElementAccessExpression) {
if (languageVersion >= ScriptTarget.ES5) {
return updateForIn(
node,
createPropertyAccess(createRefObject(initializer, hoistVariableDeclaration, /*writeOnly*/ true), "value"),
node.expression,
node.statement
);
}
else {
const temp = createTempVariable(hoistVariableDeclaration);
return updateForIn(
node,
createVariableDeclarationList([createVariableDeclaration(temp)]),
node.expression,
insertLeadingStatement(
node.statement,
setTextRange(
createStatement(
setTextRange(
createAssignment(
initializer,
temp
),
node.initializer
)
),
node.initializer
)
)
);
}
}
function visitParameter(node: ParameterDeclaration): ParameterDeclaration {
if (node.transformFlags & TransformFlags.ContainsObjectRest) {
// Binding patterns are converted into a generated name and are
@@ -982,7 +1065,7 @@ namespace ts {
setTextRange(
createConditional(
createEquality(baseValue, createNull()),
createVoidZero(),
node.kind === SyntaxKind.DeleteExpression ? createTrue() : createVoidZero(),
updateNode(
node,
reference
+1 -1
View File
@@ -334,7 +334,7 @@ namespace ts {
_primaryExpressionBrand: any;
_memberExpressionBrand: any;
_leftHandSideExpressionBrand: any;
_incrementExpressionBrand: any;
_updateExpressionBrand: any;
_unaryExpressionBrand: any;
_expressionBrand: any;
constructor(_kind: SyntaxKind.Identifier, pos: number, end: number) {
@@ -0,0 +1,716 @@
//// [tests/cases/conformance/emitter/es2015/safeNavigation/emitter.safeNavigation.es2015.ts] ////
//// [declarations.d.ts]
declare var x: any;
declare var y: any;
declare var f: ({
(): void;
<T>(): void;
new (): any;
new <T>(): any;
}) | undefined;
declare var o: { y: typeof f; }
declare class Base { x(): any; }
declare namespace M {
export class y {}
export class z<T> {}
}
//// [propertyAccessOk.ts]
x.y
x?.y
x?.y.z
x.y?.z
x?.y?.z
//// [elementAccessOk.ts]
x["y"]
x?.["y"]
x?.["y"]["z"]
x["y"]?.["z"]
x?.["y"]?.["z"]
//// [callExpressionOk.ts]
x()
x?.()
x.y?.()
x["y"]?.()
f?.<number>()
o.y?.<number>()
o["y"]?.<number>()
//// [newExpressionOk.ts]
new x()
new x.y?.()
new x["y"]?.()
new f?.<number>()
new o.y?.<number>()
new o["y"]?.<number>()
//// [mixedOk.ts]
x?.y?.["z"]
x?.["y"]?.z
x?.y()
x?.y?.()
o?.y<number>()
o?.y?.<number>()
x?.["z"]()
x?.["z"]?.()
o?.["y"]<number>()
o?.["y"]?.<number>()
//// [mutationOk.ts]
x?.y = 1
x?.y += 1;
x?.y -= 1;
x?.y *= 1;
x?.y /= 1;
x?.y %= 1;
x?.y **= 1;
x?.y |= 1;
x?.y &= 1;
x?.y ^= 1;
x?.y <<= 1;
x?.y >>= 1;
x?.y >>>= 1;
x?.y++;
x?.y--;
++x?.y;
--x?.y;
delete x?.y;
x?.["y"] = 1
x?.["y"] += 1;
x?.["y"] -= 1;
x?.["y"] *= 1;
x?.["y"] /= 1;
x?.["y"] %= 1;
x?.["y"] **= 1;
x?.["y"] |= 1;
x?.["y"] &= 1;
x?.["y"] ^= 1;
x?.["y"] <<= 1;
x?.["y"] >>= 1;
x?.["y"] >>>= 1;
x?.["y"]++;
x?.["y"]--;
++x?.["y"];
--x?.["y"];
delete x?.["y"];
//// [arrayAssignmentPatternOk.ts]
[x?.y] = [1];
[x?.["y"]] = [1];
[...x?.y] = [1];
[...x?.["y"]] = [1];
//// [objectAssignmentPatternOk.ts]
({ a: x?.y } = { a: 1 });
({ a: x?.["y"] } = { a: 1 });
//// [questionDotDigitIsConditionalOk.ts]
x?.3:1;
//// [superPropertyInvocationOk.ts]
// supported for invocation of super property
void class extends Base {
m() {
super.x?.();
super["x"]?.();
}
}
//// [generalParsingOk.ts]
// object literals
// - computed property names
void { [x?.y]: 1 }
void { [x?.["y"]]: 1 }
void { [x?.()]: 1 }
void { [new x?.()]: 1 }
// - property assignments
void { a: x?.y }
void { a: x?.["y"] }
void { a: x?.() }
void { a: new x?.() }
// classes
// - computed property names
// void class { [x?.y] = 1 } // legal parse, but causes a checker error
// void class { [x?.["y"]] = 1 } // legal parse, but causes a checker error
// void class { [x?.()] = 1 } // legal parse, but causes a checker error
// void class { [new f?.()] = 1 } // legal parse, but causes a checker error
void class { [Symbol?.toStringTag] = "" }
// - property declarations
void class { a = x?.y }
void class { a = x?.["y"] }
void class { a = x?.() }
void class { a = new x?.() }
// - heritage clauses
void class extends M?.y {}
void class extends M?.["y"] {}
void class extends M?.z<number> {}
// - class decorators
@x?.y class C1 {}
@x?.["y"] class C2 {}
@x?.() class C3 {}
@new x?.() class C4 {}
// - member decorators
class C5 { @x?.y m() {} }
class C6 { @x?.["y"] m() {} } // allowed as ?.[ is not ambiguous with computed property names
class C7 { @x?.() m() {} }
class C8 { @new x?.() m () {} }
// - parameter decorators
class C9 { m(@x?.y a) {} }
class C10 { m(@x?.["y"] a) {} }
class C11 { m(@x?.() a) {} }
class C12 { m(@new x?.() a) {} }
// functions
// - parameters
void function (a = x?.y) {}
void function (a = x?.["y"]) {}
void function (a = x?.()) {}
void function (a = new x?.()) {}
// - binding elements
// - initializers
void function ({ a = x?.y }) {}
void function ({ a = x?.["y"] }) {}
void function ({ a = x?.() }) {}
void function ({ a = new x?.() }) {}
// - computed properties
void function ({ [x?.y]: a }) {}
void function ({ [x?.["y"]]: a }) {}
void function ({ [x?.()]: a }) {}
void function ({ [new x?.()]: a }) {}
// arrow functions
// - parameters
((a = x?.y) => {});
((a = x?.["y"]) => {});
((a = x?.()) => {});
((a = new x?.()) => {});
// - expression bodies
(() => x?.y);
(() => x?.["y"]);
(() => x?.());
(() => new x?.());
// parenthesis
(x?.y);
// comma
x?.y, f();
f(), x?.y;
// conditional
x?.y ? 0 : 1
0 ? x?.y : 1;
0 ? 1 : x?.y;
// binary
x?.y + 1;
x?.y - 1;
x?.y * 1;
x?.y / 1;
x?.y ** 1;
x?.y % 1;
x?.y ^ 1;
x?.y & 1;
x?.y | 1;
x?.y << 1;
x?.y >> 1;
x?.y >>> 1;
x?.y && 1;
x?.y || 1;
x?.y == 1;
x?.y === 1;
x?.y != 1;
x?.y !== 1;
x?.y < 1;
x?.y <= 1;
x?.y > 1;
x?.y >= 1;
1 + x?.y;
1 - x?.y;
1 * x?.y;
1 / x?.y;
1 ** x?.y;
1 % x?.y;
1 ^ x?.y;
1 & x?.y;
1 | x?.y;
1 << x?.y;
1 >> x?.y;
1 >>> x?.y;
1 && x?.y;
1 || x?.y;
1 == x?.y;
1 === x?.y;
1 != x?.y;
1 !== x?.y;
1 < x?.y;
1 <= x?.y;
1 > x?.y;
1 >= x?.y;
// prefix unary
+x?.y;
-x?.y;
!x?.y;
~x?.y;
// unary
void x?.y;
typeof x?.y;
void function * () { yield x?.y; }
void async function() { await x?.y; }
// notnull
x?.y!.z;
// assertions
<string>x?.y;
x?.y as string;
// array literals
[x?.y];
[, x?.y];
[...x?.y];
// literals
1?.toString(); // no need for `..`
1.?.toString();
.0?.toString();
4e3?.toString();
1.e3?.toString();
""?.toString();
''?.toString();
``?.toString();
/./?.toString();
/./g?.toString();
true?.toString();
false?.toString();
// templates
`${x?.y}`;
// variables
var v = x?.y;
var [v] = x?.y;
var [v = x?.y] = [1];
var {v} = x?.y;
var {v = x?.y} = {v:1};
var {[x?.y]: v} = null;
// if/else if
if (x?.y) {}
if (1) {} else if (x?.y) {}
// switch
switch (x?.y) {}
switch (1) { case x?.y: break; }
// do/while
do {} while (x?.y)
while (x?.y) {}
// for
for (x?.y; x?.y; x?.y);
// for..in
for (x?.y in {});
// for..of
for (x?.y of []);
// enums
enum E {
a = x?.y
}
//// [exportsOk.ts]
export default x?.y;
//// [propertyAccessOk.js]
x.y;
x == null ? void 0 : x.y;
(x == null ? void 0 : x.y).z;
(_a = x.y) == null ? void 0 : _a.z;
(_b = x == null ? void 0 : x.y) == null ? void 0 : _b.z;
var _a, _b;
//// [elementAccessOk.js]
x["y"];
x == null ? void 0 : x["y"];
(x == null ? void 0 : x["y"])["z"];
(_a = x["y"]) == null ? void 0 : _a["z"];
(_b = x == null ? void 0 : x["y"]) == null ? void 0 : _b["z"];
var _a, _b;
//// [callExpressionOk.js]
x();
x == null ? void 0 : x();
(_a = x.y) == null ? void 0 : _a.call(x);
(_b = x["y"]) == null ? void 0 : _b.call(x);
f == null ? void 0 : f();
(_c = o.y) == null ? void 0 : _c.call(o);
(_d = o["y"]) == null ? void 0 : _d.call(o);
var _a, _b, _c, _d;
//// [newExpressionOk.js]
new x();
(_a = x.y) == null ? void 0 : new _a();
(_b = x["y"]) == null ? void 0 : new _b();
f == null ? void 0 : new f();
(_c = o.y) == null ? void 0 : new _c();
(_d = o["y"]) == null ? void 0 : new _d();
var _a, _b, _c, _d;
//// [mixedOk.js]
(_a = x == null ? void 0 : x.y) == null ? void 0 : _a["z"];
(_b = x == null ? void 0 : x["y"]) == null ? void 0 : _b.z;
(x == null ? void 0 : x.y)();
(_c = x == null ? void 0 : x.y) == null ? void 0 : _c.call(x);
(o == null ? void 0 : o.y)();
(_d = o == null ? void 0 : o.y) == null ? void 0 : _d.call(o);
(x == null ? void 0 : x["z"])();
(_e = x == null ? void 0 : x["z"]) == null ? void 0 : _e.call(x);
(o == null ? void 0 : o["y"])();
(_f = o == null ? void 0 : o["y"]) == null ? void 0 : _f.call(o);
var _a, _b, _c, _d, _e, _f;
//// [mutationOk.js]
_a = 1, x == null ? _a : x.y = _a;
_b = 1, x == null ? _b : x.y += _b;
_c = 1, x == null ? _c : x.y -= _c;
_d = 1, x == null ? _d : x.y *= _d;
_e = 1, x == null ? _e : x.y /= _e;
_f = 1, x == null ? _f : x.y %= _f;
_g = 1, x == null ? _g : (_h = x).y = Math.pow(_h.y, _g);
_j = 1, x == null ? _j : x.y |= _j;
_k = 1, x == null ? _k : x.y &= _k;
_l = 1, x == null ? _l : x.y ^= _l;
_m = 1, x == null ? _m : x.y <<= _m;
_o = 1, x == null ? _o : x.y >>= _o;
_p = 1, x == null ? _p : x.y >>>= _p;
x == null ? void 0 : x.y++;
x == null ? void 0 : x.y--;
x == null ? void 0 : ++x.y;
x == null ? void 0 : --x.y;
x == null ? true : delete x.y;
_q = 1, x == null ? _q : x["y"] = _q;
_r = 1, x == null ? _r : x["y"] += _r;
_s = 1, x == null ? _s : x["y"] -= _s;
_t = 1, x == null ? _t : x["y"] *= _t;
_u = 1, x == null ? _u : x["y"] /= _u;
_v = 1, x == null ? _v : x["y"] %= _v;
_w = 1, x == null ? _w : (_x = x)[_y = "y"] = Math.pow(_x[_y], _w);
_z = 1, x == null ? _z : x["y"] |= _z;
_0 = 1, x == null ? _0 : x["y"] &= _0;
_1 = 1, x == null ? _1 : x["y"] ^= _1;
_2 = 1, x == null ? _2 : x["y"] <<= _2;
_3 = 1, x == null ? _3 : x["y"] >>= _3;
_4 = 1, x == null ? _4 : x["y"] >>>= _4;
x == null ? void 0 : x["y"]++;
x == null ? void 0 : x["y"]--;
x == null ? void 0 : ++x["y"];
x == null ? void 0 : --x["y"];
x == null ? true : delete x["y"];
var _a, _b, _c, _d, _e, _f, _g, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _z, _0, _1, _2, _3, _4;
var _h, _x, _y;
//// [arrayAssignmentPatternOk.js]
[{ set value(_a) { x == null ? _a : x.y = _a; } }.value] = [1];
[{ set value(_a) { x == null ? _a : x["y"] = _a; } }.value] = [1];
[...{ set value(_a) { x == null ? _a : x.y = _a; } }.value] = [1];
[...{ set value(_a) { x == null ? _a : x["y"] = _a; } }.value] = [1];
//// [objectAssignmentPatternOk.js]
({ a: { set value(_a) { x == null ? _a : x.y = _a; } }.value } = { a: 1 });
({ a: { set value(_a) { x == null ? _a : x["y"] = _a; } }.value } = { a: 1 });
//// [questionDotDigitIsConditionalOk.js]
x ? .3 : 1;
//// [superPropertyInvocationOk.js]
// supported for invocation of super property
void class extends Base {
m() {
(_a = super.x) == null ? void 0 : _a.call(this);
(_b = super["x"]) == null ? void 0 : _b.call(this);
var _a, _b;
}
};
//// [generalParsingOk.js]
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
// object literals
// - computed property names
void { [x == null ? void 0 : x.y]: 1 };
void { [x == null ? void 0 : x["y"]]: 1 };
void { [x == null ? void 0 : x()]: 1 };
void { [x == null ? void 0 : new x()]: 1 };
// - property assignments
void { a: x == null ? void 0 : x.y };
void { a: x == null ? void 0 : x["y"] };
void { a: x == null ? void 0 : x() };
void { a: x == null ? void 0 : new x() };
// classes
// - computed property names
// void class { [x?.y] = 1 } // legal parse, but causes a checker error
// void class { [x?.["y"]] = 1 } // legal parse, but causes a checker error
// void class { [x?.()] = 1 } // legal parse, but causes a checker error
// void class { [new f?.()] = 1 } // legal parse, but causes a checker error
void class {
constructor() {
this[Symbol == null ? void 0 : Symbol.toStringTag] = "";
}
};
// - property declarations
void class {
constructor() {
this.a = x == null ? void 0 : x.y;
}
};
void class {
constructor() {
this.a = x == null ? void 0 : x["y"];
}
};
void class {
constructor() {
this.a = x == null ? void 0 : x();
}
};
void class {
constructor() {
this.a = x == null ? void 0 : new x();
}
};
// - heritage clauses
void class extends (M == null ? void 0 : M.y) {
};
void class extends (M == null ? void 0 : M["y"]) {
};
void class extends (M == null ? void 0 : M.z) {
};
// - class decorators
let C1 = class C1 {
};
C1 = __decorate([
x == null ? void 0 : x.y
], C1);
let C2 = class C2 {
};
C2 = __decorate([
x == null ? void 0 : x["y"]
], C2);
let C3 = class C3 {
};
C3 = __decorate([
x == null ? void 0 : x()
], C3);
let C4 = class C4 {
};
C4 = __decorate([
x == null ? void 0 : new x()
], C4);
// - member decorators
class C5 {
m() { }
}
__decorate([
x == null ? void 0 : x.y
], C5.prototype, "m", null);
class C6 {
m() { }
} // allowed as ?.[ is not ambiguous with computed property names
__decorate([
x == null ? void 0 : x["y"]
], C6.prototype, "m", null);
class C7 {
m() { }
}
__decorate([
x == null ? void 0 : x()
], C7.prototype, "m", null);
class C8 {
m() { }
}
__decorate([
x == null ? void 0 : new x()
], C8.prototype, "m", null);
// - parameter decorators
class C9 {
m(a) { }
}
__decorate([
__param(0, x == null ? void 0 : x.y)
], C9.prototype, "m", null);
class C10 {
m(a) { }
}
__decorate([
__param(0, x == null ? void 0 : x["y"])
], C10.prototype, "m", null);
class C11 {
m(a) { }
}
__decorate([
__param(0, x == null ? void 0 : x())
], C11.prototype, "m", null);
class C12 {
m(a) { }
}
__decorate([
__param(0, x == null ? void 0 : new x())
], C12.prototype, "m", null);
// functions
// - parameters
void function (a = x == null ? void 0 : x.y) { };
void function (a = x == null ? void 0 : x["y"]) { };
void function (a = x == null ? void 0 : x()) { };
void function (a = x == null ? void 0 : new x()) { };
// - binding elements
// - initializers
void function ({ a = x == null ? void 0 : x.y }) { };
void function ({ a = x == null ? void 0 : x["y"] }) { };
void function ({ a = x == null ? void 0 : x() }) { };
void function ({ a = x == null ? void 0 : new x() }) { };
// - computed properties
void function ({ [x == null ? void 0 : x.y]: a }) { };
void function ({ [x == null ? void 0 : x["y"]]: a }) { };
void function ({ [x == null ? void 0 : x()]: a }) { };
void function ({ [x == null ? void 0 : new x()]: a }) { }((a = x == null ? void 0 : x.y) => { });
((a = x == null ? void 0 : x["y"]) => { });
((a = x == null ? void 0 : x()) => { });
((a = x == null ? void 0 : new x()) => { });
// - expression bodies
(() => x == null ? void 0 : x.y);
(() => x == null ? void 0 : x["y"]);
(() => x == null ? void 0 : x());
(() => x == null ? void 0 : new x());
// parenthesis
(x == null ? void 0 : x.y);
// comma
x == null ? void 0 : x.y, f();
f(), x == null ? void 0 : x.y;
// conditional
x == null ? void 0 : x.y ? 0 : 1;
0 ? x == null ? void 0 : x.y : 1;
0 ? 1 : x == null ? void 0 : x.y;
// binary
(x == null ? void 0 : x.y) + 1;
(x == null ? void 0 : x.y) - 1;
(x == null ? void 0 : x.y) * 1;
(x == null ? void 0 : x.y) / 1;
Math.pow((x == null ? void 0 : x.y), 1);
(x == null ? void 0 : x.y) % 1;
(x == null ? void 0 : x.y) ^ 1;
(x == null ? void 0 : x.y) & 1;
(x == null ? void 0 : x.y) | 1;
(x == null ? void 0 : x.y) << 1;
(x == null ? void 0 : x.y) >> 1;
(x == null ? void 0 : x.y) >>> 1;
(x == null ? void 0 : x.y) && 1;
(x == null ? void 0 : x.y) || 1;
(x == null ? void 0 : x.y) == 1;
(x == null ? void 0 : x.y) === 1;
(x == null ? void 0 : x.y) != 1;
(x == null ? void 0 : x.y) !== 1;
(x == null ? void 0 : x.y) < 1;
(x == null ? void 0 : x.y) <= 1;
(x == null ? void 0 : x.y) > 1;
(x == null ? void 0 : x.y) >= 1;
1 + (x == null ? void 0 : x.y);
1 - (x == null ? void 0 : x.y);
1 * (x == null ? void 0 : x.y);
1 / (x == null ? void 0 : x.y);
Math.pow(1, (x == null ? void 0 : x.y));
1 % (x == null ? void 0 : x.y);
1 ^ (x == null ? void 0 : x.y);
1 & (x == null ? void 0 : x.y);
1 | (x == null ? void 0 : x.y);
1 << (x == null ? void 0 : x.y);
1 >> (x == null ? void 0 : x.y);
1 >>> (x == null ? void 0 : x.y);
1 && (x == null ? void 0 : x.y);
1 || (x == null ? void 0 : x.y);
1 == (x == null ? void 0 : x.y);
1 === (x == null ? void 0 : x.y);
1 != (x == null ? void 0 : x.y);
1 !== (x == null ? void 0 : x.y);
1 < (x == null ? void 0 : x.y);
1 <= (x == null ? void 0 : x.y);
1 > (x == null ? void 0 : x.y);
1 >= (x == null ? void 0 : x.y);
// prefix unary
+(x == null ? void 0 : x.y);
-(x == null ? void 0 : x.y);
!(x == null ? void 0 : x.y);
~(x == null ? void 0 : x.y);
// unary
void (x == null ? void 0 : x.y);
typeof (x == null ? void 0 : x.y);
void function* () { yield x == null ? void 0 : x.y; };
void function () {
return __awaiter(this, void 0, void 0, function* () { yield (x == null ? void 0 : x.y); });
};
// notnull
(x == null ? void 0 : x.y).z;
// assertions
x == null ? void 0 : x.y;
x == null ? void 0 : x.y;
// array literals
[x == null ? void 0 : x.y];
[, x == null ? void 0 : x.y];
[...x == null ? void 0 : x.y];
// literals
((_a = 1) == null ? void 0 : _a.toString)(); // no need for `..`
((_b = 1.) == null ? void 0 : _b.toString)();
((_c = .0) == null ? void 0 : _c.toString)();
((_d = 4e3) == null ? void 0 : _d.toString)();
((_e = 1.e3) == null ? void 0 : _e.toString)();
((_f = "") == null ? void 0 : _f.toString)();
((_g = '') == null ? void 0 : _g.toString)();
((_h = ``) == null ? void 0 : _h.toString)();
((_j = /./) == null ? void 0 : _j.toString)();
((_k = /./g) == null ? void 0 : _k.toString)();
((_l = true) == null ? void 0 : _l.toString)();
((_m = false) == null ? void 0 : _m.toString)();
// templates
`${x == null ? void 0 : x.y}`;
// variables
var v = x == null ? void 0 : x.y;
var [v] = x == null ? void 0 : x.y;
var [v = x == null ? void 0 : x.y] = [1];
var { v } = x == null ? void 0 : x.y;
var { v = x == null ? void 0 : x.y } = { v: 1 };
var { [x == null ? void 0 : x.y]: v } = null;
// if/else if
if (x == null ? void 0 : x.y) { }
if (1) { }
else if (x == null ? void 0 : x.y) { }
// switch
switch (x == null ? void 0 : x.y) {
}
switch (1) {
case x == null ? void 0 : x.y: break;
}
// do/while
do { } while (x == null ? void 0 : x.y);
while (x == null ? void 0 : x.y) { }
// for
for (x == null ? void 0 : x.y; x == null ? void 0 : x.y; x == null ? void 0 : x.y)
;
// for..in
for ({ set value(_a) { x == null ? _a : x.y = _a; } }.value in {})
;
// for..of
for ({ set value(_a) { x == null ? _a : x.y = _a; } }.value of [])
;
// enums
var E;
(function (E) {
E[E["a"] = x == null ? void 0 : x.y] = "a";
})(E || (E = {}));
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
//// [exportsOk.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = x == null ? void 0 : x.y;
@@ -0,0 +1,862 @@
=== tests/cases/conformance/emitter/es2015/safeNavigation/declarations.d.ts ===
declare var x: any;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
declare var y: any;
>y : Symbol(y, Decl(declarations.d.ts, 1, 11))
declare var f: ({
>f : Symbol(f, Decl(declarations.d.ts, 2, 11))
(): void;
<T>(): void;
>T : Symbol(T, Decl(declarations.d.ts, 4, 5))
new (): any;
new <T>(): any;
>T : Symbol(T, Decl(declarations.d.ts, 6, 9))
}) | undefined;
declare var o: { y: typeof f; }
>o : Symbol(o, Decl(declarations.d.ts, 8, 11))
>y : Symbol(y, Decl(declarations.d.ts, 8, 16))
>f : Symbol(f, Decl(declarations.d.ts, 2, 11))
declare class Base { x(): any; }
>Base : Symbol(Base, Decl(declarations.d.ts, 8, 31))
>x : Symbol(Base.x, Decl(declarations.d.ts, 9, 20))
declare namespace M {
>M : Symbol(M, Decl(declarations.d.ts, 9, 32))
export class y {}
>y : Symbol(y, Decl(declarations.d.ts, 10, 21))
export class z<T> {}
>z : Symbol(z, Decl(declarations.d.ts, 11, 21))
>T : Symbol(T, Decl(declarations.d.ts, 12, 19))
}
=== tests/cases/conformance/emitter/es2015/safeNavigation/propertyAccessOk.ts ===
x.y
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y.z
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x.y?.z
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y?.z
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
=== tests/cases/conformance/emitter/es2015/safeNavigation/elementAccessOk.ts ===
x["y"]
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"]
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"]["z"]
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x["y"]?.["z"]
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"]?.["z"]
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
=== tests/cases/conformance/emitter/es2015/safeNavigation/callExpressionOk.ts ===
x()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x.y?.()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x["y"]?.()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
f?.<number>()
>f : Symbol(f, Decl(declarations.d.ts, 2, 11))
o.y?.<number>()
>o.y : Symbol(y, Decl(declarations.d.ts, 8, 16))
>o : Symbol(o, Decl(declarations.d.ts, 8, 11))
>y : Symbol(y, Decl(declarations.d.ts, 8, 16))
o["y"]?.<number>()
>o : Symbol(o, Decl(declarations.d.ts, 8, 11))
>"y" : Symbol(y, Decl(declarations.d.ts, 8, 16))
=== tests/cases/conformance/emitter/es2015/safeNavigation/newExpressionOk.ts ===
new x()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
new x.y?.()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
new x["y"]?.()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
new f?.<number>()
>f : Symbol(f, Decl(declarations.d.ts, 2, 11))
new o.y?.<number>()
>o.y : Symbol(y, Decl(declarations.d.ts, 8, 16))
>o : Symbol(o, Decl(declarations.d.ts, 8, 11))
>y : Symbol(y, Decl(declarations.d.ts, 8, 16))
new o["y"]?.<number>()
>o : Symbol(o, Decl(declarations.d.ts, 8, 11))
>"y" : Symbol(y, Decl(declarations.d.ts, 8, 16))
=== tests/cases/conformance/emitter/es2015/safeNavigation/mixedOk.ts ===
x?.y?.["z"]
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"]?.z
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y?.()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
o?.y<number>()
>o?.y : Symbol(y, Decl(declarations.d.ts, 8, 16))
>o : Symbol(o, Decl(declarations.d.ts, 8, 11))
>y : Symbol(y, Decl(declarations.d.ts, 8, 16))
o?.y?.<number>()
>o?.y : Symbol(y, Decl(declarations.d.ts, 8, 16))
>o : Symbol(o, Decl(declarations.d.ts, 8, 11))
>y : Symbol(y, Decl(declarations.d.ts, 8, 16))
x?.["z"]()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["z"]?.()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
o?.["y"]<number>()
>o : Symbol(o, Decl(declarations.d.ts, 8, 11))
>"y" : Symbol(y, Decl(declarations.d.ts, 8, 16))
o?.["y"]?.<number>()
>o : Symbol(o, Decl(declarations.d.ts, 8, 11))
>"y" : Symbol(y, Decl(declarations.d.ts, 8, 16))
=== tests/cases/conformance/emitter/es2015/safeNavigation/mutationOk.ts ===
x?.y = 1
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y += 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y -= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y *= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y /= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y %= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y **= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y |= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y &= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y ^= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y <<= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y >>= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y >>>= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y++;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y--;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
++x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
--x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
delete x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] = 1
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] += 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] -= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] *= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] /= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] %= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] **= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] |= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] &= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] ^= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] <<= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] >>= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] >>>= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"]++;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"]--;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
++x?.["y"];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
--x?.["y"];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
delete x?.["y"];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
=== tests/cases/conformance/emitter/es2015/safeNavigation/arrayAssignmentPatternOk.ts ===
[x?.y] = [1];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
[x?.["y"]] = [1];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
[...x?.y] = [1];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
[...x?.["y"]] = [1];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
=== tests/cases/conformance/emitter/es2015/safeNavigation/objectAssignmentPatternOk.ts ===
({ a: x?.y } = { a: 1 });
>a : Symbol(a, Decl(objectAssignmentPatternOk.ts, 0, 2))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(objectAssignmentPatternOk.ts, 0, 16))
({ a: x?.["y"] } = { a: 1 });
>a : Symbol(a, Decl(objectAssignmentPatternOk.ts, 1, 2))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(objectAssignmentPatternOk.ts, 1, 20))
=== tests/cases/conformance/emitter/es2015/safeNavigation/questionDotDigitIsConditionalOk.ts ===
x?.3:1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
=== tests/cases/conformance/emitter/es2015/safeNavigation/superPropertyInvocationOk.ts ===
// supported for invocation of super property
void class extends Base {
>Base : Symbol(Base, Decl(declarations.d.ts, 8, 31))
m() {
>m : Symbol((Anonymous class).m, Decl(superPropertyInvocationOk.ts, 1, 25))
super.x?.();
>super.x : Symbol(Base.x, Decl(declarations.d.ts, 9, 20))
>super : Symbol(Base, Decl(declarations.d.ts, 8, 31))
>x : Symbol(Base.x, Decl(declarations.d.ts, 9, 20))
super["x"]?.();
>super : Symbol(Base, Decl(declarations.d.ts, 8, 31))
>"x" : Symbol(Base.x, Decl(declarations.d.ts, 9, 20))
}
}
=== tests/cases/conformance/emitter/es2015/safeNavigation/generalParsingOk.ts ===
// object literals
// - computed property names
void { [x?.y]: 1 }
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void { [x?.["y"]]: 1 }
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void { [x?.()]: 1 }
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void { [new x?.()]: 1 }
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// - property assignments
void { a: x?.y }
>a : Symbol(a, Decl(generalParsingOk.ts, 7, 6))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void { a: x?.["y"] }
>a : Symbol(a, Decl(generalParsingOk.ts, 8, 6))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void { a: x?.() }
>a : Symbol(a, Decl(generalParsingOk.ts, 9, 6))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void { a: new x?.() }
>a : Symbol(a, Decl(generalParsingOk.ts, 10, 6))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// classes
// - computed property names
// void class { [x?.y] = 1 } // legal parse, but causes a checker error
// void class { [x?.["y"]] = 1 } // legal parse, but causes a checker error
// void class { [x?.()] = 1 } // legal parse, but causes a checker error
// void class { [new f?.()] = 1 } // legal parse, but causes a checker error
void class { [Symbol?.toStringTag] = "" }
>Symbol?.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --))
>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
// - property declarations
void class { a = x?.y }
>a : Symbol((Anonymous class).a, Decl(generalParsingOk.ts, 20, 12))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void class { a = x?.["y"] }
>a : Symbol((Anonymous class).a, Decl(generalParsingOk.ts, 21, 12))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void class { a = x?.() }
>a : Symbol((Anonymous class).a, Decl(generalParsingOk.ts, 22, 12))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void class { a = new x?.() }
>a : Symbol((Anonymous class).a, Decl(generalParsingOk.ts, 23, 12))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// - heritage clauses
void class extends M?.y {}
>M?.y : Symbol(M.y, Decl(declarations.d.ts, 10, 21))
>M : Symbol(M, Decl(declarations.d.ts, 9, 32))
>y : Symbol(M.y, Decl(declarations.d.ts, 10, 21))
void class extends M?.["y"] {}
>M : Symbol(M, Decl(declarations.d.ts, 9, 32))
>"y" : Symbol(M.y, Decl(declarations.d.ts, 10, 21))
void class extends M?.z<number> {}
>M?.z : Symbol(M.z, Decl(declarations.d.ts, 11, 21))
>M : Symbol(M, Decl(declarations.d.ts, 9, 32))
>z : Symbol(M.z, Decl(declarations.d.ts, 11, 21))
// - class decorators
@x?.y class C1 {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>C1 : Symbol(C1, Decl(generalParsingOk.ts, 27, 34))
@x?.["y"] class C2 {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>C2 : Symbol(C2, Decl(generalParsingOk.ts, 29, 17))
@x?.() class C3 {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>C3 : Symbol(C3, Decl(generalParsingOk.ts, 30, 21))
@new x?.() class C4 {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>C4 : Symbol(C4, Decl(generalParsingOk.ts, 31, 18))
// - member decorators
class C5 { @x?.y m() {} }
>C5 : Symbol(C5, Decl(generalParsingOk.ts, 32, 22))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>m : Symbol(C5.m, Decl(generalParsingOk.ts, 34, 10))
class C6 { @x?.["y"] m() {} } // allowed as ?.[ is not ambiguous with computed property names
>C6 : Symbol(C6, Decl(generalParsingOk.ts, 34, 25))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>m : Symbol(C6.m, Decl(generalParsingOk.ts, 35, 10))
class C7 { @x?.() m() {} }
>C7 : Symbol(C7, Decl(generalParsingOk.ts, 35, 29))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>m : Symbol(C7.m, Decl(generalParsingOk.ts, 36, 10))
class C8 { @new x?.() m () {} }
>C8 : Symbol(C8, Decl(generalParsingOk.ts, 36, 26))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>m : Symbol(C8.m, Decl(generalParsingOk.ts, 37, 10))
// - parameter decorators
class C9 { m(@x?.y a) {} }
>C9 : Symbol(C9, Decl(generalParsingOk.ts, 37, 31))
>m : Symbol(C9.m, Decl(generalParsingOk.ts, 39, 10))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(generalParsingOk.ts, 39, 13))
class C10 { m(@x?.["y"] a) {} }
>C10 : Symbol(C10, Decl(generalParsingOk.ts, 39, 26))
>m : Symbol(C10.m, Decl(generalParsingOk.ts, 40, 11))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(generalParsingOk.ts, 40, 14))
class C11 { m(@x?.() a) {} }
>C11 : Symbol(C11, Decl(generalParsingOk.ts, 40, 31))
>m : Symbol(C11.m, Decl(generalParsingOk.ts, 41, 11))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(generalParsingOk.ts, 41, 14))
class C12 { m(@new x?.() a) {} }
>C12 : Symbol(C12, Decl(generalParsingOk.ts, 41, 28))
>m : Symbol(C12.m, Decl(generalParsingOk.ts, 42, 11))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(generalParsingOk.ts, 42, 14))
// functions
// - parameters
void function (a = x?.y) {}
>a : Symbol(a, Decl(generalParsingOk.ts, 46, 15))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void function (a = x?.["y"]) {}
>a : Symbol(a, Decl(generalParsingOk.ts, 47, 15))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void function (a = x?.()) {}
>a : Symbol(a, Decl(generalParsingOk.ts, 48, 15))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void function (a = new x?.()) {}
>a : Symbol(a, Decl(generalParsingOk.ts, 49, 15))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// - binding elements
// - initializers
void function ({ a = x?.y }) {}
>a : Symbol(a, Decl(generalParsingOk.ts, 52, 16))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void function ({ a = x?.["y"] }) {}
>a : Symbol(a, Decl(generalParsingOk.ts, 53, 16))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void function ({ a = x?.() }) {}
>a : Symbol(a, Decl(generalParsingOk.ts, 54, 16))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void function ({ a = new x?.() }) {}
>a : Symbol(a, Decl(generalParsingOk.ts, 55, 16))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// - computed properties
void function ({ [x?.y]: a }) {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(generalParsingOk.ts, 57, 16))
void function ({ [x?.["y"]]: a }) {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(generalParsingOk.ts, 58, 16))
void function ({ [x?.()]: a }) {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(generalParsingOk.ts, 59, 16))
void function ({ [new x?.()]: a }) {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(generalParsingOk.ts, 60, 16))
// arrow functions
// - parameters
((a = x?.y) => {});
>a : Symbol(a, Decl(generalParsingOk.ts, 64, 2))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
((a = x?.["y"]) => {});
>a : Symbol(a, Decl(generalParsingOk.ts, 65, 2))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
((a = x?.()) => {});
>a : Symbol(a, Decl(generalParsingOk.ts, 66, 2))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
((a = new x?.()) => {});
>a : Symbol(a, Decl(generalParsingOk.ts, 67, 2))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// - expression bodies
(() => x?.y);
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
(() => x?.["y"]);
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
(() => x?.());
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
(() => new x?.());
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// parenthesis
(x?.y);
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// comma
x?.y, f();
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>f : Symbol(f, Decl(declarations.d.ts, 2, 11))
f(), x?.y;
>f : Symbol(f, Decl(declarations.d.ts, 2, 11))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// conditional
x?.y ? 0 : 1
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
0 ? x?.y : 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
0 ? 1 : x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// binary
x?.y + 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y - 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y * 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y / 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y ** 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y % 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y ^ 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y & 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y | 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y << 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y >> 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y >>> 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y && 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y || 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y == 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y === 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y != 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y !== 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y < 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y <= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y > 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y >= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 + x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 - x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 * x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 / x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 ** x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 % x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 ^ x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 & x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 | x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 << x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 >> x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 >>> x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 && x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 || x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 == x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 === x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 != x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 !== x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 < x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 <= x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 > x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 >= x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// prefix unary
+x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
-x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
!x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
~x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// unary
void x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
typeof x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void function * () { yield x?.y; }
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void async function() { await x?.y; }
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// notnull
x?.y!.z;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// assertions
<string>x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y as string;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// array literals
[x?.y];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
[, x?.y];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
[...x?.y];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// literals
1?.toString(); // no need for `..`
>1?.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
1.?.toString();
>1.?.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
.0?.toString();
>.0?.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
4e3?.toString();
>4e3?.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
1.e3?.toString();
>1.e3?.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
""?.toString();
>""?.toString : Symbol(String.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(String.toString, Decl(lib.es5.d.ts, --, --))
''?.toString();
>''?.toString : Symbol(String.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(String.toString, Decl(lib.es5.d.ts, --, --))
``?.toString();
>``?.toString : Symbol(String.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(String.toString, Decl(lib.es5.d.ts, --, --))
/./?.toString();
>/./?.toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
/./g?.toString();
>/./g?.toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
true?.toString();
>true?.toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
false?.toString();
>false?.toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
// templates
`${x?.y}`;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// variables
var v = x?.y;
>v : Symbol(v, Decl(generalParsingOk.ts, 174, 3), Decl(generalParsingOk.ts, 175, 5), Decl(generalParsingOk.ts, 176, 5), Decl(generalParsingOk.ts, 177, 5), Decl(generalParsingOk.ts, 178, 5), Decl(generalParsingOk.ts, 179, 5))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
var [v] = x?.y;
>v : Symbol(v, Decl(generalParsingOk.ts, 174, 3), Decl(generalParsingOk.ts, 175, 5), Decl(generalParsingOk.ts, 176, 5), Decl(generalParsingOk.ts, 177, 5), Decl(generalParsingOk.ts, 178, 5), Decl(generalParsingOk.ts, 179, 5))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
var [v = x?.y] = [1];
>v : Symbol(v, Decl(generalParsingOk.ts, 174, 3), Decl(generalParsingOk.ts, 175, 5), Decl(generalParsingOk.ts, 176, 5), Decl(generalParsingOk.ts, 177, 5), Decl(generalParsingOk.ts, 178, 5), Decl(generalParsingOk.ts, 179, 5))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
var {v} = x?.y;
>v : Symbol(v, Decl(generalParsingOk.ts, 174, 3), Decl(generalParsingOk.ts, 175, 5), Decl(generalParsingOk.ts, 176, 5), Decl(generalParsingOk.ts, 177, 5), Decl(generalParsingOk.ts, 178, 5), Decl(generalParsingOk.ts, 179, 5))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
var {v = x?.y} = {v:1};
>v : Symbol(v, Decl(generalParsingOk.ts, 174, 3), Decl(generalParsingOk.ts, 175, 5), Decl(generalParsingOk.ts, 176, 5), Decl(generalParsingOk.ts, 177, 5), Decl(generalParsingOk.ts, 178, 5), Decl(generalParsingOk.ts, 179, 5))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>v : Symbol(v, Decl(generalParsingOk.ts, 178, 18))
var {[x?.y]: v} = null;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>v : Symbol(v, Decl(generalParsingOk.ts, 174, 3), Decl(generalParsingOk.ts, 175, 5), Decl(generalParsingOk.ts, 176, 5), Decl(generalParsingOk.ts, 177, 5), Decl(generalParsingOk.ts, 178, 5), Decl(generalParsingOk.ts, 179, 5))
// if/else if
if (x?.y) {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
if (1) {} else if (x?.y) {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// switch
switch (x?.y) {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
switch (1) { case x?.y: break; }
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// do/while
do {} while (x?.y)
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
while (x?.y) {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// for
for (x?.y; x?.y; x?.y);
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// for..in
for (x?.y in {});
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// for..of
for (x?.y of []);
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// enums
enum E {
>E : Symbol(E, Decl(generalParsingOk.ts, 200, 17))
a = x?.y
>a : Symbol(E.a, Decl(generalParsingOk.ts, 203, 8))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
}
=== tests/cases/conformance/emitter/es2015/safeNavigation/exportsOk.ts ===
export default x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,876 @@
//// [tests/cases/conformance/emitter/es3/safeNavigation/emitter.safeNavigation.es3.ts] ////
//// [declarations.d.ts]
declare var x: any;
declare var y: any;
declare var f: ({
(): void;
<T>(): void;
new (): any;
new <T>(): any;
}) | undefined;
declare var o: { y: typeof f; }
declare class Base { x(): any; }
declare namespace M {
export class y {}
export class z<T> {}
}
//// [propertyAccessOk.ts]
x.y
x?.y
x?.y.z
x.y?.z
x?.y?.z
//// [elementAccessOk.ts]
x["y"]
x?.["y"]
x?.["y"]["z"]
x["y"]?.["z"]
x?.["y"]?.["z"]
//// [callExpressionOk.ts]
x()
x?.()
x.y?.()
x["y"]?.()
f?.<number>()
o.y?.<number>()
o["y"]?.<number>()
//// [newExpressionOk.ts]
new x()
new x.y?.()
new x["y"]?.()
new f?.<number>()
new o.y?.<number>()
new o["y"]?.<number>()
//// [mixedOk.ts]
x?.y?.["z"]
x?.["y"]?.z
x?.y()
x?.y?.()
o?.y<number>()
o?.y?.<number>()
x?.["z"]()
x?.["z"]?.()
o?.["y"]<number>()
o?.["y"]?.<number>()
//// [mutationOk.ts]
x?.y = 1
x?.y += 1;
x?.y -= 1;
x?.y *= 1;
x?.y /= 1;
x?.y %= 1;
x?.y **= 1;
x?.y |= 1;
x?.y &= 1;
x?.y ^= 1;
x?.y <<= 1;
x?.y >>= 1;
x?.y >>>= 1;
x?.y++;
x?.y--;
++x?.y;
--x?.y;
delete x?.y;
x?.["y"] = 1
x?.["y"] += 1;
x?.["y"] -= 1;
x?.["y"] *= 1;
x?.["y"] /= 1;
x?.["y"] %= 1;
x?.["y"] **= 1;
x?.["y"] |= 1;
x?.["y"] &= 1;
x?.["y"] ^= 1;
x?.["y"] <<= 1;
x?.["y"] >>= 1;
x?.["y"] >>>= 1;
x?.["y"]++;
x?.["y"]--;
++x?.["y"];
--x?.["y"];
delete x?.["y"];
//// [arrayAssignmentPatternOk.ts]
[x?.y] = [1];
[x?.["y"]] = [1];
[...x?.y] = [1];
[...x?.["y"]] = [1];
//// [objectAssignmentPatternOk.ts]
({ a: x?.y } = { a: 1 });
({ a: x?.["y"] } = { a: 1 });
//// [questionDotDigitIsConditionalOk.ts]
x?.3:1;
//// [superPropertyInvocationOk.ts]
// supported for invocation of super property
void class extends Base {
m() {
super.x?.();
}
}
//// [generalParsingOk.ts]
// object literals
// - computed property names
void { [x?.y]: 1 }
void { [x?.["y"]]: 1 }
void { [x?.()]: 1 }
void { [new x?.()]: 1 }
// - property assignments
void { a: x?.y }
void { a: x?.["y"] }
void { a: x?.() }
void { a: new x?.() }
// classes
// - computed property names
// void class { [x?.y] = 1 } // legal parse, but causes a checker error
// void class { [x?.["y"]] = 1 } // legal parse, but causes a checker error
// void class { [x?.()] = 1 } // legal parse, but causes a checker error
// void class { [new f?.()] = 1 } // legal parse, but causes a checker error
void class { [Symbol?.toStringTag] = "" }
// - property declarations
void class { a = x?.y }
void class { a = x?.["y"] }
void class { a = x?.() }
void class { a = new x?.() }
// - heritage clauses
void class extends M?.y {}
void class extends M?.["y"] {}
void class extends M?.z<number> {}
// - class decorators
@x?.y class C1 {}
@x?.["y"] class C2 {}
@x?.() class C3 {}
@new x?.() class C4 {}
// - member decorators
class C5 { @x?.y m() {} }
class C6 { @x?.["y"] m() {} } // allowed as ?.[ is not ambiguous with computed property names
class C7 { @x?.() m() {} }
class C8 { @new x?.() m () {} }
// - parameter decorators
class C9 { m(@x?.y a) {} }
class C10 { m(@x?.["y"] a) {} }
class C11 { m(@x?.() a) {} }
class C12 { m(@new x?.() a) {} }
// functions
// - parameters
void function (a = x?.y) {}
void function (a = x?.["y"]) {}
void function (a = x?.()) {}
void function (a = new x?.()) {}
// - binding elements
// - initializers
void function ({ a = x?.y }) {}
void function ({ a = x?.["y"] }) {}
void function ({ a = x?.() }) {}
void function ({ a = new x?.() }) {}
// - computed properties
void function ({ [x?.y]: a }) {}
void function ({ [x?.["y"]]: a }) {}
void function ({ [x?.()]: a }) {}
void function ({ [new x?.()]: a }) {}
// arrow functions
// - parameters
((a = x?.y) => {});
((a = x?.["y"]) => {});
((a = x?.()) => {});
((a = new x?.()) => {});
// - expression bodies
(() => x?.y);
(() => x?.["y"]);
(() => x?.());
(() => new x?.());
// parenthesis
(x?.y);
// comma
x?.y, f();
f(), x?.y;
// conditional
x?.y ? 0 : 1
0 ? x?.y : 1;
0 ? 1 : x?.y;
// binary
x?.y + 1;
x?.y - 1;
x?.y * 1;
x?.y / 1;
x?.y ** 1;
x?.y % 1;
x?.y ^ 1;
x?.y & 1;
x?.y | 1;
x?.y << 1;
x?.y >> 1;
x?.y >>> 1;
x?.y && 1;
x?.y || 1;
x?.y == 1;
x?.y === 1;
x?.y != 1;
x?.y !== 1;
x?.y < 1;
x?.y <= 1;
x?.y > 1;
x?.y >= 1;
1 + x?.y;
1 - x?.y;
1 * x?.y;
1 / x?.y;
1 ** x?.y;
1 % x?.y;
1 ^ x?.y;
1 & x?.y;
1 | x?.y;
1 << x?.y;
1 >> x?.y;
1 >>> x?.y;
1 && x?.y;
1 || x?.y;
1 == x?.y;
1 === x?.y;
1 != x?.y;
1 !== x?.y;
1 < x?.y;
1 <= x?.y;
1 > x?.y;
1 >= x?.y;
// prefix unary
+x?.y;
-x?.y;
!x?.y;
~x?.y;
// unary
void x?.y;
typeof x?.y;
void function * () { yield x?.y; }
void async function() { await x?.y; }
// notnull
x?.y!.z;
// assertions
<string>x?.y;
x?.y as string;
// array literals
[x?.y];
[, x?.y];
[...x?.y];
// literals
1?.toString(); // no need for `..`
1.?.toString();
.0?.toString();
4e3?.toString();
1.e3?.toString();
""?.toString();
''?.toString();
``?.toString();
/./?.toString();
/./g?.toString();
true?.toString();
false?.toString();
// templates
`${x?.y}`;
// variables
var v = x?.y;
var [v] = x?.y;
var [v = x?.y] = [1];
var {v} = x?.y;
var {v = x?.y} = {v:1};
var {[x?.y]: v} = null;
// if/else if
if (x?.y) {}
if (1) {} else if (x?.y) {}
// switch
switch (x?.y) {}
switch (1) { case x?.y: break; }
// do/while
do {} while (x?.y)
while (x?.y) {}
// for
for (x?.y; x?.y; x?.y);
// for..in
for (x?.y in {});
// for..of
for (x?.y of []);
// enums
enum E {
a = x?.y
}
//// [exportsOk.ts]
export default x?.y;
//// [propertyAccessOk.js]
x.y;
x == null ? void 0 : x.y;
(x == null ? void 0 : x.y).z;
(_a = x.y) == null ? void 0 : _a.z;
(_b = x == null ? void 0 : x.y) == null ? void 0 : _b.z;
var _a, _b;
//// [elementAccessOk.js]
x["y"];
x == null ? void 0 : x["y"];
(x == null ? void 0 : x["y"])["z"];
(_a = x["y"]) == null ? void 0 : _a["z"];
(_b = x == null ? void 0 : x["y"]) == null ? void 0 : _b["z"];
var _a, _b;
//// [callExpressionOk.js]
x();
x == null ? void 0 : x();
(_a = x.y) == null ? void 0 : _a.call(x);
(_b = x["y"]) == null ? void 0 : _b.call(x);
f == null ? void 0 : f();
(_c = o.y) == null ? void 0 : _c.call(o);
(_d = o["y"]) == null ? void 0 : _d.call(o);
var _a, _b, _c, _d;
//// [newExpressionOk.js]
new x();
(_a = x.y) == null ? void 0 : new _a();
(_b = x["y"]) == null ? void 0 : new _b();
f == null ? void 0 : new f();
(_c = o.y) == null ? void 0 : new _c();
(_d = o["y"]) == null ? void 0 : new _d();
var _a, _b, _c, _d;
//// [mixedOk.js]
(_a = x == null ? void 0 : x.y) == null ? void 0 : _a["z"];
(_b = x == null ? void 0 : x["y"]) == null ? void 0 : _b.z;
(x == null ? void 0 : x.y)();
(_c = x == null ? void 0 : x.y) == null ? void 0 : _c.call(x);
(o == null ? void 0 : o.y)();
(_d = o == null ? void 0 : o.y) == null ? void 0 : _d.call(o);
(x == null ? void 0 : x["z"])();
(_e = x == null ? void 0 : x["z"]) == null ? void 0 : _e.call(x);
(o == null ? void 0 : o["y"])();
(_f = o == null ? void 0 : o["y"]) == null ? void 0 : _f.call(o);
var _a, _b, _c, _d, _e, _f;
//// [mutationOk.js]
_a = 1, x == null ? _a : x.y = _a;
_b = 1, x == null ? _b : x.y += _b;
_c = 1, x == null ? _c : x.y -= _c;
_d = 1, x == null ? _d : x.y *= _d;
_e = 1, x == null ? _e : x.y /= _e;
_f = 1, x == null ? _f : x.y %= _f;
_g = 1, x == null ? _g : (_h = x).y = Math.pow(_h.y, _g);
_j = 1, x == null ? _j : x.y |= _j;
_k = 1, x == null ? _k : x.y &= _k;
_l = 1, x == null ? _l : x.y ^= _l;
_m = 1, x == null ? _m : x.y <<= _m;
_o = 1, x == null ? _o : x.y >>= _o;
_p = 1, x == null ? _p : x.y >>>= _p;
x == null ? void 0 : x.y++;
x == null ? void 0 : x.y--;
x == null ? void 0 : ++x.y;
x == null ? void 0 : --x.y;
x == null ? true : delete x.y;
_q = 1, x == null ? _q : x["y"] = _q;
_r = 1, x == null ? _r : x["y"] += _r;
_s = 1, x == null ? _s : x["y"] -= _s;
_t = 1, x == null ? _t : x["y"] *= _t;
_u = 1, x == null ? _u : x["y"] /= _u;
_v = 1, x == null ? _v : x["y"] %= _v;
_w = 1, x == null ? _w : (_x = x)[_y = "y"] = Math.pow(_x[_y], _w);
_z = 1, x == null ? _z : x["y"] |= _z;
_0 = 1, x == null ? _0 : x["y"] &= _0;
_1 = 1, x == null ? _1 : x["y"] ^= _1;
_2 = 1, x == null ? _2 : x["y"] <<= _2;
_3 = 1, x == null ? _3 : x["y"] >>= _3;
_4 = 1, x == null ? _4 : x["y"] >>>= _4;
x == null ? void 0 : x["y"]++;
x == null ? void 0 : x["y"]--;
x == null ? void 0 : ++x["y"];
x == null ? void 0 : --x["y"];
x == null ? true : delete x["y"];
var _a, _b, _c, _d, _e, _f, _g, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _z, _0, _1, _2, _3, _4;
var _h, _x, _y;
//// [arrayAssignmentPatternOk.js]
_a = [1], (x == null ? void 0 : x.y = _a[0], _a);
_b = [1], (x == null ? void 0 : x["y"] = _b[0], _b);
_c = [1], (x == null ? void 0 : x.y = _c.slice(0), _c);
_d = [1], (x == null ? void 0 : x["y"] = _d.slice(0), _d);
var _a, _b, _c, _d;
//// [objectAssignmentPatternOk.js]
(_a = { a: 1 }, (x == null ? void 0 : x.y = _a.a, _a));
(_b = { a: 1 }, (x == null ? void 0 : x["y"] = _b.a, _b));
var _a, _b;
//// [questionDotDigitIsConditionalOk.js]
x ? .3 : 1;
//// [superPropertyInvocationOk.js]
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
// supported for invocation of super property
void (function (_super) {
__extends(class_1, _super);
function class_1() {
return _super !== null && _super.apply(this, arguments) || this;
}
class_1.prototype.m = function () {
(_a = _super.prototype.x) == null ? void 0 : _a.call(this);
var _a;
};
return class_1;
}(Base));
//// [generalParsingOk.js]
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
// object literals
// - computed property names
void (_a = {}, _a[x == null ? void 0 : x.y] = 1, _a);
void (_b = {}, _b[x == null ? void 0 : x["y"]] = 1, _b);
void (_c = {}, _c[x == null ? void 0 : x()] = 1, _c);
void (_d = {}, _d[x == null ? void 0 : new x()] = 1, _d);
// - property assignments
void { a: x == null ? void 0 : x.y };
void { a: x == null ? void 0 : x["y"] };
void { a: x == null ? void 0 : x() };
void { a: x == null ? void 0 : new x() };
// classes
// - computed property names
// void class { [x?.y] = 1 } // legal parse, but causes a checker error
// void class { [x?.["y"]] = 1 } // legal parse, but causes a checker error
// void class { [x?.()] = 1 } // legal parse, but causes a checker error
// void class { [new f?.()] = 1 } // legal parse, but causes a checker error
void (function () {
function class_1() {
this[Symbol == null ? void 0 : Symbol.toStringTag] = "";
}
return class_1;
}());
// - property declarations
void (function () {
function class_2() {
this.a = x == null ? void 0 : x.y;
}
return class_2;
}());
void (function () {
function class_3() {
this.a = x == null ? void 0 : x["y"];
}
return class_3;
}());
void (function () {
function class_4() {
this.a = x == null ? void 0 : x();
}
return class_4;
}());
void (function () {
function class_5() {
this.a = x == null ? void 0 : new x();
}
return class_5;
}());
// - heritage clauses
void (function (_super) {
__extends(class_6, _super);
function class_6() {
return _super !== null && _super.apply(this, arguments) || this;
}
return class_6;
}((M == null ? void 0 : M.y)));
void (function (_super) {
__extends(class_7, _super);
function class_7() {
return _super !== null && _super.apply(this, arguments) || this;
}
return class_7;
}((M == null ? void 0 : M["y"])));
void (function (_super) {
__extends(class_8, _super);
function class_8() {
return _super !== null && _super.apply(this, arguments) || this;
}
return class_8;
}((M == null ? void 0 : M.z)));
// - class decorators
var C1 = (function () {
function C1() {
}
return C1;
}());
C1 = __decorate([
x == null ? void 0 : x.y
], C1);
var C2 = (function () {
function C2() {
}
return C2;
}());
C2 = __decorate([
x == null ? void 0 : x["y"]
], C2);
var C3 = (function () {
function C3() {
}
return C3;
}());
C3 = __decorate([
x == null ? void 0 : x()
], C3);
var C4 = (function () {
function C4() {
}
return C4;
}());
C4 = __decorate([
x == null ? void 0 : new x()
], C4);
// - member decorators
var C5 = (function () {
function C5() {
}
C5.prototype.m = function () { };
return C5;
}());
__decorate([
x == null ? void 0 : x.y
], C5.prototype, "m");
var C6 = (function () {
function C6() {
}
C6.prototype.m = function () { };
return C6;
}()); // allowed as ?.[ is not ambiguous with computed property names
__decorate([
x == null ? void 0 : x["y"]
], C6.prototype, "m");
var C7 = (function () {
function C7() {
}
C7.prototype.m = function () { };
return C7;
}());
__decorate([
x == null ? void 0 : x()
], C7.prototype, "m");
var C8 = (function () {
function C8() {
}
C8.prototype.m = function () { };
return C8;
}());
__decorate([
x == null ? void 0 : new x()
], C8.prototype, "m");
// - parameter decorators
var C9 = (function () {
function C9() {
}
C9.prototype.m = function (a) { };
return C9;
}());
__decorate([
__param(0, x == null ? void 0 : x.y)
], C9.prototype, "m");
var C10 = (function () {
function C10() {
}
C10.prototype.m = function (a) { };
return C10;
}());
__decorate([
__param(0, x == null ? void 0 : x["y"])
], C10.prototype, "m");
var C11 = (function () {
function C11() {
}
C11.prototype.m = function (a) { };
return C11;
}());
__decorate([
__param(0, x == null ? void 0 : x())
], C11.prototype, "m");
var C12 = (function () {
function C12() {
}
C12.prototype.m = function (a) { };
return C12;
}());
__decorate([
__param(0, x == null ? void 0 : new x())
], C12.prototype, "m");
// functions
// - parameters
void function (a) {
if (a === void 0) { a = x == null ? void 0 : x.y; }
};
void function (a) {
if (a === void 0) { a = x == null ? void 0 : x["y"]; }
};
void function (a) {
if (a === void 0) { a = x == null ? void 0 : x(); }
};
void function (a) {
if (a === void 0) { a = x == null ? void 0 : new x(); }
};
// - binding elements
// - initializers
void function (_a) {
var _b = _a.a, a = _b === void 0 ? x == null ? void 0 : x.y : _b;
};
void function (_a) {
var _b = _a.a, a = _b === void 0 ? x == null ? void 0 : x["y"] : _b;
};
void function (_a) {
var _b = _a.a, a = _b === void 0 ? x == null ? void 0 : x() : _b;
};
void function (_a) {
var _b = _a.a, a = _b === void 0 ? x == null ? void 0 : new x() : _b;
};
// - computed properties
void function (_a) {
var _b = x == null ? void 0 : x.y, a = _a[_b];
};
void function (_a) {
var _b = x == null ? void 0 : x["y"], a = _a[_b];
};
void function (_a) {
var _b = x == null ? void 0 : x(), a = _a[_b];
};
void function (_a) {
var _b = x == null ? void 0 : new x(), a = _a[_b];
}(function (a) {
if (a === void 0) { a = x == null ? void 0 : x.y; }
});
(function (a) {
if (a === void 0) { a = x == null ? void 0 : x["y"]; }
});
(function (a) {
if (a === void 0) { a = x == null ? void 0 : x(); }
});
(function (a) {
if (a === void 0) { a = x == null ? void 0 : new x(); }
});
// - expression bodies
(function () { return x == null ? void 0 : x.y; });
(function () { return x == null ? void 0 : x["y"]; });
(function () { return x == null ? void 0 : x(); });
(function () { return x == null ? void 0 : new x(); });
// parenthesis
(x == null ? void 0 : x.y);
// comma
x == null ? void 0 : x.y, f();
f(), x == null ? void 0 : x.y;
// conditional
x == null ? void 0 : x.y ? 0 : 1;
0 ? x == null ? void 0 : x.y : 1;
0 ? 1 : x == null ? void 0 : x.y;
// binary
(x == null ? void 0 : x.y) + 1;
(x == null ? void 0 : x.y) - 1;
(x == null ? void 0 : x.y) * 1;
(x == null ? void 0 : x.y) / 1;
Math.pow((x == null ? void 0 : x.y), 1);
(x == null ? void 0 : x.y) % 1;
(x == null ? void 0 : x.y) ^ 1;
(x == null ? void 0 : x.y) & 1;
(x == null ? void 0 : x.y) | 1;
(x == null ? void 0 : x.y) << 1;
(x == null ? void 0 : x.y) >> 1;
(x == null ? void 0 : x.y) >>> 1;
(x == null ? void 0 : x.y) && 1;
(x == null ? void 0 : x.y) || 1;
(x == null ? void 0 : x.y) == 1;
(x == null ? void 0 : x.y) === 1;
(x == null ? void 0 : x.y) != 1;
(x == null ? void 0 : x.y) !== 1;
(x == null ? void 0 : x.y) < 1;
(x == null ? void 0 : x.y) <= 1;
(x == null ? void 0 : x.y) > 1;
(x == null ? void 0 : x.y) >= 1;
1 + (x == null ? void 0 : x.y);
1 - (x == null ? void 0 : x.y);
1 * (x == null ? void 0 : x.y);
1 / (x == null ? void 0 : x.y);
Math.pow(1, (x == null ? void 0 : x.y));
1 % (x == null ? void 0 : x.y);
1 ^ (x == null ? void 0 : x.y);
1 & (x == null ? void 0 : x.y);
1 | (x == null ? void 0 : x.y);
1 << (x == null ? void 0 : x.y);
1 >> (x == null ? void 0 : x.y);
1 >>> (x == null ? void 0 : x.y);
1 && (x == null ? void 0 : x.y);
1 || (x == null ? void 0 : x.y);
1 == (x == null ? void 0 : x.y);
1 === (x == null ? void 0 : x.y);
1 != (x == null ? void 0 : x.y);
1 !== (x == null ? void 0 : x.y);
1 < (x == null ? void 0 : x.y);
1 <= (x == null ? void 0 : x.y);
1 > (x == null ? void 0 : x.y);
1 >= (x == null ? void 0 : x.y);
// prefix unary
+(x == null ? void 0 : x.y);
-(x == null ? void 0 : x.y);
!(x == null ? void 0 : x.y);
~(x == null ? void 0 : x.y);
// unary
void (x == null ? void 0 : x.y);
typeof (x == null ? void 0 : x.y);
void function () { return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, x == null ? void 0 : x.y];
case 1:
_a.sent();
return [2 /*return*/];
}
}); };
void function () {
return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, (x == null ? void 0 : x.y)];
case 1:
_a.sent();
return [2 /*return*/];
}
}); });
};
// notnull
(x == null ? void 0 : x.y).z;
// assertions
x == null ? void 0 : x.y;
x == null ? void 0 : x.y;
// array literals
[x == null ? void 0 : x.y];
[, x == null ? void 0 : x.y];
(x == null ? void 0 : x.y).slice();
// literals
((_e = 1) == null ? void 0 : _e.toString)(); // no need for `..`
((_f = 1.) == null ? void 0 : _f.toString)();
((_g = .0) == null ? void 0 : _g.toString)();
((_h = 4e3) == null ? void 0 : _h.toString)();
((_j = 1.e3) == null ? void 0 : _j.toString)();
((_k = "") == null ? void 0 : _k.toString)();
((_l = '') == null ? void 0 : _l.toString)();
((_m = "") == null ? void 0 : _m.toString)();
((_o = /./) == null ? void 0 : _o.toString)();
((_p = /./g) == null ? void 0 : _p.toString)();
((_q = true) == null ? void 0 : _q.toString)();
((_r = false) == null ? void 0 : _r.toString)();
// templates
"" + (x == null ? void 0 : x.y);
// variables
var v = x == null ? void 0 : x.y;
var v = (x == null ? void 0 : x.y)[0];
var _s = [1][0], v = _s === void 0 ? x == null ? void 0 : x.y : _s;
var v = (x == null ? void 0 : x.y).v;
var _t = { v: 1 }.v, v = _t === void 0 ? x == null ? void 0 : x.y : _t;
var _u = x == null ? void 0 : x.y, v = null[_u];
// if/else if
if (x == null ? void 0 : x.y) { }
if (1) { }
else if (x == null ? void 0 : x.y) { }
// switch
switch (x == null ? void 0 : x.y) {
}
switch (1) {
case x == null ? void 0 : x.y: break;
}
// do/while
do { } while (x == null ? void 0 : x.y);
while (x == null ? void 0 : x.y) { }
// for
for (x == null ? void 0 : x.y; x == null ? void 0 : x.y; x == null ? void 0 : x.y)
;
// for..in
for (var _v in {}) {
x == null ? _v : x.y = _v;
;
}
// for..of
for (var _i = 0, _w = []; _i < _w.length; _i++) {
var _x = _w[_i];
x == null ? _x : x.y = _x;
;
}
// enums
var E;
(function (E) {
E[E["a"] = x == null ? void 0 : x.y] = "a";
})(E || (E = {}));
var _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _v, _x;
var _a, _b, _c, _d;
//// [exportsOk.js]
"use strict";
exports.__esModule = true;
exports["default"] = x == null ? void 0 : x.y;
@@ -0,0 +1,858 @@
=== tests/cases/conformance/emitter/es3/safeNavigation/declarations.d.ts ===
declare var x: any;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
declare var y: any;
>y : Symbol(y, Decl(declarations.d.ts, 1, 11))
declare var f: ({
>f : Symbol(f, Decl(declarations.d.ts, 2, 11))
(): void;
<T>(): void;
>T : Symbol(T, Decl(declarations.d.ts, 4, 5))
new (): any;
new <T>(): any;
>T : Symbol(T, Decl(declarations.d.ts, 6, 9))
}) | undefined;
declare var o: { y: typeof f; }
>o : Symbol(o, Decl(declarations.d.ts, 8, 11))
>y : Symbol(y, Decl(declarations.d.ts, 8, 16))
>f : Symbol(f, Decl(declarations.d.ts, 2, 11))
declare class Base { x(): any; }
>Base : Symbol(Base, Decl(declarations.d.ts, 8, 31))
>x : Symbol(Base.x, Decl(declarations.d.ts, 9, 20))
declare namespace M {
>M : Symbol(M, Decl(declarations.d.ts, 9, 32))
export class y {}
>y : Symbol(y, Decl(declarations.d.ts, 10, 21))
export class z<T> {}
>z : Symbol(z, Decl(declarations.d.ts, 11, 21))
>T : Symbol(T, Decl(declarations.d.ts, 12, 19))
}
=== tests/cases/conformance/emitter/es3/safeNavigation/propertyAccessOk.ts ===
x.y
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y.z
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x.y?.z
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y?.z
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
=== tests/cases/conformance/emitter/es3/safeNavigation/elementAccessOk.ts ===
x["y"]
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"]
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"]["z"]
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x["y"]?.["z"]
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"]?.["z"]
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
=== tests/cases/conformance/emitter/es3/safeNavigation/callExpressionOk.ts ===
x()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x.y?.()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x["y"]?.()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
f?.<number>()
>f : Symbol(f, Decl(declarations.d.ts, 2, 11))
o.y?.<number>()
>o.y : Symbol(y, Decl(declarations.d.ts, 8, 16))
>o : Symbol(o, Decl(declarations.d.ts, 8, 11))
>y : Symbol(y, Decl(declarations.d.ts, 8, 16))
o["y"]?.<number>()
>o : Symbol(o, Decl(declarations.d.ts, 8, 11))
>"y" : Symbol(y, Decl(declarations.d.ts, 8, 16))
=== tests/cases/conformance/emitter/es3/safeNavigation/newExpressionOk.ts ===
new x()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
new x.y?.()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
new x["y"]?.()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
new f?.<number>()
>f : Symbol(f, Decl(declarations.d.ts, 2, 11))
new o.y?.<number>()
>o.y : Symbol(y, Decl(declarations.d.ts, 8, 16))
>o : Symbol(o, Decl(declarations.d.ts, 8, 11))
>y : Symbol(y, Decl(declarations.d.ts, 8, 16))
new o["y"]?.<number>()
>o : Symbol(o, Decl(declarations.d.ts, 8, 11))
>"y" : Symbol(y, Decl(declarations.d.ts, 8, 16))
=== tests/cases/conformance/emitter/es3/safeNavigation/mixedOk.ts ===
x?.y?.["z"]
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"]?.z
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y?.()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
o?.y<number>()
>o?.y : Symbol(y, Decl(declarations.d.ts, 8, 16))
>o : Symbol(o, Decl(declarations.d.ts, 8, 11))
>y : Symbol(y, Decl(declarations.d.ts, 8, 16))
o?.y?.<number>()
>o?.y : Symbol(y, Decl(declarations.d.ts, 8, 16))
>o : Symbol(o, Decl(declarations.d.ts, 8, 11))
>y : Symbol(y, Decl(declarations.d.ts, 8, 16))
x?.["z"]()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["z"]?.()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
o?.["y"]<number>()
>o : Symbol(o, Decl(declarations.d.ts, 8, 11))
>"y" : Symbol(y, Decl(declarations.d.ts, 8, 16))
o?.["y"]?.<number>()
>o : Symbol(o, Decl(declarations.d.ts, 8, 11))
>"y" : Symbol(y, Decl(declarations.d.ts, 8, 16))
=== tests/cases/conformance/emitter/es3/safeNavigation/mutationOk.ts ===
x?.y = 1
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y += 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y -= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y *= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y /= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y %= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y **= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y |= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y &= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y ^= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y <<= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y >>= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y >>>= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y++;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y--;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
++x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
--x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
delete x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] = 1
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] += 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] -= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] *= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] /= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] %= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] **= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] |= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] &= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] ^= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] <<= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] >>= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] >>>= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"]++;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"]--;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
++x?.["y"];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
--x?.["y"];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
delete x?.["y"];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
=== tests/cases/conformance/emitter/es3/safeNavigation/arrayAssignmentPatternOk.ts ===
[x?.y] = [1];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
[x?.["y"]] = [1];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
[...x?.y] = [1];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
[...x?.["y"]] = [1];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
=== tests/cases/conformance/emitter/es3/safeNavigation/objectAssignmentPatternOk.ts ===
({ a: x?.y } = { a: 1 });
>a : Symbol(a, Decl(objectAssignmentPatternOk.ts, 0, 2))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(objectAssignmentPatternOk.ts, 0, 16))
({ a: x?.["y"] } = { a: 1 });
>a : Symbol(a, Decl(objectAssignmentPatternOk.ts, 1, 2))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(objectAssignmentPatternOk.ts, 1, 20))
=== tests/cases/conformance/emitter/es3/safeNavigation/questionDotDigitIsConditionalOk.ts ===
x?.3:1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
=== tests/cases/conformance/emitter/es3/safeNavigation/superPropertyInvocationOk.ts ===
// supported for invocation of super property
void class extends Base {
>Base : Symbol(Base, Decl(declarations.d.ts, 8, 31))
m() {
>m : Symbol((Anonymous class).m, Decl(superPropertyInvocationOk.ts, 1, 25))
super.x?.();
>super.x : Symbol(Base.x, Decl(declarations.d.ts, 9, 20))
>super : Symbol(Base, Decl(declarations.d.ts, 8, 31))
>x : Symbol(Base.x, Decl(declarations.d.ts, 9, 20))
}
}
=== tests/cases/conformance/emitter/es3/safeNavigation/generalParsingOk.ts ===
// object literals
// - computed property names
void { [x?.y]: 1 }
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void { [x?.["y"]]: 1 }
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void { [x?.()]: 1 }
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void { [new x?.()]: 1 }
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// - property assignments
void { a: x?.y }
>a : Symbol(a, Decl(generalParsingOk.ts, 7, 6))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void { a: x?.["y"] }
>a : Symbol(a, Decl(generalParsingOk.ts, 8, 6))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void { a: x?.() }
>a : Symbol(a, Decl(generalParsingOk.ts, 9, 6))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void { a: new x?.() }
>a : Symbol(a, Decl(generalParsingOk.ts, 10, 6))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// classes
// - computed property names
// void class { [x?.y] = 1 } // legal parse, but causes a checker error
// void class { [x?.["y"]] = 1 } // legal parse, but causes a checker error
// void class { [x?.()] = 1 } // legal parse, but causes a checker error
// void class { [new f?.()] = 1 } // legal parse, but causes a checker error
void class { [Symbol?.toStringTag] = "" }
>Symbol?.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --))
>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
// - property declarations
void class { a = x?.y }
>a : Symbol((Anonymous class).a, Decl(generalParsingOk.ts, 20, 12))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void class { a = x?.["y"] }
>a : Symbol((Anonymous class).a, Decl(generalParsingOk.ts, 21, 12))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void class { a = x?.() }
>a : Symbol((Anonymous class).a, Decl(generalParsingOk.ts, 22, 12))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void class { a = new x?.() }
>a : Symbol((Anonymous class).a, Decl(generalParsingOk.ts, 23, 12))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// - heritage clauses
void class extends M?.y {}
>M?.y : Symbol(M.y, Decl(declarations.d.ts, 10, 21))
>M : Symbol(M, Decl(declarations.d.ts, 9, 32))
>y : Symbol(M.y, Decl(declarations.d.ts, 10, 21))
void class extends M?.["y"] {}
>M : Symbol(M, Decl(declarations.d.ts, 9, 32))
>"y" : Symbol(M.y, Decl(declarations.d.ts, 10, 21))
void class extends M?.z<number> {}
>M?.z : Symbol(M.z, Decl(declarations.d.ts, 11, 21))
>M : Symbol(M, Decl(declarations.d.ts, 9, 32))
>z : Symbol(M.z, Decl(declarations.d.ts, 11, 21))
// - class decorators
@x?.y class C1 {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>C1 : Symbol(C1, Decl(generalParsingOk.ts, 27, 34))
@x?.["y"] class C2 {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>C2 : Symbol(C2, Decl(generalParsingOk.ts, 29, 17))
@x?.() class C3 {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>C3 : Symbol(C3, Decl(generalParsingOk.ts, 30, 21))
@new x?.() class C4 {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>C4 : Symbol(C4, Decl(generalParsingOk.ts, 31, 18))
// - member decorators
class C5 { @x?.y m() {} }
>C5 : Symbol(C5, Decl(generalParsingOk.ts, 32, 22))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>m : Symbol(C5.m, Decl(generalParsingOk.ts, 34, 10))
class C6 { @x?.["y"] m() {} } // allowed as ?.[ is not ambiguous with computed property names
>C6 : Symbol(C6, Decl(generalParsingOk.ts, 34, 25))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>m : Symbol(C6.m, Decl(generalParsingOk.ts, 35, 10))
class C7 { @x?.() m() {} }
>C7 : Symbol(C7, Decl(generalParsingOk.ts, 35, 29))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>m : Symbol(C7.m, Decl(generalParsingOk.ts, 36, 10))
class C8 { @new x?.() m () {} }
>C8 : Symbol(C8, Decl(generalParsingOk.ts, 36, 26))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>m : Symbol(C8.m, Decl(generalParsingOk.ts, 37, 10))
// - parameter decorators
class C9 { m(@x?.y a) {} }
>C9 : Symbol(C9, Decl(generalParsingOk.ts, 37, 31))
>m : Symbol(C9.m, Decl(generalParsingOk.ts, 39, 10))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(generalParsingOk.ts, 39, 13))
class C10 { m(@x?.["y"] a) {} }
>C10 : Symbol(C10, Decl(generalParsingOk.ts, 39, 26))
>m : Symbol(C10.m, Decl(generalParsingOk.ts, 40, 11))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(generalParsingOk.ts, 40, 14))
class C11 { m(@x?.() a) {} }
>C11 : Symbol(C11, Decl(generalParsingOk.ts, 40, 31))
>m : Symbol(C11.m, Decl(generalParsingOk.ts, 41, 11))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(generalParsingOk.ts, 41, 14))
class C12 { m(@new x?.() a) {} }
>C12 : Symbol(C12, Decl(generalParsingOk.ts, 41, 28))
>m : Symbol(C12.m, Decl(generalParsingOk.ts, 42, 11))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(generalParsingOk.ts, 42, 14))
// functions
// - parameters
void function (a = x?.y) {}
>a : Symbol(a, Decl(generalParsingOk.ts, 46, 15))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void function (a = x?.["y"]) {}
>a : Symbol(a, Decl(generalParsingOk.ts, 47, 15))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void function (a = x?.()) {}
>a : Symbol(a, Decl(generalParsingOk.ts, 48, 15))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void function (a = new x?.()) {}
>a : Symbol(a, Decl(generalParsingOk.ts, 49, 15))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// - binding elements
// - initializers
void function ({ a = x?.y }) {}
>a : Symbol(a, Decl(generalParsingOk.ts, 52, 16))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void function ({ a = x?.["y"] }) {}
>a : Symbol(a, Decl(generalParsingOk.ts, 53, 16))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void function ({ a = x?.() }) {}
>a : Symbol(a, Decl(generalParsingOk.ts, 54, 16))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void function ({ a = new x?.() }) {}
>a : Symbol(a, Decl(generalParsingOk.ts, 55, 16))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// - computed properties
void function ({ [x?.y]: a }) {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(generalParsingOk.ts, 57, 16))
void function ({ [x?.["y"]]: a }) {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(generalParsingOk.ts, 58, 16))
void function ({ [x?.()]: a }) {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(generalParsingOk.ts, 59, 16))
void function ({ [new x?.()]: a }) {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(generalParsingOk.ts, 60, 16))
// arrow functions
// - parameters
((a = x?.y) => {});
>a : Symbol(a, Decl(generalParsingOk.ts, 64, 2))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
((a = x?.["y"]) => {});
>a : Symbol(a, Decl(generalParsingOk.ts, 65, 2))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
((a = x?.()) => {});
>a : Symbol(a, Decl(generalParsingOk.ts, 66, 2))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
((a = new x?.()) => {});
>a : Symbol(a, Decl(generalParsingOk.ts, 67, 2))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// - expression bodies
(() => x?.y);
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
(() => x?.["y"]);
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
(() => x?.());
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
(() => new x?.());
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// parenthesis
(x?.y);
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// comma
x?.y, f();
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>f : Symbol(f, Decl(declarations.d.ts, 2, 11))
f(), x?.y;
>f : Symbol(f, Decl(declarations.d.ts, 2, 11))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// conditional
x?.y ? 0 : 1
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
0 ? x?.y : 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
0 ? 1 : x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// binary
x?.y + 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y - 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y * 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y / 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y ** 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y % 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y ^ 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y & 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y | 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y << 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y >> 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y >>> 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y && 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y || 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y == 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y === 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y != 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y !== 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y < 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y <= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y > 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y >= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 + x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 - x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 * x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 / x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 ** x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 % x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 ^ x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 & x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 | x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 << x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 >> x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 >>> x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 && x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 || x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 == x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 === x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 != x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 !== x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 < x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 <= x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 > x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 >= x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// prefix unary
+x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
-x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
!x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
~x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// unary
void x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
typeof x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void function * () { yield x?.y; }
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void async function() { await x?.y; }
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// notnull
x?.y!.z;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// assertions
<string>x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y as string;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// array literals
[x?.y];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
[, x?.y];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
[...x?.y];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// literals
1?.toString(); // no need for `..`
>1?.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
1.?.toString();
>1.?.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
.0?.toString();
>.0?.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
4e3?.toString();
>4e3?.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
1.e3?.toString();
>1.e3?.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
""?.toString();
>""?.toString : Symbol(String.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(String.toString, Decl(lib.es5.d.ts, --, --))
''?.toString();
>''?.toString : Symbol(String.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(String.toString, Decl(lib.es5.d.ts, --, --))
``?.toString();
>``?.toString : Symbol(String.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(String.toString, Decl(lib.es5.d.ts, --, --))
/./?.toString();
>/./?.toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
/./g?.toString();
>/./g?.toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
true?.toString();
>true?.toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
false?.toString();
>false?.toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
// templates
`${x?.y}`;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// variables
var v = x?.y;
>v : Symbol(v, Decl(generalParsingOk.ts, 174, 3), Decl(generalParsingOk.ts, 175, 5), Decl(generalParsingOk.ts, 176, 5), Decl(generalParsingOk.ts, 177, 5), Decl(generalParsingOk.ts, 178, 5), Decl(generalParsingOk.ts, 179, 5))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
var [v] = x?.y;
>v : Symbol(v, Decl(generalParsingOk.ts, 174, 3), Decl(generalParsingOk.ts, 175, 5), Decl(generalParsingOk.ts, 176, 5), Decl(generalParsingOk.ts, 177, 5), Decl(generalParsingOk.ts, 178, 5), Decl(generalParsingOk.ts, 179, 5))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
var [v = x?.y] = [1];
>v : Symbol(v, Decl(generalParsingOk.ts, 174, 3), Decl(generalParsingOk.ts, 175, 5), Decl(generalParsingOk.ts, 176, 5), Decl(generalParsingOk.ts, 177, 5), Decl(generalParsingOk.ts, 178, 5), Decl(generalParsingOk.ts, 179, 5))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
var {v} = x?.y;
>v : Symbol(v, Decl(generalParsingOk.ts, 174, 3), Decl(generalParsingOk.ts, 175, 5), Decl(generalParsingOk.ts, 176, 5), Decl(generalParsingOk.ts, 177, 5), Decl(generalParsingOk.ts, 178, 5), Decl(generalParsingOk.ts, 179, 5))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
var {v = x?.y} = {v:1};
>v : Symbol(v, Decl(generalParsingOk.ts, 174, 3), Decl(generalParsingOk.ts, 175, 5), Decl(generalParsingOk.ts, 176, 5), Decl(generalParsingOk.ts, 177, 5), Decl(generalParsingOk.ts, 178, 5), Decl(generalParsingOk.ts, 179, 5))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>v : Symbol(v, Decl(generalParsingOk.ts, 178, 18))
var {[x?.y]: v} = null;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>v : Symbol(v, Decl(generalParsingOk.ts, 174, 3), Decl(generalParsingOk.ts, 175, 5), Decl(generalParsingOk.ts, 176, 5), Decl(generalParsingOk.ts, 177, 5), Decl(generalParsingOk.ts, 178, 5), Decl(generalParsingOk.ts, 179, 5))
// if/else if
if (x?.y) {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
if (1) {} else if (x?.y) {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// switch
switch (x?.y) {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
switch (1) { case x?.y: break; }
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// do/while
do {} while (x?.y)
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
while (x?.y) {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// for
for (x?.y; x?.y; x?.y);
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// for..in
for (x?.y in {});
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// for..of
for (x?.y of []);
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// enums
enum E {
>E : Symbol(E, Decl(generalParsingOk.ts, 200, 17))
a = x?.y
>a : Symbol(E.a, Decl(generalParsingOk.ts, 203, 8))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
}
=== tests/cases/conformance/emitter/es3/safeNavigation/exportsOk.ts ===
export default x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,874 @@
//// [tests/cases/conformance/emitter/es5/safeNavigation/emitter.safeNavigation.es5.ts] ////
//// [declarations.d.ts]
declare var x: any;
declare var y: any;
declare var f: ({
(): void;
<T>(): void;
new (): any;
new <T>(): any;
}) | undefined;
declare var o: { y: typeof f; }
declare class Base { x(): any; }
declare namespace M {
export class y {}
export class z<T> {}
}
//// [propertyAccessOk.ts]
x.y
x?.y
x?.y.z
x.y?.z
x?.y?.z
//// [elementAccessOk.ts]
x["y"]
x?.["y"]
x?.["y"]["z"]
x["y"]?.["z"]
x?.["y"]?.["z"]
//// [callExpressionOk.ts]
x()
x?.()
x.y?.()
x["y"]?.()
f?.<number>()
o.y?.<number>()
o["y"]?.<number>()
//// [newExpressionOk.ts]
new x()
new x.y?.()
new x["y"]?.()
new f?.<number>()
new o.y?.<number>()
new o["y"]?.<number>()
//// [mixedOk.ts]
x?.y?.["z"]
x?.["y"]?.z
x?.y()
x?.y?.()
o?.y<number>()
o?.y?.<number>()
x?.["z"]()
x?.["z"]?.()
o?.["y"]<number>()
o?.["y"]?.<number>()
//// [mutationOk.ts]
x?.y = 1
x?.y += 1;
x?.y -= 1;
x?.y *= 1;
x?.y /= 1;
x?.y %= 1;
x?.y **= 1;
x?.y |= 1;
x?.y &= 1;
x?.y ^= 1;
x?.y <<= 1;
x?.y >>= 1;
x?.y >>>= 1;
x?.y++;
x?.y--;
++x?.y;
--x?.y;
delete x?.y;
x?.["y"] = 1
x?.["y"] += 1;
x?.["y"] -= 1;
x?.["y"] *= 1;
x?.["y"] /= 1;
x?.["y"] %= 1;
x?.["y"] **= 1;
x?.["y"] |= 1;
x?.["y"] &= 1;
x?.["y"] ^= 1;
x?.["y"] <<= 1;
x?.["y"] >>= 1;
x?.["y"] >>>= 1;
x?.["y"]++;
x?.["y"]--;
++x?.["y"];
--x?.["y"];
delete x?.["y"];
//// [arrayAssignmentPatternOk.ts]
[x?.y] = [1];
[x?.["y"]] = [1];
[...x?.y] = [1];
[...x?.["y"]] = [1];
//// [objectAssignmentPatternOk.ts]
({ a: x?.y } = { a: 1 });
({ a: x?.["y"] } = { a: 1 });
//// [questionDotDigitIsConditionalOk.ts]
x?.3:1;
//// [superPropertyInvocationOk.ts]
// supported for invocation of super property
void class extends Base {
m() {
super.x?.();
}
}
//// [generalParsingOk.ts]
// object literals
// - computed property names
void { [x?.y]: 1 }
void { [x?.["y"]]: 1 }
void { [x?.()]: 1 }
void { [new x?.()]: 1 }
// - property assignments
void { a: x?.y }
void { a: x?.["y"] }
void { a: x?.() }
void { a: new x?.() }
// classes
// - computed property names
// void class { [x?.y] = 1 } // legal parse, but causes a checker error
// void class { [x?.["y"]] = 1 } // legal parse, but causes a checker error
// void class { [x?.()] = 1 } // legal parse, but causes a checker error
// void class { [new f?.()] = 1 } // legal parse, but causes a checker error
void class { [Symbol?.toStringTag] = "" }
// - property declarations
void class { a = x?.y }
void class { a = x?.["y"] }
void class { a = x?.() }
void class { a = new x?.() }
// - heritage clauses
void class extends M?.y {}
void class extends M?.["y"] {}
void class extends M?.z<number> {}
// - class decorators
@x?.y class C1 {}
@x?.["y"] class C2 {}
@x?.() class C3 {}
@new x?.() class C4 {}
// - member decorators
class C5 { @x?.y m() {} }
class C6 { @x?.["y"] m() {} } // allowed as ?.[ is not ambiguous with computed property names
class C7 { @x?.() m() {} }
class C8 { @new x?.() m () {} }
// - parameter decorators
class C9 { m(@x?.y a) {} }
class C10 { m(@x?.["y"] a) {} }
class C11 { m(@x?.() a) {} }
class C12 { m(@new x?.() a) {} }
// functions
// - parameters
void function (a = x?.y) {}
void function (a = x?.["y"]) {}
void function (a = x?.()) {}
void function (a = new x?.()) {}
// - binding elements
// - initializers
void function ({ a = x?.y }) {}
void function ({ a = x?.["y"] }) {}
void function ({ a = x?.() }) {}
void function ({ a = new x?.() }) {}
// - computed properties
void function ({ [x?.y]: a }) {}
void function ({ [x?.["y"]]: a }) {}
void function ({ [x?.()]: a }) {}
void function ({ [new x?.()]: a }) {}
// arrow functions
// - parameters
((a = x?.y) => {});
((a = x?.["y"]) => {});
((a = x?.()) => {});
((a = new x?.()) => {});
// - expression bodies
(() => x?.y);
(() => x?.["y"]);
(() => x?.());
(() => new x?.());
// parenthesis
(x?.y);
// comma
x?.y, f();
f(), x?.y;
// conditional
x?.y ? 0 : 1
0 ? x?.y : 1;
0 ? 1 : x?.y;
// binary
x?.y + 1;
x?.y - 1;
x?.y * 1;
x?.y / 1;
x?.y ** 1;
x?.y % 1;
x?.y ^ 1;
x?.y & 1;
x?.y | 1;
x?.y << 1;
x?.y >> 1;
x?.y >>> 1;
x?.y && 1;
x?.y || 1;
x?.y == 1;
x?.y === 1;
x?.y != 1;
x?.y !== 1;
x?.y < 1;
x?.y <= 1;
x?.y > 1;
x?.y >= 1;
1 + x?.y;
1 - x?.y;
1 * x?.y;
1 / x?.y;
1 ** x?.y;
1 % x?.y;
1 ^ x?.y;
1 & x?.y;
1 | x?.y;
1 << x?.y;
1 >> x?.y;
1 >>> x?.y;
1 && x?.y;
1 || x?.y;
1 == x?.y;
1 === x?.y;
1 != x?.y;
1 !== x?.y;
1 < x?.y;
1 <= x?.y;
1 > x?.y;
1 >= x?.y;
// prefix unary
+x?.y;
-x?.y;
!x?.y;
~x?.y;
// unary
void x?.y;
typeof x?.y;
void function * () { yield x?.y; }
void async function() { await x?.y; }
// notnull
x?.y!.z;
// assertions
<string>x?.y;
x?.y as string;
// array literals
[x?.y];
[, x?.y];
[...x?.y];
// literals
1?.toString(); // no need for `..`
1.?.toString();
.0?.toString();
4e3?.toString();
1.e3?.toString();
""?.toString();
''?.toString();
``?.toString();
/./?.toString();
/./g?.toString();
true?.toString();
false?.toString();
// templates
`${x?.y}`;
// variables
var v = x?.y;
var [v] = x?.y;
var [v = x?.y] = [1];
var {v} = x?.y;
var {v = x?.y} = {v:1};
var {[x?.y]: v} = null;
// if/else if
if (x?.y) {}
if (1) {} else if (x?.y) {}
// switch
switch (x?.y) {}
switch (1) { case x?.y: break; }
// do/while
do {} while (x?.y)
while (x?.y) {}
// for
for (x?.y; x?.y; x?.y);
// for..in
for (x?.y in {});
// for..of
for (x?.y of []);
// enums
enum E {
a = x?.y
}
//// [exportsOk.ts]
export default x?.y;
//// [propertyAccessOk.js]
x.y;
x == null ? void 0 : x.y;
(x == null ? void 0 : x.y).z;
(_a = x.y) == null ? void 0 : _a.z;
(_b = x == null ? void 0 : x.y) == null ? void 0 : _b.z;
var _a, _b;
//// [elementAccessOk.js]
x["y"];
x == null ? void 0 : x["y"];
(x == null ? void 0 : x["y"])["z"];
(_a = x["y"]) == null ? void 0 : _a["z"];
(_b = x == null ? void 0 : x["y"]) == null ? void 0 : _b["z"];
var _a, _b;
//// [callExpressionOk.js]
x();
x == null ? void 0 : x();
(_a = x.y) == null ? void 0 : _a.call(x);
(_b = x["y"]) == null ? void 0 : _b.call(x);
f == null ? void 0 : f();
(_c = o.y) == null ? void 0 : _c.call(o);
(_d = o["y"]) == null ? void 0 : _d.call(o);
var _a, _b, _c, _d;
//// [newExpressionOk.js]
new x();
(_a = x.y) == null ? void 0 : new _a();
(_b = x["y"]) == null ? void 0 : new _b();
f == null ? void 0 : new f();
(_c = o.y) == null ? void 0 : new _c();
(_d = o["y"]) == null ? void 0 : new _d();
var _a, _b, _c, _d;
//// [mixedOk.js]
(_a = x == null ? void 0 : x.y) == null ? void 0 : _a["z"];
(_b = x == null ? void 0 : x["y"]) == null ? void 0 : _b.z;
(x == null ? void 0 : x.y)();
(_c = x == null ? void 0 : x.y) == null ? void 0 : _c.call(x);
(o == null ? void 0 : o.y)();
(_d = o == null ? void 0 : o.y) == null ? void 0 : _d.call(o);
(x == null ? void 0 : x["z"])();
(_e = x == null ? void 0 : x["z"]) == null ? void 0 : _e.call(x);
(o == null ? void 0 : o["y"])();
(_f = o == null ? void 0 : o["y"]) == null ? void 0 : _f.call(o);
var _a, _b, _c, _d, _e, _f;
//// [mutationOk.js]
_a = 1, x == null ? _a : x.y = _a;
_b = 1, x == null ? _b : x.y += _b;
_c = 1, x == null ? _c : x.y -= _c;
_d = 1, x == null ? _d : x.y *= _d;
_e = 1, x == null ? _e : x.y /= _e;
_f = 1, x == null ? _f : x.y %= _f;
_g = 1, x == null ? _g : (_h = x).y = Math.pow(_h.y, _g);
_j = 1, x == null ? _j : x.y |= _j;
_k = 1, x == null ? _k : x.y &= _k;
_l = 1, x == null ? _l : x.y ^= _l;
_m = 1, x == null ? _m : x.y <<= _m;
_o = 1, x == null ? _o : x.y >>= _o;
_p = 1, x == null ? _p : x.y >>>= _p;
x == null ? void 0 : x.y++;
x == null ? void 0 : x.y--;
x == null ? void 0 : ++x.y;
x == null ? void 0 : --x.y;
x == null ? true : delete x.y;
_q = 1, x == null ? _q : x["y"] = _q;
_r = 1, x == null ? _r : x["y"] += _r;
_s = 1, x == null ? _s : x["y"] -= _s;
_t = 1, x == null ? _t : x["y"] *= _t;
_u = 1, x == null ? _u : x["y"] /= _u;
_v = 1, x == null ? _v : x["y"] %= _v;
_w = 1, x == null ? _w : (_x = x)[_y = "y"] = Math.pow(_x[_y], _w);
_z = 1, x == null ? _z : x["y"] |= _z;
_0 = 1, x == null ? _0 : x["y"] &= _0;
_1 = 1, x == null ? _1 : x["y"] ^= _1;
_2 = 1, x == null ? _2 : x["y"] <<= _2;
_3 = 1, x == null ? _3 : x["y"] >>= _3;
_4 = 1, x == null ? _4 : x["y"] >>>= _4;
x == null ? void 0 : x["y"]++;
x == null ? void 0 : x["y"]--;
x == null ? void 0 : ++x["y"];
x == null ? void 0 : --x["y"];
x == null ? true : delete x["y"];
var _a, _b, _c, _d, _e, _f, _g, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _z, _0, _1, _2, _3, _4;
var _h, _x, _y;
//// [arrayAssignmentPatternOk.js]
_a = [1], (x == null ? void 0 : x.y = _a[0], _a);
_b = [1], (x == null ? void 0 : x["y"] = _b[0], _b);
_c = [1], (x == null ? void 0 : x.y = _c.slice(0), _c);
_d = [1], (x == null ? void 0 : x["y"] = _d.slice(0), _d);
var _a, _b, _c, _d;
//// [objectAssignmentPatternOk.js]
(_a = { a: 1 }, (x == null ? void 0 : x.y = _a.a, _a));
(_b = { a: 1 }, (x == null ? void 0 : x["y"] = _b.a, _b));
var _a, _b;
//// [questionDotDigitIsConditionalOk.js]
x ? .3 : 1;
//// [superPropertyInvocationOk.js]
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
// supported for invocation of super property
void (function (_super) {
__extends(class_1, _super);
function class_1() {
return _super !== null && _super.apply(this, arguments) || this;
}
class_1.prototype.m = function () {
(_a = _super.prototype.x) == null ? void 0 : _a.call(this);
var _a;
};
return class_1;
}(Base));
//// [generalParsingOk.js]
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
// object literals
// - computed property names
void (_a = {}, _a[x == null ? void 0 : x.y] = 1, _a);
void (_b = {}, _b[x == null ? void 0 : x["y"]] = 1, _b);
void (_c = {}, _c[x == null ? void 0 : x()] = 1, _c);
void (_d = {}, _d[x == null ? void 0 : new x()] = 1, _d);
// - property assignments
void { a: x == null ? void 0 : x.y };
void { a: x == null ? void 0 : x["y"] };
void { a: x == null ? void 0 : x() };
void { a: x == null ? void 0 : new x() };
// classes
// - computed property names
// void class { [x?.y] = 1 } // legal parse, but causes a checker error
// void class { [x?.["y"]] = 1 } // legal parse, but causes a checker error
// void class { [x?.()] = 1 } // legal parse, but causes a checker error
// void class { [new f?.()] = 1 } // legal parse, but causes a checker error
void (function () {
function class_1() {
this[Symbol == null ? void 0 : Symbol.toStringTag] = "";
}
return class_1;
}());
// - property declarations
void (function () {
function class_2() {
this.a = x == null ? void 0 : x.y;
}
return class_2;
}());
void (function () {
function class_3() {
this.a = x == null ? void 0 : x["y"];
}
return class_3;
}());
void (function () {
function class_4() {
this.a = x == null ? void 0 : x();
}
return class_4;
}());
void (function () {
function class_5() {
this.a = x == null ? void 0 : new x();
}
return class_5;
}());
// - heritage clauses
void (function (_super) {
__extends(class_6, _super);
function class_6() {
return _super !== null && _super.apply(this, arguments) || this;
}
return class_6;
}((M == null ? void 0 : M.y)));
void (function (_super) {
__extends(class_7, _super);
function class_7() {
return _super !== null && _super.apply(this, arguments) || this;
}
return class_7;
}((M == null ? void 0 : M["y"])));
void (function (_super) {
__extends(class_8, _super);
function class_8() {
return _super !== null && _super.apply(this, arguments) || this;
}
return class_8;
}((M == null ? void 0 : M.z)));
// - class decorators
var C1 = (function () {
function C1() {
}
return C1;
}());
C1 = __decorate([
x == null ? void 0 : x.y
], C1);
var C2 = (function () {
function C2() {
}
return C2;
}());
C2 = __decorate([
x == null ? void 0 : x["y"]
], C2);
var C3 = (function () {
function C3() {
}
return C3;
}());
C3 = __decorate([
x == null ? void 0 : x()
], C3);
var C4 = (function () {
function C4() {
}
return C4;
}());
C4 = __decorate([
x == null ? void 0 : new x()
], C4);
// - member decorators
var C5 = (function () {
function C5() {
}
C5.prototype.m = function () { };
return C5;
}());
__decorate([
x == null ? void 0 : x.y
], C5.prototype, "m", null);
var C6 = (function () {
function C6() {
}
C6.prototype.m = function () { };
return C6;
}()); // allowed as ?.[ is not ambiguous with computed property names
__decorate([
x == null ? void 0 : x["y"]
], C6.prototype, "m", null);
var C7 = (function () {
function C7() {
}
C7.prototype.m = function () { };
return C7;
}());
__decorate([
x == null ? void 0 : x()
], C7.prototype, "m", null);
var C8 = (function () {
function C8() {
}
C8.prototype.m = function () { };
return C8;
}());
__decorate([
x == null ? void 0 : new x()
], C8.prototype, "m", null);
// - parameter decorators
var C9 = (function () {
function C9() {
}
C9.prototype.m = function (a) { };
return C9;
}());
__decorate([
__param(0, x == null ? void 0 : x.y)
], C9.prototype, "m", null);
var C10 = (function () {
function C10() {
}
C10.prototype.m = function (a) { };
return C10;
}());
__decorate([
__param(0, x == null ? void 0 : x["y"])
], C10.prototype, "m", null);
var C11 = (function () {
function C11() {
}
C11.prototype.m = function (a) { };
return C11;
}());
__decorate([
__param(0, x == null ? void 0 : x())
], C11.prototype, "m", null);
var C12 = (function () {
function C12() {
}
C12.prototype.m = function (a) { };
return C12;
}());
__decorate([
__param(0, x == null ? void 0 : new x())
], C12.prototype, "m", null);
// functions
// - parameters
void function (a) {
if (a === void 0) { a = x == null ? void 0 : x.y; }
};
void function (a) {
if (a === void 0) { a = x == null ? void 0 : x["y"]; }
};
void function (a) {
if (a === void 0) { a = x == null ? void 0 : x(); }
};
void function (a) {
if (a === void 0) { a = x == null ? void 0 : new x(); }
};
// - binding elements
// - initializers
void function (_a) {
var _b = _a.a, a = _b === void 0 ? x == null ? void 0 : x.y : _b;
};
void function (_a) {
var _b = _a.a, a = _b === void 0 ? x == null ? void 0 : x["y"] : _b;
};
void function (_a) {
var _b = _a.a, a = _b === void 0 ? x == null ? void 0 : x() : _b;
};
void function (_a) {
var _b = _a.a, a = _b === void 0 ? x == null ? void 0 : new x() : _b;
};
// - computed properties
void function (_a) {
var _b = x == null ? void 0 : x.y, a = _a[_b];
};
void function (_a) {
var _b = x == null ? void 0 : x["y"], a = _a[_b];
};
void function (_a) {
var _b = x == null ? void 0 : x(), a = _a[_b];
};
void function (_a) {
var _b = x == null ? void 0 : new x(), a = _a[_b];
}(function (a) {
if (a === void 0) { a = x == null ? void 0 : x.y; }
});
(function (a) {
if (a === void 0) { a = x == null ? void 0 : x["y"]; }
});
(function (a) {
if (a === void 0) { a = x == null ? void 0 : x(); }
});
(function (a) {
if (a === void 0) { a = x == null ? void 0 : new x(); }
});
// - expression bodies
(function () { return x == null ? void 0 : x.y; });
(function () { return x == null ? void 0 : x["y"]; });
(function () { return x == null ? void 0 : x(); });
(function () { return x == null ? void 0 : new x(); });
// parenthesis
(x == null ? void 0 : x.y);
// comma
x == null ? void 0 : x.y, f();
f(), x == null ? void 0 : x.y;
// conditional
x == null ? void 0 : x.y ? 0 : 1;
0 ? x == null ? void 0 : x.y : 1;
0 ? 1 : x == null ? void 0 : x.y;
// binary
(x == null ? void 0 : x.y) + 1;
(x == null ? void 0 : x.y) - 1;
(x == null ? void 0 : x.y) * 1;
(x == null ? void 0 : x.y) / 1;
Math.pow((x == null ? void 0 : x.y), 1);
(x == null ? void 0 : x.y) % 1;
(x == null ? void 0 : x.y) ^ 1;
(x == null ? void 0 : x.y) & 1;
(x == null ? void 0 : x.y) | 1;
(x == null ? void 0 : x.y) << 1;
(x == null ? void 0 : x.y) >> 1;
(x == null ? void 0 : x.y) >>> 1;
(x == null ? void 0 : x.y) && 1;
(x == null ? void 0 : x.y) || 1;
(x == null ? void 0 : x.y) == 1;
(x == null ? void 0 : x.y) === 1;
(x == null ? void 0 : x.y) != 1;
(x == null ? void 0 : x.y) !== 1;
(x == null ? void 0 : x.y) < 1;
(x == null ? void 0 : x.y) <= 1;
(x == null ? void 0 : x.y) > 1;
(x == null ? void 0 : x.y) >= 1;
1 + (x == null ? void 0 : x.y);
1 - (x == null ? void 0 : x.y);
1 * (x == null ? void 0 : x.y);
1 / (x == null ? void 0 : x.y);
Math.pow(1, (x == null ? void 0 : x.y));
1 % (x == null ? void 0 : x.y);
1 ^ (x == null ? void 0 : x.y);
1 & (x == null ? void 0 : x.y);
1 | (x == null ? void 0 : x.y);
1 << (x == null ? void 0 : x.y);
1 >> (x == null ? void 0 : x.y);
1 >>> (x == null ? void 0 : x.y);
1 && (x == null ? void 0 : x.y);
1 || (x == null ? void 0 : x.y);
1 == (x == null ? void 0 : x.y);
1 === (x == null ? void 0 : x.y);
1 != (x == null ? void 0 : x.y);
1 !== (x == null ? void 0 : x.y);
1 < (x == null ? void 0 : x.y);
1 <= (x == null ? void 0 : x.y);
1 > (x == null ? void 0 : x.y);
1 >= (x == null ? void 0 : x.y);
// prefix unary
+(x == null ? void 0 : x.y);
-(x == null ? void 0 : x.y);
!(x == null ? void 0 : x.y);
~(x == null ? void 0 : x.y);
// unary
void (x == null ? void 0 : x.y);
typeof (x == null ? void 0 : x.y);
void function () { return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, x == null ? void 0 : x.y];
case 1:
_a.sent();
return [2 /*return*/];
}
}); };
void function () {
return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, (x == null ? void 0 : x.y)];
case 1:
_a.sent();
return [2 /*return*/];
}
}); });
};
// notnull
(x == null ? void 0 : x.y).z;
// assertions
x == null ? void 0 : x.y;
x == null ? void 0 : x.y;
// array literals
[x == null ? void 0 : x.y];
[, x == null ? void 0 : x.y];
(x == null ? void 0 : x.y).slice();
// literals
((_e = 1) == null ? void 0 : _e.toString)(); // no need for `..`
((_f = 1.) == null ? void 0 : _f.toString)();
((_g = .0) == null ? void 0 : _g.toString)();
((_h = 4e3) == null ? void 0 : _h.toString)();
((_j = 1.e3) == null ? void 0 : _j.toString)();
((_k = "") == null ? void 0 : _k.toString)();
((_l = '') == null ? void 0 : _l.toString)();
((_m = "") == null ? void 0 : _m.toString)();
((_o = /./) == null ? void 0 : _o.toString)();
((_p = /./g) == null ? void 0 : _p.toString)();
((_q = true) == null ? void 0 : _q.toString)();
((_r = false) == null ? void 0 : _r.toString)();
// templates
"" + (x == null ? void 0 : x.y);
// variables
var v = x == null ? void 0 : x.y;
var v = (x == null ? void 0 : x.y)[0];
var _s = [1][0], v = _s === void 0 ? x == null ? void 0 : x.y : _s;
var v = (x == null ? void 0 : x.y).v;
var _t = { v: 1 }.v, v = _t === void 0 ? x == null ? void 0 : x.y : _t;
var _u = x == null ? void 0 : x.y, v = null[_u];
// if/else if
if (x == null ? void 0 : x.y) { }
if (1) { }
else if (x == null ? void 0 : x.y) { }
// switch
switch (x == null ? void 0 : x.y) {
}
switch (1) {
case x == null ? void 0 : x.y: break;
}
// do/while
do { } while (x == null ? void 0 : x.y);
while (x == null ? void 0 : x.y) { }
// for
for (x == null ? void 0 : x.y; x == null ? void 0 : x.y; x == null ? void 0 : x.y)
;
// for..in
for ({ set value(_a) { x == null ? _a : x.y = _a; } }.value in {})
;
// for..of
for (var _i = 0, _v = []; _i < _v.length; _i++) {
var _w = _v[_i];
x == null ? _w : x.y = _w;
;
}
// enums
var E;
(function (E) {
E[E["a"] = x == null ? void 0 : x.y] = "a";
})(E || (E = {}));
var _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _w;
var _a, _b, _c, _d;
//// [exportsOk.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = x == null ? void 0 : x.y;
@@ -0,0 +1,858 @@
=== tests/cases/conformance/emitter/es5/safeNavigation/declarations.d.ts ===
declare var x: any;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
declare var y: any;
>y : Symbol(y, Decl(declarations.d.ts, 1, 11))
declare var f: ({
>f : Symbol(f, Decl(declarations.d.ts, 2, 11))
(): void;
<T>(): void;
>T : Symbol(T, Decl(declarations.d.ts, 4, 5))
new (): any;
new <T>(): any;
>T : Symbol(T, Decl(declarations.d.ts, 6, 9))
}) | undefined;
declare var o: { y: typeof f; }
>o : Symbol(o, Decl(declarations.d.ts, 8, 11))
>y : Symbol(y, Decl(declarations.d.ts, 8, 16))
>f : Symbol(f, Decl(declarations.d.ts, 2, 11))
declare class Base { x(): any; }
>Base : Symbol(Base, Decl(declarations.d.ts, 8, 31))
>x : Symbol(Base.x, Decl(declarations.d.ts, 9, 20))
declare namespace M {
>M : Symbol(M, Decl(declarations.d.ts, 9, 32))
export class y {}
>y : Symbol(y, Decl(declarations.d.ts, 10, 21))
export class z<T> {}
>z : Symbol(z, Decl(declarations.d.ts, 11, 21))
>T : Symbol(T, Decl(declarations.d.ts, 12, 19))
}
=== tests/cases/conformance/emitter/es5/safeNavigation/propertyAccessOk.ts ===
x.y
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y.z
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x.y?.z
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y?.z
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
=== tests/cases/conformance/emitter/es5/safeNavigation/elementAccessOk.ts ===
x["y"]
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"]
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"]["z"]
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x["y"]?.["z"]
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"]?.["z"]
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
=== tests/cases/conformance/emitter/es5/safeNavigation/callExpressionOk.ts ===
x()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x.y?.()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x["y"]?.()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
f?.<number>()
>f : Symbol(f, Decl(declarations.d.ts, 2, 11))
o.y?.<number>()
>o.y : Symbol(y, Decl(declarations.d.ts, 8, 16))
>o : Symbol(o, Decl(declarations.d.ts, 8, 11))
>y : Symbol(y, Decl(declarations.d.ts, 8, 16))
o["y"]?.<number>()
>o : Symbol(o, Decl(declarations.d.ts, 8, 11))
>"y" : Symbol(y, Decl(declarations.d.ts, 8, 16))
=== tests/cases/conformance/emitter/es5/safeNavigation/newExpressionOk.ts ===
new x()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
new x.y?.()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
new x["y"]?.()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
new f?.<number>()
>f : Symbol(f, Decl(declarations.d.ts, 2, 11))
new o.y?.<number>()
>o.y : Symbol(y, Decl(declarations.d.ts, 8, 16))
>o : Symbol(o, Decl(declarations.d.ts, 8, 11))
>y : Symbol(y, Decl(declarations.d.ts, 8, 16))
new o["y"]?.<number>()
>o : Symbol(o, Decl(declarations.d.ts, 8, 11))
>"y" : Symbol(y, Decl(declarations.d.ts, 8, 16))
=== tests/cases/conformance/emitter/es5/safeNavigation/mixedOk.ts ===
x?.y?.["z"]
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"]?.z
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y?.()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
o?.y<number>()
>o?.y : Symbol(y, Decl(declarations.d.ts, 8, 16))
>o : Symbol(o, Decl(declarations.d.ts, 8, 11))
>y : Symbol(y, Decl(declarations.d.ts, 8, 16))
o?.y?.<number>()
>o?.y : Symbol(y, Decl(declarations.d.ts, 8, 16))
>o : Symbol(o, Decl(declarations.d.ts, 8, 11))
>y : Symbol(y, Decl(declarations.d.ts, 8, 16))
x?.["z"]()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["z"]?.()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
o?.["y"]<number>()
>o : Symbol(o, Decl(declarations.d.ts, 8, 11))
>"y" : Symbol(y, Decl(declarations.d.ts, 8, 16))
o?.["y"]?.<number>()
>o : Symbol(o, Decl(declarations.d.ts, 8, 11))
>"y" : Symbol(y, Decl(declarations.d.ts, 8, 16))
=== tests/cases/conformance/emitter/es5/safeNavigation/mutationOk.ts ===
x?.y = 1
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y += 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y -= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y *= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y /= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y %= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y **= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y |= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y &= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y ^= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y <<= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y >>= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y >>>= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y++;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y--;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
++x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
--x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
delete x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] = 1
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] += 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] -= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] *= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] /= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] %= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] **= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] |= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] &= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] ^= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] <<= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] >>= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] >>>= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"]++;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"]--;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
++x?.["y"];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
--x?.["y"];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
delete x?.["y"];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
=== tests/cases/conformance/emitter/es5/safeNavigation/arrayAssignmentPatternOk.ts ===
[x?.y] = [1];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
[x?.["y"]] = [1];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
[...x?.y] = [1];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
[...x?.["y"]] = [1];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
=== tests/cases/conformance/emitter/es5/safeNavigation/objectAssignmentPatternOk.ts ===
({ a: x?.y } = { a: 1 });
>a : Symbol(a, Decl(objectAssignmentPatternOk.ts, 0, 2))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(objectAssignmentPatternOk.ts, 0, 16))
({ a: x?.["y"] } = { a: 1 });
>a : Symbol(a, Decl(objectAssignmentPatternOk.ts, 1, 2))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(objectAssignmentPatternOk.ts, 1, 20))
=== tests/cases/conformance/emitter/es5/safeNavigation/questionDotDigitIsConditionalOk.ts ===
x?.3:1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
=== tests/cases/conformance/emitter/es5/safeNavigation/superPropertyInvocationOk.ts ===
// supported for invocation of super property
void class extends Base {
>Base : Symbol(Base, Decl(declarations.d.ts, 8, 31))
m() {
>m : Symbol((Anonymous class).m, Decl(superPropertyInvocationOk.ts, 1, 25))
super.x?.();
>super.x : Symbol(Base.x, Decl(declarations.d.ts, 9, 20))
>super : Symbol(Base, Decl(declarations.d.ts, 8, 31))
>x : Symbol(Base.x, Decl(declarations.d.ts, 9, 20))
}
}
=== tests/cases/conformance/emitter/es5/safeNavigation/generalParsingOk.ts ===
// object literals
// - computed property names
void { [x?.y]: 1 }
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void { [x?.["y"]]: 1 }
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void { [x?.()]: 1 }
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void { [new x?.()]: 1 }
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// - property assignments
void { a: x?.y }
>a : Symbol(a, Decl(generalParsingOk.ts, 7, 6))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void { a: x?.["y"] }
>a : Symbol(a, Decl(generalParsingOk.ts, 8, 6))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void { a: x?.() }
>a : Symbol(a, Decl(generalParsingOk.ts, 9, 6))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void { a: new x?.() }
>a : Symbol(a, Decl(generalParsingOk.ts, 10, 6))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// classes
// - computed property names
// void class { [x?.y] = 1 } // legal parse, but causes a checker error
// void class { [x?.["y"]] = 1 } // legal parse, but causes a checker error
// void class { [x?.()] = 1 } // legal parse, but causes a checker error
// void class { [new f?.()] = 1 } // legal parse, but causes a checker error
void class { [Symbol?.toStringTag] = "" }
>Symbol?.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --))
>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
// - property declarations
void class { a = x?.y }
>a : Symbol((Anonymous class).a, Decl(generalParsingOk.ts, 20, 12))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void class { a = x?.["y"] }
>a : Symbol((Anonymous class).a, Decl(generalParsingOk.ts, 21, 12))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void class { a = x?.() }
>a : Symbol((Anonymous class).a, Decl(generalParsingOk.ts, 22, 12))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void class { a = new x?.() }
>a : Symbol((Anonymous class).a, Decl(generalParsingOk.ts, 23, 12))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// - heritage clauses
void class extends M?.y {}
>M?.y : Symbol(M.y, Decl(declarations.d.ts, 10, 21))
>M : Symbol(M, Decl(declarations.d.ts, 9, 32))
>y : Symbol(M.y, Decl(declarations.d.ts, 10, 21))
void class extends M?.["y"] {}
>M : Symbol(M, Decl(declarations.d.ts, 9, 32))
>"y" : Symbol(M.y, Decl(declarations.d.ts, 10, 21))
void class extends M?.z<number> {}
>M?.z : Symbol(M.z, Decl(declarations.d.ts, 11, 21))
>M : Symbol(M, Decl(declarations.d.ts, 9, 32))
>z : Symbol(M.z, Decl(declarations.d.ts, 11, 21))
// - class decorators
@x?.y class C1 {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>C1 : Symbol(C1, Decl(generalParsingOk.ts, 27, 34))
@x?.["y"] class C2 {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>C2 : Symbol(C2, Decl(generalParsingOk.ts, 29, 17))
@x?.() class C3 {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>C3 : Symbol(C3, Decl(generalParsingOk.ts, 30, 21))
@new x?.() class C4 {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>C4 : Symbol(C4, Decl(generalParsingOk.ts, 31, 18))
// - member decorators
class C5 { @x?.y m() {} }
>C5 : Symbol(C5, Decl(generalParsingOk.ts, 32, 22))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>m : Symbol(C5.m, Decl(generalParsingOk.ts, 34, 10))
class C6 { @x?.["y"] m() {} } // allowed as ?.[ is not ambiguous with computed property names
>C6 : Symbol(C6, Decl(generalParsingOk.ts, 34, 25))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>m : Symbol(C6.m, Decl(generalParsingOk.ts, 35, 10))
class C7 { @x?.() m() {} }
>C7 : Symbol(C7, Decl(generalParsingOk.ts, 35, 29))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>m : Symbol(C7.m, Decl(generalParsingOk.ts, 36, 10))
class C8 { @new x?.() m () {} }
>C8 : Symbol(C8, Decl(generalParsingOk.ts, 36, 26))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>m : Symbol(C8.m, Decl(generalParsingOk.ts, 37, 10))
// - parameter decorators
class C9 { m(@x?.y a) {} }
>C9 : Symbol(C9, Decl(generalParsingOk.ts, 37, 31))
>m : Symbol(C9.m, Decl(generalParsingOk.ts, 39, 10))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(generalParsingOk.ts, 39, 13))
class C10 { m(@x?.["y"] a) {} }
>C10 : Symbol(C10, Decl(generalParsingOk.ts, 39, 26))
>m : Symbol(C10.m, Decl(generalParsingOk.ts, 40, 11))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(generalParsingOk.ts, 40, 14))
class C11 { m(@x?.() a) {} }
>C11 : Symbol(C11, Decl(generalParsingOk.ts, 40, 31))
>m : Symbol(C11.m, Decl(generalParsingOk.ts, 41, 11))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(generalParsingOk.ts, 41, 14))
class C12 { m(@new x?.() a) {} }
>C12 : Symbol(C12, Decl(generalParsingOk.ts, 41, 28))
>m : Symbol(C12.m, Decl(generalParsingOk.ts, 42, 11))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(generalParsingOk.ts, 42, 14))
// functions
// - parameters
void function (a = x?.y) {}
>a : Symbol(a, Decl(generalParsingOk.ts, 46, 15))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void function (a = x?.["y"]) {}
>a : Symbol(a, Decl(generalParsingOk.ts, 47, 15))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void function (a = x?.()) {}
>a : Symbol(a, Decl(generalParsingOk.ts, 48, 15))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void function (a = new x?.()) {}
>a : Symbol(a, Decl(generalParsingOk.ts, 49, 15))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// - binding elements
// - initializers
void function ({ a = x?.y }) {}
>a : Symbol(a, Decl(generalParsingOk.ts, 52, 16))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void function ({ a = x?.["y"] }) {}
>a : Symbol(a, Decl(generalParsingOk.ts, 53, 16))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void function ({ a = x?.() }) {}
>a : Symbol(a, Decl(generalParsingOk.ts, 54, 16))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void function ({ a = new x?.() }) {}
>a : Symbol(a, Decl(generalParsingOk.ts, 55, 16))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// - computed properties
void function ({ [x?.y]: a }) {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(generalParsingOk.ts, 57, 16))
void function ({ [x?.["y"]]: a }) {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(generalParsingOk.ts, 58, 16))
void function ({ [x?.()]: a }) {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(generalParsingOk.ts, 59, 16))
void function ({ [new x?.()]: a }) {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(generalParsingOk.ts, 60, 16))
// arrow functions
// - parameters
((a = x?.y) => {});
>a : Symbol(a, Decl(generalParsingOk.ts, 64, 2))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
((a = x?.["y"]) => {});
>a : Symbol(a, Decl(generalParsingOk.ts, 65, 2))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
((a = x?.()) => {});
>a : Symbol(a, Decl(generalParsingOk.ts, 66, 2))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
((a = new x?.()) => {});
>a : Symbol(a, Decl(generalParsingOk.ts, 67, 2))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// - expression bodies
(() => x?.y);
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
(() => x?.["y"]);
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
(() => x?.());
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
(() => new x?.());
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// parenthesis
(x?.y);
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// comma
x?.y, f();
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>f : Symbol(f, Decl(declarations.d.ts, 2, 11))
f(), x?.y;
>f : Symbol(f, Decl(declarations.d.ts, 2, 11))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// conditional
x?.y ? 0 : 1
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
0 ? x?.y : 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
0 ? 1 : x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// binary
x?.y + 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y - 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y * 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y / 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y ** 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y % 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y ^ 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y & 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y | 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y << 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y >> 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y >>> 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y && 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y || 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y == 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y === 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y != 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y !== 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y < 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y <= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y > 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y >= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 + x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 - x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 * x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 / x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 ** x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 % x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 ^ x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 & x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 | x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 << x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 >> x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 >>> x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 && x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 || x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 == x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 === x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 != x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 !== x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 < x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 <= x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 > x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 >= x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// prefix unary
+x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
-x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
!x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
~x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// unary
void x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
typeof x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void function * () { yield x?.y; }
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void async function() { await x?.y; }
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// notnull
x?.y!.z;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// assertions
<string>x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y as string;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// array literals
[x?.y];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
[, x?.y];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
[...x?.y];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// literals
1?.toString(); // no need for `..`
>1?.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
1.?.toString();
>1.?.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
.0?.toString();
>.0?.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
4e3?.toString();
>4e3?.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
1.e3?.toString();
>1.e3?.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
""?.toString();
>""?.toString : Symbol(String.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(String.toString, Decl(lib.es5.d.ts, --, --))
''?.toString();
>''?.toString : Symbol(String.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(String.toString, Decl(lib.es5.d.ts, --, --))
``?.toString();
>``?.toString : Symbol(String.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(String.toString, Decl(lib.es5.d.ts, --, --))
/./?.toString();
>/./?.toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
/./g?.toString();
>/./g?.toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
true?.toString();
>true?.toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
false?.toString();
>false?.toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
// templates
`${x?.y}`;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// variables
var v = x?.y;
>v : Symbol(v, Decl(generalParsingOk.ts, 174, 3), Decl(generalParsingOk.ts, 175, 5), Decl(generalParsingOk.ts, 176, 5), Decl(generalParsingOk.ts, 177, 5), Decl(generalParsingOk.ts, 178, 5), Decl(generalParsingOk.ts, 179, 5))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
var [v] = x?.y;
>v : Symbol(v, Decl(generalParsingOk.ts, 174, 3), Decl(generalParsingOk.ts, 175, 5), Decl(generalParsingOk.ts, 176, 5), Decl(generalParsingOk.ts, 177, 5), Decl(generalParsingOk.ts, 178, 5), Decl(generalParsingOk.ts, 179, 5))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
var [v = x?.y] = [1];
>v : Symbol(v, Decl(generalParsingOk.ts, 174, 3), Decl(generalParsingOk.ts, 175, 5), Decl(generalParsingOk.ts, 176, 5), Decl(generalParsingOk.ts, 177, 5), Decl(generalParsingOk.ts, 178, 5), Decl(generalParsingOk.ts, 179, 5))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
var {v} = x?.y;
>v : Symbol(v, Decl(generalParsingOk.ts, 174, 3), Decl(generalParsingOk.ts, 175, 5), Decl(generalParsingOk.ts, 176, 5), Decl(generalParsingOk.ts, 177, 5), Decl(generalParsingOk.ts, 178, 5), Decl(generalParsingOk.ts, 179, 5))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
var {v = x?.y} = {v:1};
>v : Symbol(v, Decl(generalParsingOk.ts, 174, 3), Decl(generalParsingOk.ts, 175, 5), Decl(generalParsingOk.ts, 176, 5), Decl(generalParsingOk.ts, 177, 5), Decl(generalParsingOk.ts, 178, 5), Decl(generalParsingOk.ts, 179, 5))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>v : Symbol(v, Decl(generalParsingOk.ts, 178, 18))
var {[x?.y]: v} = null;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>v : Symbol(v, Decl(generalParsingOk.ts, 174, 3), Decl(generalParsingOk.ts, 175, 5), Decl(generalParsingOk.ts, 176, 5), Decl(generalParsingOk.ts, 177, 5), Decl(generalParsingOk.ts, 178, 5), Decl(generalParsingOk.ts, 179, 5))
// if/else if
if (x?.y) {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
if (1) {} else if (x?.y) {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// switch
switch (x?.y) {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
switch (1) { case x?.y: break; }
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// do/while
do {} while (x?.y)
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
while (x?.y) {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// for
for (x?.y; x?.y; x?.y);
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// for..in
for (x?.y in {});
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// for..of
for (x?.y of []);
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// enums
enum E {
>E : Symbol(E, Decl(generalParsingOk.ts, 200, 17))
a = x?.y
>a : Symbol(E.a, Decl(generalParsingOk.ts, 203, 8))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
}
=== tests/cases/conformance/emitter/es5/safeNavigation/exportsOk.ts ===
export default x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,697 @@
//// [tests/cases/conformance/emitter/esnext/safeNavigation/emitter.safeNavigation.esnext.ts] ////
//// [declarations.d.ts]
declare var x: any;
declare var y: any;
declare var f: ({
(): void;
<T>(): void;
new (): any;
new <T>(): any;
}) | undefined;
declare var o: { y: typeof f; }
declare class Base { x(): any; }
declare namespace M {
export class y {}
export class z<T> {}
}
//// [propertyAccessOk.ts]
x.y
x?.y
x?.y.z
x.y?.z
x?.y?.z
//// [elementAccessOk.ts]
x["y"]
x?.["y"]
x?.["y"]["z"]
x["y"]?.["z"]
x?.["y"]?.["z"]
//// [callExpressionOk.ts]
x()
x?.()
x.y?.()
x["y"]?.()
f?.<number>()
o.y?.<number>()
o["y"]?.<number>()
//// [newExpressionOk.ts]
new x()
new x.y?.()
new x["y"]?.()
new f?.<number>()
new o.y?.<number>()
new o["y"]?.<number>()
//// [mixedOk.ts]
x?.y?.["z"]
x?.["y"]?.z
x?.y()
x?.y?.()
o?.y<number>()
o?.y?.<number>()
x?.["z"]()
x?.["z"]?.()
o?.["y"]<number>()
o?.["y"]?.<number>()
//// [mutationOk.ts]
x?.y = 1
x?.y += 1;
x?.y -= 1;
x?.y *= 1;
x?.y /= 1;
x?.y %= 1;
x?.y **= 1;
x?.y |= 1;
x?.y &= 1;
x?.y ^= 1;
x?.y <<= 1;
x?.y >>= 1;
x?.y >>>= 1;
x?.y++;
x?.y--;
++x?.y;
--x?.y;
delete x?.y;
x?.["y"] = 1
x?.["y"] += 1;
x?.["y"] -= 1;
x?.["y"] *= 1;
x?.["y"] /= 1;
x?.["y"] %= 1;
x?.["y"] **= 1;
x?.["y"] |= 1;
x?.["y"] &= 1;
x?.["y"] ^= 1;
x?.["y"] <<= 1;
x?.["y"] >>= 1;
x?.["y"] >>>= 1;
x?.["y"]++;
x?.["y"]--;
++x?.["y"];
--x?.["y"];
delete x?.["y"];
//// [arrayAssignmentPatternOk.ts]
[x?.y] = [1];
[x?.["y"]] = [1];
[...x?.y] = [1];
[...x?.["y"]] = [1];
//// [objectAssignmentPatternOk.ts]
({ a: x?.y } = { a: 1 });
({ a: x?.["y"] } = { a: 1 });
//// [questionDotDigitIsConditionalOk.ts]
x?.3:1;
//// [superPropertyInvocationOk.ts]
// supported for invocation of super property
void class extends Base {
m() {
super.x?.();
super["x"]?.();
}
}
//// [generalParsingOk.ts]
// object literals
// - computed property names
void { [x?.y]: 1 }
void { [x?.["y"]]: 1 }
void { [x?.()]: 1 }
void { [new x?.()]: 1 }
// - property assignments
void { a: x?.y }
void { a: x?.["y"] }
void { a: x?.() }
void { a: new x?.() }
// classes
// - computed property names
// void class { [x?.y] = 1 } // legal parse, but causes a checker error
// void class { [x?.["y"]] = 1 } // legal parse, but causes a checker error
// void class { [x?.()] = 1 } // legal parse, but causes a checker error
// void class { [new f?.()] = 1 } // legal parse, but causes a checker error
void class { [Symbol?.toStringTag] = "" }
// - property declarations
void class { a = x?.y }
void class { a = x?.["y"] }
void class { a = x?.() }
void class { a = new x?.() }
// - heritage clauses
void class extends M?.y {}
void class extends M?.["y"] {}
void class extends M?.z<number> {}
// - class decorators
@x?.y class C1 {}
@x?.["y"] class C2 {}
@x?.() class C3 {}
@new x?.() class C4 {}
// - member decorators
class C5 { @x?.y m() {} }
class C6 { @x?.["y"] m() {} } // allowed as ?.[ is not ambiguous with computed property names
class C7 { @x?.() m() {} }
class C8 { @new x?.() m () {} }
// - parameter decorators
class C9 { m(@x?.y a) {} }
class C10 { m(@x?.["y"] a) {} }
class C11 { m(@x?.() a) {} }
class C12 { m(@new x?.() a) {} }
// functions
// - parameters
void function (a = x?.y) {}
void function (a = x?.["y"]) {}
void function (a = x?.()) {}
void function (a = new x?.()) {}
// - binding elements
// - initializers
void function ({ a = x?.y }) {}
void function ({ a = x?.["y"] }) {}
void function ({ a = x?.() }) {}
void function ({ a = new x?.() }) {}
// - computed properties
void function ({ [x?.y]: a }) {}
void function ({ [x?.["y"]]: a }) {}
void function ({ [x?.()]: a }) {}
void function ({ [new x?.()]: a }) {}
// arrow functions
// - parameters
((a = x?.y) => {});
((a = x?.["y"]) => {});
((a = x?.()) => {});
((a = new x?.()) => {});
// - expression bodies
(() => x?.y);
(() => x?.["y"]);
(() => x?.());
(() => new x?.());
// parenthesis
(x?.y);
// comma
x?.y, f();
f(), x?.y;
// conditional
x?.y ? 0 : 1
0 ? x?.y : 1;
0 ? 1 : x?.y;
// binary
x?.y + 1;
x?.y - 1;
x?.y * 1;
x?.y / 1;
x?.y ** 1;
x?.y % 1;
x?.y ^ 1;
x?.y & 1;
x?.y | 1;
x?.y << 1;
x?.y >> 1;
x?.y >>> 1;
x?.y && 1;
x?.y || 1;
x?.y == 1;
x?.y === 1;
x?.y != 1;
x?.y !== 1;
x?.y < 1;
x?.y <= 1;
x?.y > 1;
x?.y >= 1;
1 + x?.y;
1 - x?.y;
1 * x?.y;
1 / x?.y;
1 ** x?.y;
1 % x?.y;
1 ^ x?.y;
1 & x?.y;
1 | x?.y;
1 << x?.y;
1 >> x?.y;
1 >>> x?.y;
1 && x?.y;
1 || x?.y;
1 == x?.y;
1 === x?.y;
1 != x?.y;
1 !== x?.y;
1 < x?.y;
1 <= x?.y;
1 > x?.y;
1 >= x?.y;
// prefix unary
+x?.y;
-x?.y;
!x?.y;
~x?.y;
// unary
void x?.y;
typeof x?.y;
void function * () { yield x?.y; }
void async function() { await x?.y; }
// notnull
x?.y!.z;
// assertions
<string>x?.y;
x?.y as string;
// array literals
[x?.y];
[, x?.y];
[...x?.y];
// literals
1?.toString(); // no need for `..`
1.?.toString();
.0?.toString();
4e3?.toString();
1.e3?.toString();
""?.toString();
''?.toString();
``?.toString();
/./?.toString();
/./g?.toString();
true?.toString();
false?.toString();
// templates
`${x?.y}`;
// variables
var v = x?.y;
var [v] = x?.y;
var [v = x?.y] = [1];
var {v} = x?.y;
var {v = x?.y} = {v:1};
var {[x?.y]: v} = null;
// if/else if
if (x?.y) {}
if (1) {} else if (x?.y) {}
// switch
switch (x?.y) {}
switch (1) { case x?.y: break; }
// do/while
do {} while (x?.y)
while (x?.y) {}
// for
for (x?.y; x?.y; x?.y);
// for..in
for (x?.y in {});
// for..of
for (x?.y of []);
// enums
enum E {
a = x?.y
}
//// [exportsOk.ts]
export default x?.y;
//// [propertyAccessOk.js]
x.y;
x?.y;
x?.y.z;
x.y?.z;
x?.y?.z;
//// [elementAccessOk.js]
x["y"];
x?.["y"];
x?.["y"]["z"];
x["y"]?.["z"];
x?.["y"]?.["z"];
//// [callExpressionOk.js]
x();
x?.();
x.y?.();
x["y"]?.();
f?.();
o.y?.();
o["y"]?.();
//// [newExpressionOk.js]
new x();
new x.y?.();
new x["y"]?.();
new f?.();
new o.y?.();
new o["y"]?.();
//// [mixedOk.js]
x?.y?.["z"];
x?.["y"]?.z;
x?.y();
x?.y?.();
o?.y();
o?.y?.();
x?.["z"]();
x?.["z"]?.();
o?.["y"]();
o?.["y"]?.();
//// [mutationOk.js]
x?.y = 1;
x?.y += 1;
x?.y -= 1;
x?.y *= 1;
x?.y /= 1;
x?.y %= 1;
x?.y **= 1;
x?.y |= 1;
x?.y &= 1;
x?.y ^= 1;
x?.y <<= 1;
x?.y >>= 1;
x?.y >>>= 1;
x?.y++;
x?.y--;
++x?.y;
--x?.y;
delete x?.y;
x?.["y"] = 1;
x?.["y"] += 1;
x?.["y"] -= 1;
x?.["y"] *= 1;
x?.["y"] /= 1;
x?.["y"] %= 1;
x?.["y"] **= 1;
x?.["y"] |= 1;
x?.["y"] &= 1;
x?.["y"] ^= 1;
x?.["y"] <<= 1;
x?.["y"] >>= 1;
x?.["y"] >>>= 1;
x?.["y"]++;
x?.["y"]--;
++x?.["y"];
--x?.["y"];
delete x?.["y"];
//// [arrayAssignmentPatternOk.js]
[x?.y] = [1];
[x?.["y"]] = [1];
[...x?.y] = [1];
[...x?.["y"]] = [1];
//// [objectAssignmentPatternOk.js]
({ a: x?.y } = { a: 1 });
({ a: x?.["y"] } = { a: 1 });
//// [questionDotDigitIsConditionalOk.js]
x ? .3 : 1;
//// [superPropertyInvocationOk.js]
// supported for invocation of super property
void class extends Base {
m() {
super.x?.();
super["x"]?.();
}
};
//// [generalParsingOk.js]
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
// object literals
// - computed property names
void { [x?.y]: 1 };
void { [x?.["y"]]: 1 };
void { [x?.()]: 1 };
void { [new x?.()]: 1 };
// - property assignments
void { a: x?.y };
void { a: x?.["y"] };
void { a: x?.() };
void { a: new x?.() };
// classes
// - computed property names
// void class { [x?.y] = 1 } // legal parse, but causes a checker error
// void class { [x?.["y"]] = 1 } // legal parse, but causes a checker error
// void class { [x?.()] = 1 } // legal parse, but causes a checker error
// void class { [new f?.()] = 1 } // legal parse, but causes a checker error
void class {
constructor() {
this[Symbol?.toStringTag] = "";
}
};
// - property declarations
void class {
constructor() {
this.a = x?.y;
}
};
void class {
constructor() {
this.a = x?.["y"];
}
};
void class {
constructor() {
this.a = x?.();
}
};
void class {
constructor() {
this.a = new x?.();
}
};
// - heritage clauses
void class extends M?.y {
};
void class extends M?.["y"] {
};
void class extends M?.z {
};
// - class decorators
let C1 = class C1 {
};
C1 = __decorate([
x?.y
], C1);
let C2 = class C2 {
};
C2 = __decorate([
x?.["y"]
], C2);
let C3 = class C3 {
};
C3 = __decorate([
x?.()
], C3);
let C4 = class C4 {
};
C4 = __decorate([
new x?.()
], C4);
// - member decorators
class C5 {
m() { }
}
__decorate([
x?.y
], C5.prototype, "m", null);
class C6 {
m() { }
} // allowed as ?.[ is not ambiguous with computed property names
__decorate([
x?.["y"]
], C6.prototype, "m", null);
class C7 {
m() { }
}
__decorate([
x?.()
], C7.prototype, "m", null);
class C8 {
m() { }
}
__decorate([
new x?.()
], C8.prototype, "m", null);
// - parameter decorators
class C9 {
m(a) { }
}
__decorate([
__param(0, x?.y)
], C9.prototype, "m", null);
class C10 {
m(a) { }
}
__decorate([
__param(0, x?.["y"])
], C10.prototype, "m", null);
class C11 {
m(a) { }
}
__decorate([
__param(0, x?.())
], C11.prototype, "m", null);
class C12 {
m(a) { }
}
__decorate([
__param(0, new x?.())
], C12.prototype, "m", null);
// functions
// - parameters
void function (a = x?.y) { };
void function (a = x?.["y"]) { };
void function (a = x?.()) { };
void function (a = new x?.()) { };
// - binding elements
// - initializers
void function ({ a = x?.y }) { };
void function ({ a = x?.["y"] }) { };
void function ({ a = x?.() }) { };
void function ({ a = new x?.() }) { };
// - computed properties
void function ({ [x?.y]: a }) { };
void function ({ [x?.["y"]]: a }) { };
void function ({ [x?.()]: a }) { };
void function ({ [new x?.()]: a }) { }((a = x?.y) => { });
((a = x?.["y"]) => { });
((a = x?.()) => { });
((a = new x?.()) => { });
// - expression bodies
(() => x?.y);
(() => x?.["y"]);
(() => x?.());
(() => new x?.());
// parenthesis
(x?.y);
// comma
x?.y, f();
f(), x?.y;
// conditional
x?.y ? 0 : 1;
0 ? x?.y : 1;
0 ? 1 : x?.y;
// binary
x?.y + 1;
x?.y - 1;
x?.y * 1;
x?.y / 1;
x?.y ** 1;
x?.y % 1;
x?.y ^ 1;
x?.y & 1;
x?.y | 1;
x?.y << 1;
x?.y >> 1;
x?.y >>> 1;
x?.y && 1;
x?.y || 1;
x?.y == 1;
x?.y === 1;
x?.y != 1;
x?.y !== 1;
x?.y < 1;
x?.y <= 1;
x?.y > 1;
x?.y >= 1;
1 + x?.y;
1 - x?.y;
1 * x?.y;
1 / x?.y;
1 ** x?.y;
1 % x?.y;
1 ^ x?.y;
1 & x?.y;
1 | x?.y;
1 << x?.y;
1 >> x?.y;
1 >>> x?.y;
1 && x?.y;
1 || x?.y;
1 == x?.y;
1 === x?.y;
1 != x?.y;
1 !== x?.y;
1 < x?.y;
1 <= x?.y;
1 > x?.y;
1 >= x?.y;
// prefix unary
+x?.y;
-x?.y;
!x?.y;
~x?.y;
// unary
void x?.y;
typeof x?.y;
void function* () { yield x?.y; };
void async function () { await x?.y; };
// notnull
x?.y.z;
// assertions
x?.y;
x?.y;
// array literals
[x?.y];
[, x?.y];
[...x?.y];
// literals
1?.toString(); // no need for `..`
1.?.toString();
.0?.toString();
4e3?.toString();
1.e3?.toString();
""?.toString();
''?.toString();
``?.toString();
/./?.toString();
/./g?.toString();
true?.toString();
false?.toString();
// templates
`${x?.y}`;
// variables
var v = x?.y;
var [v] = x?.y;
var [v = x?.y] = [1];
var { v } = x?.y;
var { v = x?.y } = { v: 1 };
var { [x?.y]: v } = null;
// if/else if
if (x?.y) { }
if (1) { }
else if (x?.y) { }
// switch
switch (x?.y) {
}
switch (1) {
case x?.y: break;
}
// do/while
do { } while (x?.y);
while (x?.y) { }
// for
for (x?.y; x?.y; x?.y)
;
// for..in
for (x?.y in {})
;
// for..of
for (x?.y of [])
;
// enums
var E;
(function (E) {
E[E["a"] = x?.y] = "a";
})(E || (E = {}));
//// [exportsOk.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = x?.y;
@@ -0,0 +1,862 @@
=== tests/cases/conformance/emitter/esnext/safeNavigation/declarations.d.ts ===
declare var x: any;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
declare var y: any;
>y : Symbol(y, Decl(declarations.d.ts, 1, 11))
declare var f: ({
>f : Symbol(f, Decl(declarations.d.ts, 2, 11))
(): void;
<T>(): void;
>T : Symbol(T, Decl(declarations.d.ts, 4, 5))
new (): any;
new <T>(): any;
>T : Symbol(T, Decl(declarations.d.ts, 6, 9))
}) | undefined;
declare var o: { y: typeof f; }
>o : Symbol(o, Decl(declarations.d.ts, 8, 11))
>y : Symbol(y, Decl(declarations.d.ts, 8, 16))
>f : Symbol(f, Decl(declarations.d.ts, 2, 11))
declare class Base { x(): any; }
>Base : Symbol(Base, Decl(declarations.d.ts, 8, 31))
>x : Symbol(Base.x, Decl(declarations.d.ts, 9, 20))
declare namespace M {
>M : Symbol(M, Decl(declarations.d.ts, 9, 32))
export class y {}
>y : Symbol(y, Decl(declarations.d.ts, 10, 21))
export class z<T> {}
>z : Symbol(z, Decl(declarations.d.ts, 11, 21))
>T : Symbol(T, Decl(declarations.d.ts, 12, 19))
}
=== tests/cases/conformance/emitter/esnext/safeNavigation/propertyAccessOk.ts ===
x.y
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y.z
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x.y?.z
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y?.z
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
=== tests/cases/conformance/emitter/esnext/safeNavigation/elementAccessOk.ts ===
x["y"]
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"]
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"]["z"]
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x["y"]?.["z"]
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"]?.["z"]
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
=== tests/cases/conformance/emitter/esnext/safeNavigation/callExpressionOk.ts ===
x()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x.y?.()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x["y"]?.()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
f?.<number>()
>f : Symbol(f, Decl(declarations.d.ts, 2, 11))
o.y?.<number>()
>o.y : Symbol(y, Decl(declarations.d.ts, 8, 16))
>o : Symbol(o, Decl(declarations.d.ts, 8, 11))
>y : Symbol(y, Decl(declarations.d.ts, 8, 16))
o["y"]?.<number>()
>o : Symbol(o, Decl(declarations.d.ts, 8, 11))
>"y" : Symbol(y, Decl(declarations.d.ts, 8, 16))
=== tests/cases/conformance/emitter/esnext/safeNavigation/newExpressionOk.ts ===
new x()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
new x.y?.()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
new x["y"]?.()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
new f?.<number>()
>f : Symbol(f, Decl(declarations.d.ts, 2, 11))
new o.y?.<number>()
>o.y : Symbol(y, Decl(declarations.d.ts, 8, 16))
>o : Symbol(o, Decl(declarations.d.ts, 8, 11))
>y : Symbol(y, Decl(declarations.d.ts, 8, 16))
new o["y"]?.<number>()
>o : Symbol(o, Decl(declarations.d.ts, 8, 11))
>"y" : Symbol(y, Decl(declarations.d.ts, 8, 16))
=== tests/cases/conformance/emitter/esnext/safeNavigation/mixedOk.ts ===
x?.y?.["z"]
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"]?.z
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y?.()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
o?.y<number>()
>o?.y : Symbol(y, Decl(declarations.d.ts, 8, 16))
>o : Symbol(o, Decl(declarations.d.ts, 8, 11))
>y : Symbol(y, Decl(declarations.d.ts, 8, 16))
o?.y?.<number>()
>o?.y : Symbol(y, Decl(declarations.d.ts, 8, 16))
>o : Symbol(o, Decl(declarations.d.ts, 8, 11))
>y : Symbol(y, Decl(declarations.d.ts, 8, 16))
x?.["z"]()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["z"]?.()
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
o?.["y"]<number>()
>o : Symbol(o, Decl(declarations.d.ts, 8, 11))
>"y" : Symbol(y, Decl(declarations.d.ts, 8, 16))
o?.["y"]?.<number>()
>o : Symbol(o, Decl(declarations.d.ts, 8, 11))
>"y" : Symbol(y, Decl(declarations.d.ts, 8, 16))
=== tests/cases/conformance/emitter/esnext/safeNavigation/mutationOk.ts ===
x?.y = 1
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y += 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y -= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y *= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y /= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y %= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y **= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y |= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y &= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y ^= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y <<= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y >>= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y >>>= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y++;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y--;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
++x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
--x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
delete x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] = 1
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] += 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] -= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] *= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] /= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] %= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] **= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] |= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] &= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] ^= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] <<= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] >>= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"] >>>= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"]++;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.["y"]--;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
++x?.["y"];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
--x?.["y"];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
delete x?.["y"];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
=== tests/cases/conformance/emitter/esnext/safeNavigation/arrayAssignmentPatternOk.ts ===
[x?.y] = [1];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
[x?.["y"]] = [1];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
[...x?.y] = [1];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
[...x?.["y"]] = [1];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
=== tests/cases/conformance/emitter/esnext/safeNavigation/objectAssignmentPatternOk.ts ===
({ a: x?.y } = { a: 1 });
>a : Symbol(a, Decl(objectAssignmentPatternOk.ts, 0, 2))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(objectAssignmentPatternOk.ts, 0, 16))
({ a: x?.["y"] } = { a: 1 });
>a : Symbol(a, Decl(objectAssignmentPatternOk.ts, 1, 2))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(objectAssignmentPatternOk.ts, 1, 20))
=== tests/cases/conformance/emitter/esnext/safeNavigation/questionDotDigitIsConditionalOk.ts ===
x?.3:1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
=== tests/cases/conformance/emitter/esnext/safeNavigation/superPropertyInvocationOk.ts ===
// supported for invocation of super property
void class extends Base {
>Base : Symbol(Base, Decl(declarations.d.ts, 8, 31))
m() {
>m : Symbol((Anonymous class).m, Decl(superPropertyInvocationOk.ts, 1, 25))
super.x?.();
>super.x : Symbol(Base.x, Decl(declarations.d.ts, 9, 20))
>super : Symbol(Base, Decl(declarations.d.ts, 8, 31))
>x : Symbol(Base.x, Decl(declarations.d.ts, 9, 20))
super["x"]?.();
>super : Symbol(Base, Decl(declarations.d.ts, 8, 31))
>"x" : Symbol(Base.x, Decl(declarations.d.ts, 9, 20))
}
}
=== tests/cases/conformance/emitter/esnext/safeNavigation/generalParsingOk.ts ===
// object literals
// - computed property names
void { [x?.y]: 1 }
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void { [x?.["y"]]: 1 }
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void { [x?.()]: 1 }
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void { [new x?.()]: 1 }
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// - property assignments
void { a: x?.y }
>a : Symbol(a, Decl(generalParsingOk.ts, 7, 6))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void { a: x?.["y"] }
>a : Symbol(a, Decl(generalParsingOk.ts, 8, 6))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void { a: x?.() }
>a : Symbol(a, Decl(generalParsingOk.ts, 9, 6))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void { a: new x?.() }
>a : Symbol(a, Decl(generalParsingOk.ts, 10, 6))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// classes
// - computed property names
// void class { [x?.y] = 1 } // legal parse, but causes a checker error
// void class { [x?.["y"]] = 1 } // legal parse, but causes a checker error
// void class { [x?.()] = 1 } // legal parse, but causes a checker error
// void class { [new f?.()] = 1 } // legal parse, but causes a checker error
void class { [Symbol?.toStringTag] = "" }
>Symbol?.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --))
>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
// - property declarations
void class { a = x?.y }
>a : Symbol((Anonymous class).a, Decl(generalParsingOk.ts, 20, 12))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void class { a = x?.["y"] }
>a : Symbol((Anonymous class).a, Decl(generalParsingOk.ts, 21, 12))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void class { a = x?.() }
>a : Symbol((Anonymous class).a, Decl(generalParsingOk.ts, 22, 12))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void class { a = new x?.() }
>a : Symbol((Anonymous class).a, Decl(generalParsingOk.ts, 23, 12))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// - heritage clauses
void class extends M?.y {}
>M?.y : Symbol(M.y, Decl(declarations.d.ts, 10, 21))
>M : Symbol(M, Decl(declarations.d.ts, 9, 32))
>y : Symbol(M.y, Decl(declarations.d.ts, 10, 21))
void class extends M?.["y"] {}
>M : Symbol(M, Decl(declarations.d.ts, 9, 32))
>"y" : Symbol(M.y, Decl(declarations.d.ts, 10, 21))
void class extends M?.z<number> {}
>M?.z : Symbol(M.z, Decl(declarations.d.ts, 11, 21))
>M : Symbol(M, Decl(declarations.d.ts, 9, 32))
>z : Symbol(M.z, Decl(declarations.d.ts, 11, 21))
// - class decorators
@x?.y class C1 {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>C1 : Symbol(C1, Decl(generalParsingOk.ts, 27, 34))
@x?.["y"] class C2 {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>C2 : Symbol(C2, Decl(generalParsingOk.ts, 29, 17))
@x?.() class C3 {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>C3 : Symbol(C3, Decl(generalParsingOk.ts, 30, 21))
@new x?.() class C4 {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>C4 : Symbol(C4, Decl(generalParsingOk.ts, 31, 18))
// - member decorators
class C5 { @x?.y m() {} }
>C5 : Symbol(C5, Decl(generalParsingOk.ts, 32, 22))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>m : Symbol(C5.m, Decl(generalParsingOk.ts, 34, 10))
class C6 { @x?.["y"] m() {} } // allowed as ?.[ is not ambiguous with computed property names
>C6 : Symbol(C6, Decl(generalParsingOk.ts, 34, 25))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>m : Symbol(C6.m, Decl(generalParsingOk.ts, 35, 10))
class C7 { @x?.() m() {} }
>C7 : Symbol(C7, Decl(generalParsingOk.ts, 35, 29))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>m : Symbol(C7.m, Decl(generalParsingOk.ts, 36, 10))
class C8 { @new x?.() m () {} }
>C8 : Symbol(C8, Decl(generalParsingOk.ts, 36, 26))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>m : Symbol(C8.m, Decl(generalParsingOk.ts, 37, 10))
// - parameter decorators
class C9 { m(@x?.y a) {} }
>C9 : Symbol(C9, Decl(generalParsingOk.ts, 37, 31))
>m : Symbol(C9.m, Decl(generalParsingOk.ts, 39, 10))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(generalParsingOk.ts, 39, 13))
class C10 { m(@x?.["y"] a) {} }
>C10 : Symbol(C10, Decl(generalParsingOk.ts, 39, 26))
>m : Symbol(C10.m, Decl(generalParsingOk.ts, 40, 11))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(generalParsingOk.ts, 40, 14))
class C11 { m(@x?.() a) {} }
>C11 : Symbol(C11, Decl(generalParsingOk.ts, 40, 31))
>m : Symbol(C11.m, Decl(generalParsingOk.ts, 41, 11))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(generalParsingOk.ts, 41, 14))
class C12 { m(@new x?.() a) {} }
>C12 : Symbol(C12, Decl(generalParsingOk.ts, 41, 28))
>m : Symbol(C12.m, Decl(generalParsingOk.ts, 42, 11))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(generalParsingOk.ts, 42, 14))
// functions
// - parameters
void function (a = x?.y) {}
>a : Symbol(a, Decl(generalParsingOk.ts, 46, 15))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void function (a = x?.["y"]) {}
>a : Symbol(a, Decl(generalParsingOk.ts, 47, 15))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void function (a = x?.()) {}
>a : Symbol(a, Decl(generalParsingOk.ts, 48, 15))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void function (a = new x?.()) {}
>a : Symbol(a, Decl(generalParsingOk.ts, 49, 15))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// - binding elements
// - initializers
void function ({ a = x?.y }) {}
>a : Symbol(a, Decl(generalParsingOk.ts, 52, 16))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void function ({ a = x?.["y"] }) {}
>a : Symbol(a, Decl(generalParsingOk.ts, 53, 16))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void function ({ a = x?.() }) {}
>a : Symbol(a, Decl(generalParsingOk.ts, 54, 16))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void function ({ a = new x?.() }) {}
>a : Symbol(a, Decl(generalParsingOk.ts, 55, 16))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// - computed properties
void function ({ [x?.y]: a }) {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(generalParsingOk.ts, 57, 16))
void function ({ [x?.["y"]]: a }) {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(generalParsingOk.ts, 58, 16))
void function ({ [x?.()]: a }) {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(generalParsingOk.ts, 59, 16))
void function ({ [new x?.()]: a }) {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>a : Symbol(a, Decl(generalParsingOk.ts, 60, 16))
// arrow functions
// - parameters
((a = x?.y) => {});
>a : Symbol(a, Decl(generalParsingOk.ts, 64, 2))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
((a = x?.["y"]) => {});
>a : Symbol(a, Decl(generalParsingOk.ts, 65, 2))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
((a = x?.()) => {});
>a : Symbol(a, Decl(generalParsingOk.ts, 66, 2))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
((a = new x?.()) => {});
>a : Symbol(a, Decl(generalParsingOk.ts, 67, 2))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// - expression bodies
(() => x?.y);
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
(() => x?.["y"]);
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
(() => x?.());
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
(() => new x?.());
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// parenthesis
(x?.y);
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// comma
x?.y, f();
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>f : Symbol(f, Decl(declarations.d.ts, 2, 11))
f(), x?.y;
>f : Symbol(f, Decl(declarations.d.ts, 2, 11))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// conditional
x?.y ? 0 : 1
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
0 ? x?.y : 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
0 ? 1 : x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// binary
x?.y + 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y - 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y * 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y / 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y ** 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y % 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y ^ 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y & 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y | 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y << 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y >> 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y >>> 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y && 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y || 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y == 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y === 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y != 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y !== 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y < 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y <= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y > 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y >= 1;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 + x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 - x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 * x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 / x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 ** x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 % x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 ^ x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 & x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 | x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 << x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 >> x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 >>> x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 && x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 || x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 == x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 === x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 != x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 !== x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 < x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 <= x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 > x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
1 >= x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// prefix unary
+x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
-x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
!x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
~x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// unary
void x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
typeof x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void function * () { yield x?.y; }
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
void async function() { await x?.y; }
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// notnull
x?.y!.z;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// assertions
<string>x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
x?.y as string;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// array literals
[x?.y];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
[, x?.y];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
[...x?.y];
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// literals
1?.toString(); // no need for `..`
>1?.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
1.?.toString();
>1.?.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
.0?.toString();
>.0?.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
4e3?.toString();
>4e3?.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
1.e3?.toString();
>1.e3?.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
""?.toString();
>""?.toString : Symbol(String.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(String.toString, Decl(lib.es5.d.ts, --, --))
''?.toString();
>''?.toString : Symbol(String.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(String.toString, Decl(lib.es5.d.ts, --, --))
``?.toString();
>``?.toString : Symbol(String.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(String.toString, Decl(lib.es5.d.ts, --, --))
/./?.toString();
>/./?.toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
/./g?.toString();
>/./g?.toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
true?.toString();
>true?.toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
false?.toString();
>false?.toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
>toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
// templates
`${x?.y}`;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// variables
var v = x?.y;
>v : Symbol(v, Decl(generalParsingOk.ts, 174, 3), Decl(generalParsingOk.ts, 175, 5), Decl(generalParsingOk.ts, 176, 5), Decl(generalParsingOk.ts, 177, 5), Decl(generalParsingOk.ts, 178, 5), Decl(generalParsingOk.ts, 179, 5))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
var [v] = x?.y;
>v : Symbol(v, Decl(generalParsingOk.ts, 174, 3), Decl(generalParsingOk.ts, 175, 5), Decl(generalParsingOk.ts, 176, 5), Decl(generalParsingOk.ts, 177, 5), Decl(generalParsingOk.ts, 178, 5), Decl(generalParsingOk.ts, 179, 5))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
var [v = x?.y] = [1];
>v : Symbol(v, Decl(generalParsingOk.ts, 174, 3), Decl(generalParsingOk.ts, 175, 5), Decl(generalParsingOk.ts, 176, 5), Decl(generalParsingOk.ts, 177, 5), Decl(generalParsingOk.ts, 178, 5), Decl(generalParsingOk.ts, 179, 5))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
var {v} = x?.y;
>v : Symbol(v, Decl(generalParsingOk.ts, 174, 3), Decl(generalParsingOk.ts, 175, 5), Decl(generalParsingOk.ts, 176, 5), Decl(generalParsingOk.ts, 177, 5), Decl(generalParsingOk.ts, 178, 5), Decl(generalParsingOk.ts, 179, 5))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
var {v = x?.y} = {v:1};
>v : Symbol(v, Decl(generalParsingOk.ts, 174, 3), Decl(generalParsingOk.ts, 175, 5), Decl(generalParsingOk.ts, 176, 5), Decl(generalParsingOk.ts, 177, 5), Decl(generalParsingOk.ts, 178, 5), Decl(generalParsingOk.ts, 179, 5))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>v : Symbol(v, Decl(generalParsingOk.ts, 178, 18))
var {[x?.y]: v} = null;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>v : Symbol(v, Decl(generalParsingOk.ts, 174, 3), Decl(generalParsingOk.ts, 175, 5), Decl(generalParsingOk.ts, 176, 5), Decl(generalParsingOk.ts, 177, 5), Decl(generalParsingOk.ts, 178, 5), Decl(generalParsingOk.ts, 179, 5))
// if/else if
if (x?.y) {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
if (1) {} else if (x?.y) {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// switch
switch (x?.y) {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
switch (1) { case x?.y: break; }
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// do/while
do {} while (x?.y)
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
while (x?.y) {}
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// for
for (x?.y; x?.y; x?.y);
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// for..in
for (x?.y in {});
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// for..of
for (x?.y of []);
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
// enums
enum E {
>E : Symbol(E, Decl(generalParsingOk.ts, 200, 17))
a = x?.y
>a : Symbol(E.a, Decl(generalParsingOk.ts, 203, 8))
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
}
=== tests/cases/conformance/emitter/esnext/safeNavigation/exportsOk.ts ===
export default x?.y;
>x : Symbol(x, Decl(declarations.d.ts, 0, 11))
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,383 @@
tests/cases/conformance/parser/ecmascriptnext/safeNavigation/metaPropertyError.ts(4,12): error TS1109: Expression expected.
tests/cases/conformance/parser/ecmascriptnext/safeNavigation/missingIdentifierError.ts(1,4): error TS1003: Identifier expected.
tests/cases/conformance/parser/ecmascriptnext/safeNavigation/spaceInTokenError.ts(1,4): error TS1109: Expression expected.
tests/cases/conformance/parser/ecmascriptnext/safeNavigation/spaceInTokenError.ts(1,6): error TS1005: ':' expected.
tests/cases/conformance/parser/ecmascriptnext/safeNavigation/superError.ts(4,14): error TS1012: Unexpected token.
tests/cases/conformance/parser/ecmascriptnext/safeNavigation/superProperty1Error.ts(4,14): error TS1005: '.' expected.
tests/cases/conformance/parser/ecmascriptnext/safeNavigation/superProperty2Error.ts(4,14): error TS1012: Unexpected token.
tests/cases/conformance/parser/ecmascriptnext/safeNavigation/taggedTemplateError.ts(2,4): error TS1003: Identifier expected.
tests/cases/conformance/parser/ecmascriptnext/safeNavigation/taggedTemplateError.ts(2,10): error TS2304: Cannot find name 'bar'.
==== tests/cases/conformance/parser/ecmascriptnext/safeNavigation/declarations.d.ts (0 errors) ====
declare var x: any;
declare var y: any;
declare var f: ({
(): void;
<T>(): void;
new (): any;
new <T>(): any;
}) | undefined;
declare var o: { y: typeof f; }
declare class Base { x: any; }
declare namespace M {
export class y {}
export class z<T> {}
}
==== tests/cases/conformance/parser/ecmascriptnext/safeNavigation/propertyAccessOk.ts (0 errors) ====
x.y
x?.y
x?.y.z
x.y?.z
x?.y?.z
==== tests/cases/conformance/parser/ecmascriptnext/safeNavigation/elementAccessOk.ts (0 errors) ====
x["y"]
x?.["y"]
x?.["y"]["z"]
x["y"]?.["z"]
x?.["y"]?.["z"]
==== tests/cases/conformance/parser/ecmascriptnext/safeNavigation/callExpressionOk.ts (0 errors) ====
x()
x?.()
x.y?.()
x["y"]?.()
f?.<number>()
o.y?.<number>()
o["y"]?.<number>()
==== tests/cases/conformance/parser/ecmascriptnext/safeNavigation/newExpressionOk.ts (0 errors) ====
new x()
new x.y?.()
new x["y"]?.()
new f?.<number>()
new o.y?.<number>()
new o["y"]?.<number>()
==== tests/cases/conformance/parser/ecmascriptnext/safeNavigation/mixedOk.ts (0 errors) ====
x?.y?.["z"]
x?.["y"]?.z
x?.y()
x?.y?.()
o?.y<number>()
o?.y?.<number>()
x?.["z"]()
x?.["z"]?.()
o?.["y"]<number>()
o?.["y"]?.<number>()
==== tests/cases/conformance/parser/ecmascriptnext/safeNavigation/mutationOk.ts (0 errors) ====
x?.y = 1
x?.y += 1;
x?.y -= 1;
x?.y *= 1;
x?.y /= 1;
x?.y %= 1;
x?.y **= 1;
x?.y |= 1;
x?.y &= 1;
x?.y ^= 1;
x?.y <<= 1;
x?.y >>= 1;
x?.y >>>= 1;
x?.y++;
x?.y--;
++x?.y;
--x?.y;
delete x?.y;
x?.["y"] = 1
x?.["y"] += 1;
x?.["y"] -= 1;
x?.["y"] *= 1;
x?.["y"] /= 1;
x?.["y"] %= 1;
x?.["y"] **= 1;
x?.["y"] |= 1;
x?.["y"] &= 1;
x?.["y"] ^= 1;
x?.["y"] <<= 1;
x?.["y"] >>= 1;
x?.["y"] >>>= 1;
x?.["y"]++;
x?.["y"]--;
++x?.["y"];
--x?.["y"];
delete x?.["y"];
==== tests/cases/conformance/parser/ecmascriptnext/safeNavigation/arrayAssignmentPatternOk.ts (0 errors) ====
[x?.y] = [1];
[x?.["y"]] = [1];
[...x?.y] = [1];
[...x?.["y"]] = [1];
==== tests/cases/conformance/parser/ecmascriptnext/safeNavigation/objectAssignmentPatternOk.ts (0 errors) ====
({ a: x?.y } = { a: 1 });
({ a: x?.["y"] } = { a: 1 });
==== tests/cases/conformance/parser/ecmascriptnext/safeNavigation/questionDotDigitIsConditionalOk.ts (0 errors) ====
x?.3:1;
==== tests/cases/conformance/parser/ecmascriptnext/safeNavigation/spaceInTokenError.ts (2 errors) ====
x? .y
~
!!! error TS1109: Expression expected.
!!! error TS1005: ':' expected.
==== tests/cases/conformance/parser/ecmascriptnext/safeNavigation/missingIdentifierError.ts (1 errors) ====
x?.
!!! error TS1003: Identifier expected.
==== tests/cases/conformance/parser/ecmascriptnext/safeNavigation/taggedTemplateError.ts (2 errors) ====
// not supported for tagged templates
x?.`foo${bar}`
~~~~~~
!!! error TS1003: Identifier expected.
~~~
!!! error TS2304: Cannot find name 'bar'.
==== tests/cases/conformance/parser/ecmascriptnext/safeNavigation/superError.ts (1 errors) ====
// not supported for super
void class extends Base {
constructor() {
super?.();
~~
!!! error TS1012: Unexpected token.
}
}
==== tests/cases/conformance/parser/ecmascriptnext/safeNavigation/superProperty1Error.ts (1 errors) ====
// not supported for super property
void class extends Base {
m() {
super?.x;
~~
!!! error TS1005: '.' expected.
}
}
==== tests/cases/conformance/parser/ecmascriptnext/safeNavigation/superProperty2Error.ts (1 errors) ====
// not supported for super property
void class extends Base {
m() {
super?.["x"];
~~
!!! error TS1012: Unexpected token.
}
}
==== tests/cases/conformance/parser/ecmascriptnext/safeNavigation/superPropertyInvocationOk.ts (0 errors) ====
// supported for invocation of super property
void class extends Base {
m() {
super.x?.();
super["x"]?.();
}
}
==== tests/cases/conformance/parser/ecmascriptnext/safeNavigation/metaPropertyError.ts (1 errors) ====
// not supported for meta property
void class {
constructor() {
new?.target;
~~
!!! error TS1109: Expression expected.
}
}
==== tests/cases/conformance/parser/ecmascriptnext/safeNavigation/generalParsingOk.ts (0 errors) ====
// object literals
// - computed property names
void { [x?.y]: 1 }
void { [x?.["y"]]: 1 }
void { [x?.()]: 1 }
void { [new x?.()]: 1 }
// - property assignments
void { a: x?.y }
void { a: x?.["y"] }
void { a: x?.() }
void { a: new x?.() }
// classes
// - computed property names
// void class { [x?.y] = 1 } // legal parse, but causes a checker error
// void class { [x?.["y"]] = 1 } // legal parse, but causes a checker error
// void class { [x?.()] = 1 } // legal parse, but causes a checker error
// void class { [new f?.()] = 1 } // legal parse, but causes a checker error
void class { [Symbol?.toStringTag] = "" }
// - property declarations
void class { a = x?.y }
void class { a = x?.["y"] }
void class { a = x?.() }
void class { a = new x?.() }
// - heritage clauses
void class extends M?.y {}
void class extends M?.["y"] {}
void class extends M?.z<number> {}
// - class decorators
@x?.y class C1 {}
@x?.["y"] class C2 {}
@x?.() class C3 {}
@new x?.() class C4 {}
// - member decorators
class C5 { @x?.y m() {} }
class C6 { @x?.["y"] m() {} } // allowed as ?.[ is not ambiguous with computed property names
class C7 { @x?.() m() {} }
class C8 { @new x?.() m () {} }
// - parameter decorators
class C9 { m(@x?.y a) {} }
class C10 { m(@x?.["y"] a) {} }
class C11 { m(@x?.() a) {} }
class C12 { m(@new x?.() a) {} }
// functions
// - parameters
void function (a = x?.y) {}
void function (a = x?.["y"]) {}
void function (a = x?.()) {}
void function (a = new x?.()) {}
// - binding elements
// - initializers
void function ({ a = x?.y }) {}
void function ({ a = x?.["y"] }) {}
void function ({ a = x?.() }) {}
void function ({ a = new x?.() }) {}
// - computed properties
void function ({ [x?.y]: a }) {}
void function ({ [x?.["y"]]: a }) {}
void function ({ [x?.()]: a }) {}
void function ({ [new x?.()]: a }) {}
// arrow functions
// - parameters
((a = x?.y) => {});
((a = x?.["y"]) => {});
((a = x?.()) => {});
((a = new x?.()) => {});
// - expression bodies
(() => x?.y);
(() => x?.["y"]);
(() => x?.());
(() => new x?.());
// parenthesis
(x?.y);
// comma
x?.y, f();
f(), x?.y;
// conditional
x?.y ? 0 : 1
0 ? x?.y : 1;
0 ? 1 : x?.y;
// binary
x?.y + 1;
x?.y - 1;
x?.y * 1;
x?.y / 1;
x?.y ** 1;
x?.y % 1;
x?.y ^ 1;
x?.y & 1;
x?.y | 1;
x?.y << 1;
x?.y >> 1;
x?.y >>> 1;
x?.y && 1;
x?.y || 1;
x?.y == 1;
x?.y === 1;
x?.y != 1;
x?.y !== 1;
x?.y < 1;
x?.y <= 1;
x?.y > 1;
x?.y >= 1;
1 + x?.y;
1 - x?.y;
1 * x?.y;
1 / x?.y;
1 ** x?.y;
1 % x?.y;
1 ^ x?.y;
1 & x?.y;
1 | x?.y;
1 << x?.y;
1 >> x?.y;
1 >>> x?.y;
1 && x?.y;
1 || x?.y;
1 == x?.y;
1 === x?.y;
1 != x?.y;
1 !== x?.y;
1 < x?.y;
1 <= x?.y;
1 > x?.y;
1 >= x?.y;
// prefix unary
+x?.y;
-x?.y;
!x?.y;
~x?.y;
// unary
void x?.y;
typeof x?.y;
void function * () { yield x?.y; }
void async function() { await x?.y; }
// notnull
x?.y!.z;
// assertions
<string>x?.y;
x?.y as string;
// array literals
[x?.y];
[, x?.y];
[...x?.y];
// literals
1?.toString(); // no need for `..`
1.?.toString();
.0?.toString();
4e3?.toString();
1.e3?.toString();
""?.toString();
''?.toString();
``?.toString();
/./?.toString();
/./g?.toString();
true?.toString();
false?.toString();
// templates
`${x?.y}`;
// variables
var v = x?.y;
var [v] = x?.y;
var [v = x?.y] = [1];
var {v} = x?.y;
var {v = x?.y} = {v:1};
var {[x?.y]: v} = null;
// if/else if
if (x?.y) {}
if (1) {} else if (x?.y) {}
// switch
switch (x?.y) {}
switch (1) { case x?.y: break; }
// do/while
do {} while (x?.y)
while (x?.y) {}
// for
for (x?.y; x?.y; x?.y);
// for..in
for (x?.y in {});
// for..of
for (x?.y of []);
// enums
enum E {
a = x?.y
}
==== tests/cases/conformance/parser/ecmascriptnext/safeNavigation/exportsOk.ts (0 errors) ====
export default x?.y;
@@ -0,0 +1,144 @@
=== tests/cases/conformance/types/safeNavigation/types.safeNavigation.esnext.1.ts ===
declare const x1: (() => number) | undefined | null;
>x1 : Symbol(x1, Decl(types.safeNavigation.esnext.1.ts, 0, 13))
declare const x2: { y: (() => number) | undefined | null; };
>x2 : Symbol(x2, Decl(types.safeNavigation.esnext.1.ts, 1, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 1, 19))
declare const x3: { y: (() => number) | undefined | null; } | undefined | null;
>x3 : Symbol(x3, Decl(types.safeNavigation.esnext.1.ts, 2, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 2, 19))
declare const x4: { y: { z: (() => number) | undefined | null; } };
>x4 : Symbol(x4, Decl(types.safeNavigation.esnext.1.ts, 3, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 3, 19))
>z : Symbol(z, Decl(types.safeNavigation.esnext.1.ts, 3, 24))
declare const x5: { y: { z: (() => number) | undefined | null; } | undefined | null } | undefined | null;
>x5 : Symbol(x5, Decl(types.safeNavigation.esnext.1.ts, 4, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 4, 19))
>z : Symbol(z, Decl(types.safeNavigation.esnext.1.ts, 4, 24))
declare const x6: { y: number } | undefined | null;
>x6 : Symbol(x6, Decl(types.safeNavigation.esnext.1.ts, 5, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 5, 19))
declare const x7: { y: any };
>x7 : Symbol(x7, Decl(types.safeNavigation.esnext.1.ts, 6, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 6, 19))
declare const x8: { y: { z: number } | undefined | null } | undefined | null;
>x8 : Symbol(x8, Decl(types.safeNavigation.esnext.1.ts, 7, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 7, 19))
>z : Symbol(z, Decl(types.safeNavigation.esnext.1.ts, 7, 24))
declare const y: "y";
>y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 8, 13))
declare const z: "z";
>z : Symbol(z, Decl(types.safeNavigation.esnext.1.ts, 9, 13))
x1?.();
>x1 : Symbol(x1, Decl(types.safeNavigation.esnext.1.ts, 0, 13))
(x1)?.();
>x1 : Symbol(x1, Decl(types.safeNavigation.esnext.1.ts, 0, 13))
x2.y?.();
>x2.y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 1, 19))
>x2 : Symbol(x2, Decl(types.safeNavigation.esnext.1.ts, 1, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 1, 19))
x2[y]?.();
>x2 : Symbol(x2, Decl(types.safeNavigation.esnext.1.ts, 1, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 8, 13))
(x2.y)?.();
>x2.y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 1, 19))
>x2 : Symbol(x2, Decl(types.safeNavigation.esnext.1.ts, 1, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 1, 19))
(x2[y])?.();
>x2 : Symbol(x2, Decl(types.safeNavigation.esnext.1.ts, 1, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 8, 13))
x3?.y?.();
>x3?.y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 2, 19))
>x3 : Symbol(x3, Decl(types.safeNavigation.esnext.1.ts, 2, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 2, 19))
x3?.[y]?.();
>x3 : Symbol(x3, Decl(types.safeNavigation.esnext.1.ts, 2, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 8, 13))
x4.y.z?.();
>x4.y.z : Symbol(z, Decl(types.safeNavigation.esnext.1.ts, 3, 24))
>x4.y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 3, 19))
>x4 : Symbol(x4, Decl(types.safeNavigation.esnext.1.ts, 3, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 3, 19))
>z : Symbol(z, Decl(types.safeNavigation.esnext.1.ts, 3, 24))
x4.y[z]?.();
>x4.y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 3, 19))
>x4 : Symbol(x4, Decl(types.safeNavigation.esnext.1.ts, 3, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 3, 19))
>z : Symbol(z, Decl(types.safeNavigation.esnext.1.ts, 9, 13))
(x4.y.z)?.();
>x4.y.z : Symbol(z, Decl(types.safeNavigation.esnext.1.ts, 3, 24))
>x4.y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 3, 19))
>x4 : Symbol(x4, Decl(types.safeNavigation.esnext.1.ts, 3, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 3, 19))
>z : Symbol(z, Decl(types.safeNavigation.esnext.1.ts, 3, 24))
(x4.y[z])?.();
>x4.y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 3, 19))
>x4 : Symbol(x4, Decl(types.safeNavigation.esnext.1.ts, 3, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 3, 19))
>z : Symbol(z, Decl(types.safeNavigation.esnext.1.ts, 9, 13))
x5?.y?.z?.();
>x5?.y?.z : Symbol(z, Decl(types.safeNavigation.esnext.1.ts, 4, 24))
>x5?.y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 4, 19))
>x5 : Symbol(x5, Decl(types.safeNavigation.esnext.1.ts, 4, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 4, 19))
>z : Symbol(z, Decl(types.safeNavigation.esnext.1.ts, 4, 24))
x5?.y?.z;
>x5?.y?.z : Symbol(z, Decl(types.safeNavigation.esnext.1.ts, 4, 24))
>x5?.y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 4, 19))
>x5 : Symbol(x5, Decl(types.safeNavigation.esnext.1.ts, 4, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 4, 19))
>z : Symbol(z, Decl(types.safeNavigation.esnext.1.ts, 4, 24))
x5?.[y]?.[z];
>x5 : Symbol(x5, Decl(types.safeNavigation.esnext.1.ts, 4, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 8, 13))
>z : Symbol(z, Decl(types.safeNavigation.esnext.1.ts, 9, 13))
x6?.y = 1;
>x6?.y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 5, 19))
>x6 : Symbol(x6, Decl(types.safeNavigation.esnext.1.ts, 5, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 5, 19))
x6?.y += 1;
>x6?.y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 5, 19))
>x6 : Symbol(x6, Decl(types.safeNavigation.esnext.1.ts, 5, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 5, 19))
x6?.y *= 1;
>x6?.y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 5, 19))
>x6 : Symbol(x6, Decl(types.safeNavigation.esnext.1.ts, 5, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 5, 19))
x6?.y++;
>x6?.y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 5, 19))
>x6 : Symbol(x6, Decl(types.safeNavigation.esnext.1.ts, 5, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 5, 19))
++x6?.y;
>x6?.y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 5, 19))
>x6 : Symbol(x6, Decl(types.safeNavigation.esnext.1.ts, 5, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.1.ts, 5, 19))
@@ -0,0 +1,188 @@
=== tests/cases/conformance/types/safeNavigation/types.safeNavigation.esnext.1.ts ===
declare const x1: (() => number) | undefined | null;
>x1 : () => number
>null : null
declare const x2: { y: (() => number) | undefined | null; };
>x2 : { y: () => number; }
>y : () => number
>null : null
declare const x3: { y: (() => number) | undefined | null; } | undefined | null;
>x3 : { y: () => number; }
>y : () => number
>null : null
>null : null
declare const x4: { y: { z: (() => number) | undefined | null; } };
>x4 : { y: { z: () => number; }; }
>y : { z: () => number; }
>z : () => number
>null : null
declare const x5: { y: { z: (() => number) | undefined | null; } | undefined | null } | undefined | null;
>x5 : { y: { z: () => number; }; }
>y : { z: () => number; }
>z : () => number
>null : null
>null : null
>null : null
declare const x6: { y: number } | undefined | null;
>x6 : { y: number; }
>y : number
>null : null
declare const x7: { y: any };
>x7 : { y: any; }
>y : any
declare const x8: { y: { z: number } | undefined | null } | undefined | null;
>x8 : { y: { z: number; }; }
>y : { z: number; }
>z : number
>null : null
>null : null
declare const y: "y";
>y : "y"
declare const z: "z";
>z : "z"
x1?.();
>x1?.() : number
>x1 : () => number
(x1)?.();
>(x1)?.() : number
>(x1) : () => number
>x1 : () => number
x2.y?.();
>x2.y?.() : number
>x2.y : () => number
>x2 : { y: () => number; }
>y : () => number
x2[y]?.();
>x2[y]?.() : number
>x2[y] : () => number
>x2 : { y: () => number; }
>y : "y"
(x2.y)?.();
>(x2.y)?.() : number
>(x2.y) : () => number
>x2.y : () => number
>x2 : { y: () => number; }
>y : () => number
(x2[y])?.();
>(x2[y])?.() : number
>(x2[y]) : () => number
>x2[y] : () => number
>x2 : { y: () => number; }
>y : "y"
x3?.y?.();
>x3?.y?.() : number
>x3?.y : () => number
>x3 : { y: () => number; }
>y : () => number
x3?.[y]?.();
>x3?.[y]?.() : number
>x3?.[y] : () => number
>x3 : { y: () => number; }
>y : "y"
x4.y.z?.();
>x4.y.z?.() : number
>x4.y.z : () => number
>x4.y : { z: () => number; }
>x4 : { y: { z: () => number; }; }
>y : { z: () => number; }
>z : () => number
x4.y[z]?.();
>x4.y[z]?.() : number
>x4.y[z] : () => number
>x4.y : { z: () => number; }
>x4 : { y: { z: () => number; }; }
>y : { z: () => number; }
>z : "z"
(x4.y.z)?.();
>(x4.y.z)?.() : number
>(x4.y.z) : () => number
>x4.y.z : () => number
>x4.y : { z: () => number; }
>x4 : { y: { z: () => number; }; }
>y : { z: () => number; }
>z : () => number
(x4.y[z])?.();
>(x4.y[z])?.() : number
>(x4.y[z]) : () => number
>x4.y[z] : () => number
>x4.y : { z: () => number; }
>x4 : { y: { z: () => number; }; }
>y : { z: () => number; }
>z : "z"
x5?.y?.z?.();
>x5?.y?.z?.() : number
>x5?.y?.z : () => number
>x5?.y : { z: () => number; }
>x5 : { y: { z: () => number; }; }
>y : { z: () => number; }
>z : () => number
x5?.y?.z;
>x5?.y?.z : () => number
>x5?.y : { z: () => number; }
>x5 : { y: { z: () => number; }; }
>y : { z: () => number; }
>z : () => number
x5?.[y]?.[z];
>x5?.[y]?.[z] : () => number
>x5?.[y] : { z: () => number; }
>x5 : { y: { z: () => number; }; }
>y : "y"
>z : "z"
x6?.y = 1;
>x6?.y = 1 : 1
>x6?.y : number
>x6 : { y: number; }
>y : number
>1 : 1
x6?.y += 1;
>x6?.y += 1 : number
>x6?.y : number
>x6 : { y: number; }
>y : number
>1 : 1
x6?.y *= 1;
>x6?.y *= 1 : number
>x6?.y : number
>x6 : { y: number; }
>y : number
>1 : 1
x6?.y++;
>x6?.y++ : number
>x6?.y : number
>x6 : { y: number; }
>y : number
++x6?.y;
>++x6?.y : number
>x6?.y : number
>x6 : { y: number; }
>y : number
@@ -0,0 +1,164 @@
=== tests/cases/conformance/types/safeNavigation/types.safeNavigation.esnext.2.ts ===
declare const x1: (() => number) | undefined | null;
>x1 : Symbol(x1, Decl(types.safeNavigation.esnext.2.ts, 0, 13))
declare const x2: { y: (() => number) | undefined | null; };
>x2 : Symbol(x2, Decl(types.safeNavigation.esnext.2.ts, 1, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 1, 19))
declare const x3: { y: (() => number) | undefined | null; } | undefined | null;
>x3 : Symbol(x3, Decl(types.safeNavigation.esnext.2.ts, 2, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 2, 19))
declare const x4: { y: { z: (() => number) | undefined | null; } };
>x4 : Symbol(x4, Decl(types.safeNavigation.esnext.2.ts, 3, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 3, 19))
>z : Symbol(z, Decl(types.safeNavigation.esnext.2.ts, 3, 24))
declare const x5: { y: { z: (() => number) | undefined | null; } | undefined | null } | undefined | null;
>x5 : Symbol(x5, Decl(types.safeNavigation.esnext.2.ts, 4, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 4, 19))
>z : Symbol(z, Decl(types.safeNavigation.esnext.2.ts, 4, 24))
declare const x6: { y: number } | undefined | null;
>x6 : Symbol(x6, Decl(types.safeNavigation.esnext.2.ts, 5, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 5, 19))
declare const x7: { y: any };
>x7 : Symbol(x7, Decl(types.safeNavigation.esnext.2.ts, 6, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 6, 19))
declare const x8: { y: { z: number } | undefined | null } | undefined | null;
>x8 : Symbol(x8, Decl(types.safeNavigation.esnext.2.ts, 7, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 7, 19))
>z : Symbol(z, Decl(types.safeNavigation.esnext.2.ts, 7, 24))
declare const y: "y";
>y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 8, 13))
declare const z: "z";
>z : Symbol(z, Decl(types.safeNavigation.esnext.2.ts, 9, 13))
const a1 = x1?.();
>a1 : Symbol(a1, Decl(types.safeNavigation.esnext.2.ts, 11, 5))
>x1 : Symbol(x1, Decl(types.safeNavigation.esnext.2.ts, 0, 13))
const a2 = (x1)?.();
>a2 : Symbol(a2, Decl(types.safeNavigation.esnext.2.ts, 12, 5))
>x1 : Symbol(x1, Decl(types.safeNavigation.esnext.2.ts, 0, 13))
const a3 = x2.y?.();
>a3 : Symbol(a3, Decl(types.safeNavigation.esnext.2.ts, 14, 5))
>x2.y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 1, 19))
>x2 : Symbol(x2, Decl(types.safeNavigation.esnext.2.ts, 1, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 1, 19))
const a4 = x2[y]?.();
>a4 : Symbol(a4, Decl(types.safeNavigation.esnext.2.ts, 15, 5))
>x2 : Symbol(x2, Decl(types.safeNavigation.esnext.2.ts, 1, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 8, 13))
const a5 = (x2.y)?.();
>a5 : Symbol(a5, Decl(types.safeNavigation.esnext.2.ts, 16, 5))
>x2.y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 1, 19))
>x2 : Symbol(x2, Decl(types.safeNavigation.esnext.2.ts, 1, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 1, 19))
const a6 = (x2[y])?.();
>a6 : Symbol(a6, Decl(types.safeNavigation.esnext.2.ts, 17, 5))
>x2 : Symbol(x2, Decl(types.safeNavigation.esnext.2.ts, 1, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 8, 13))
const a7 = x3?.y?.();
>a7 : Symbol(a7, Decl(types.safeNavigation.esnext.2.ts, 18, 5))
>x3?.y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 2, 19))
>x3 : Symbol(x3, Decl(types.safeNavigation.esnext.2.ts, 2, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 2, 19))
const a8 = x3?.[y]?.();
>a8 : Symbol(a8, Decl(types.safeNavigation.esnext.2.ts, 19, 5))
>x3 : Symbol(x3, Decl(types.safeNavigation.esnext.2.ts, 2, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 8, 13))
const a9 = x4.y.z?.();
>a9 : Symbol(a9, Decl(types.safeNavigation.esnext.2.ts, 21, 5))
>x4.y.z : Symbol(z, Decl(types.safeNavigation.esnext.2.ts, 3, 24))
>x4.y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 3, 19))
>x4 : Symbol(x4, Decl(types.safeNavigation.esnext.2.ts, 3, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 3, 19))
>z : Symbol(z, Decl(types.safeNavigation.esnext.2.ts, 3, 24))
const a10 = x4.y[z]?.();
>a10 : Symbol(a10, Decl(types.safeNavigation.esnext.2.ts, 22, 5))
>x4.y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 3, 19))
>x4 : Symbol(x4, Decl(types.safeNavigation.esnext.2.ts, 3, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 3, 19))
>z : Symbol(z, Decl(types.safeNavigation.esnext.2.ts, 9, 13))
const a11 = (x4.y.z)?.();
>a11 : Symbol(a11, Decl(types.safeNavigation.esnext.2.ts, 23, 5))
>x4.y.z : Symbol(z, Decl(types.safeNavigation.esnext.2.ts, 3, 24))
>x4.y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 3, 19))
>x4 : Symbol(x4, Decl(types.safeNavigation.esnext.2.ts, 3, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 3, 19))
>z : Symbol(z, Decl(types.safeNavigation.esnext.2.ts, 3, 24))
const a12 = (x4.y[z])?.();
>a12 : Symbol(a12, Decl(types.safeNavigation.esnext.2.ts, 24, 5))
>x4.y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 3, 19))
>x4 : Symbol(x4, Decl(types.safeNavigation.esnext.2.ts, 3, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 3, 19))
>z : Symbol(z, Decl(types.safeNavigation.esnext.2.ts, 9, 13))
const a13 = x5?.y?.z?.();
>a13 : Symbol(a13, Decl(types.safeNavigation.esnext.2.ts, 25, 5))
>x5?.y?.z : Symbol(z, Decl(types.safeNavigation.esnext.2.ts, 4, 24))
>x5?.y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 4, 19))
>x5 : Symbol(x5, Decl(types.safeNavigation.esnext.2.ts, 4, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 4, 19))
>z : Symbol(z, Decl(types.safeNavigation.esnext.2.ts, 4, 24))
const a14 = x5?.y?.z;
>a14 : Symbol(a14, Decl(types.safeNavigation.esnext.2.ts, 26, 5))
>x5?.y?.z : Symbol(z, Decl(types.safeNavigation.esnext.2.ts, 4, 24))
>x5?.y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 4, 19))
>x5 : Symbol(x5, Decl(types.safeNavigation.esnext.2.ts, 4, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 4, 19))
>z : Symbol(z, Decl(types.safeNavigation.esnext.2.ts, 4, 24))
const a15 = x5?.[y]?.[z];
>a15 : Symbol(a15, Decl(types.safeNavigation.esnext.2.ts, 27, 5))
>x5 : Symbol(x5, Decl(types.safeNavigation.esnext.2.ts, 4, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 8, 13))
>z : Symbol(z, Decl(types.safeNavigation.esnext.2.ts, 9, 13))
const a16 = x6?.y = 1;
>a16 : Symbol(a16, Decl(types.safeNavigation.esnext.2.ts, 29, 5))
>x6?.y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 5, 19))
>x6 : Symbol(x6, Decl(types.safeNavigation.esnext.2.ts, 5, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 5, 19))
const a17 = x6?.y += 1;
>a17 : Symbol(a17, Decl(types.safeNavigation.esnext.2.ts, 30, 5))
>x6?.y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 5, 19))
>x6 : Symbol(x6, Decl(types.safeNavigation.esnext.2.ts, 5, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 5, 19))
const a17a = x6?.y *= 1;
>a17a : Symbol(a17a, Decl(types.safeNavigation.esnext.2.ts, 31, 5))
>x6?.y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 5, 19))
>x6 : Symbol(x6, Decl(types.safeNavigation.esnext.2.ts, 5, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 5, 19))
const a18 = x6?.y++;
>a18 : Symbol(a18, Decl(types.safeNavigation.esnext.2.ts, 32, 5))
>x6?.y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 5, 19))
>x6 : Symbol(x6, Decl(types.safeNavigation.esnext.2.ts, 5, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 5, 19))
const a19 = ++x6?.y;
>a19 : Symbol(a19, Decl(types.safeNavigation.esnext.2.ts, 33, 5))
>x6?.y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 5, 19))
>x6 : Symbol(x6, Decl(types.safeNavigation.esnext.2.ts, 5, 13))
>y : Symbol(y, Decl(types.safeNavigation.esnext.2.ts, 5, 19))
@@ -0,0 +1,208 @@
=== tests/cases/conformance/types/safeNavigation/types.safeNavigation.esnext.2.ts ===
declare const x1: (() => number) | undefined | null;
>x1 : (() => number) | null | undefined
>null : null
declare const x2: { y: (() => number) | undefined | null; };
>x2 : { y: (() => number) | null | undefined; }
>y : (() => number) | null | undefined
>null : null
declare const x3: { y: (() => number) | undefined | null; } | undefined | null;
>x3 : { y: (() => number) | null | undefined; } | null | undefined
>y : (() => number) | null | undefined
>null : null
>null : null
declare const x4: { y: { z: (() => number) | undefined | null; } };
>x4 : { y: { z: (() => number) | null | undefined; }; }
>y : { z: (() => number) | null | undefined; }
>z : (() => number) | null | undefined
>null : null
declare const x5: { y: { z: (() => number) | undefined | null; } | undefined | null } | undefined | null;
>x5 : { y: { z: (() => number) | null | undefined; } | null | undefined; } | null | undefined
>y : { z: (() => number) | null | undefined; } | null | undefined
>z : (() => number) | null | undefined
>null : null
>null : null
>null : null
declare const x6: { y: number } | undefined | null;
>x6 : { y: number; } | null | undefined
>y : number
>null : null
declare const x7: { y: any };
>x7 : { y: any; }
>y : any
declare const x8: { y: { z: number } | undefined | null } | undefined | null;
>x8 : { y: { z: number; } | null | undefined; } | null | undefined
>y : { z: number; } | null | undefined
>z : number
>null : null
>null : null
declare const y: "y";
>y : "y"
declare const z: "z";
>z : "z"
const a1 = x1?.();
>a1 : number | undefined
>x1?.() : number
>x1 : (() => number) | null | undefined
const a2 = (x1)?.();
>a2 : number | undefined
>(x1)?.() : number
>(x1) : (() => number) | null | undefined
>x1 : (() => number) | null | undefined
const a3 = x2.y?.();
>a3 : number | undefined
>x2.y?.() : number
>x2.y : (() => number) | null | undefined
>x2 : { y: (() => number) | null | undefined; }
>y : (() => number) | null | undefined
const a4 = x2[y]?.();
>a4 : number | undefined
>x2[y]?.() : number
>x2[y] : (() => number) | null | undefined
>x2 : { y: (() => number) | null | undefined; }
>y : "y"
const a5 = (x2.y)?.();
>a5 : number | undefined
>(x2.y)?.() : number
>(x2.y) : (() => number) | null | undefined
>x2.y : (() => number) | null | undefined
>x2 : { y: (() => number) | null | undefined; }
>y : (() => number) | null | undefined
const a6 = (x2[y])?.();
>a6 : number | undefined
>(x2[y])?.() : number
>(x2[y]) : (() => number) | null | undefined
>x2[y] : (() => number) | null | undefined
>x2 : { y: (() => number) | null | undefined; }
>y : "y"
const a7 = x3?.y?.();
>a7 : number | undefined
>x3?.y?.() : number
>x3?.y : (() => number) | null | undefined
>x3 : { y: (() => number) | null | undefined; } | null | undefined
>y : (() => number) | null | undefined
const a8 = x3?.[y]?.();
>a8 : number | undefined
>x3?.[y]?.() : number
>x3?.[y] : (() => number) | null | undefined
>x3 : { y: (() => number) | null | undefined; } | null | undefined
>y : "y"
const a9 = x4.y.z?.();
>a9 : number | undefined
>x4.y.z?.() : number
>x4.y.z : (() => number) | null | undefined
>x4.y : { z: (() => number) | null | undefined; }
>x4 : { y: { z: (() => number) | null | undefined; }; }
>y : { z: (() => number) | null | undefined; }
>z : (() => number) | null | undefined
const a10 = x4.y[z]?.();
>a10 : number | undefined
>x4.y[z]?.() : number
>x4.y[z] : (() => number) | null | undefined
>x4.y : { z: (() => number) | null | undefined; }
>x4 : { y: { z: (() => number) | null | undefined; }; }
>y : { z: (() => number) | null | undefined; }
>z : "z"
const a11 = (x4.y.z)?.();
>a11 : number | undefined
>(x4.y.z)?.() : number
>(x4.y.z) : (() => number) | null | undefined
>x4.y.z : (() => number) | null | undefined
>x4.y : { z: (() => number) | null | undefined; }
>x4 : { y: { z: (() => number) | null | undefined; }; }
>y : { z: (() => number) | null | undefined; }
>z : (() => number) | null | undefined
const a12 = (x4.y[z])?.();
>a12 : number | undefined
>(x4.y[z])?.() : number
>(x4.y[z]) : (() => number) | null | undefined
>x4.y[z] : (() => number) | null | undefined
>x4.y : { z: (() => number) | null | undefined; }
>x4 : { y: { z: (() => number) | null | undefined; }; }
>y : { z: (() => number) | null | undefined; }
>z : "z"
const a13 = x5?.y?.z?.();
>a13 : number | undefined
>x5?.y?.z?.() : number
>x5?.y?.z : (() => number) | null | undefined
>x5?.y : { z: (() => number) | null | undefined; } | null | undefined
>x5 : { y: { z: (() => number) | null | undefined; } | null | undefined; } | null | undefined
>y : { z: (() => number) | null | undefined; } | null | undefined
>z : (() => number) | null | undefined
const a14 = x5?.y?.z;
>a14 : (() => number) | null | undefined
>x5?.y?.z : (() => number) | null | undefined
>x5?.y : { z: (() => number) | null | undefined; } | null | undefined
>x5 : { y: { z: (() => number) | null | undefined; } | null | undefined; } | null | undefined
>y : { z: (() => number) | null | undefined; } | null | undefined
>z : (() => number) | null | undefined
const a15 = x5?.[y]?.[z];
>a15 : (() => number) | null | undefined
>x5?.[y]?.[z] : (() => number) | null | undefined
>x5?.[y] : { z: (() => number) | null | undefined; } | null | undefined
>x5 : { y: { z: (() => number) | null | undefined; } | null | undefined; } | null | undefined
>y : "y"
>z : "z"
const a16 = x6?.y = 1;
>a16 : 1
>x6?.y = 1 : 1
>x6?.y : number | undefined
>x6 : { y: number; } | null | undefined
>y : number | undefined
>1 : 1
const a17 = x6?.y += 1;
>a17 : number | undefined
>x6?.y += 1 : number | undefined
>x6?.y : number | undefined
>x6 : { y: number; } | null | undefined
>y : number | undefined
>1 : 1
const a17a = x6?.y *= 1;
>a17a : number | undefined
>x6?.y *= 1 : number | undefined
>x6?.y : number | undefined
>x6 : { y: number; } | null | undefined
>y : number | undefined
>1 : 1
const a18 = x6?.y++;
>a18 : number | undefined
>x6?.y++ : number | undefined
>x6?.y : number | undefined
>x6 : { y: number; } | null | undefined
>y : number | undefined
const a19 = ++x6?.y;
>a19 : number | undefined
>++x6?.y : number | undefined
>x6?.y : number | undefined
>x6 : { y: number; } | null | undefined
>y : number | undefined
@@ -0,0 +1,323 @@
// @target: es2015
// @lib: esnext
// @module: commonjs
// @experimentalDecorators: true
// @filename: declarations.d.ts
declare var x: any;
declare var y: any;
declare var f: ({
(): void;
<T>(): void;
new (): any;
new <T>(): any;
}) | undefined;
declare var o: { y: typeof f; }
declare class Base { x(): any; }
declare namespace M {
export class y {}
export class z<T> {}
}
// @filename: propertyAccessOk.ts
x.y
x?.y
x?.y.z
x.y?.z
x?.y?.z
// @filename: elementAccessOk.ts
x["y"]
x?.["y"]
x?.["y"]["z"]
x["y"]?.["z"]
x?.["y"]?.["z"]
// @filename: callExpressionOk.ts
x()
x?.()
x.y?.()
x["y"]?.()
f?.<number>()
o.y?.<number>()
o["y"]?.<number>()
// @filename: newExpressionOk.ts
new x()
new x.y?.()
new x["y"]?.()
new f?.<number>()
new o.y?.<number>()
new o["y"]?.<number>()
// @filename: mixedOk.ts
x?.y?.["z"]
x?.["y"]?.z
x?.y()
x?.y?.()
o?.y<number>()
o?.y?.<number>()
x?.["z"]()
x?.["z"]?.()
o?.["y"]<number>()
o?.["y"]?.<number>()
// @filename: mutationOk.ts
x?.y = 1
x?.y += 1;
x?.y -= 1;
x?.y *= 1;
x?.y /= 1;
x?.y %= 1;
x?.y **= 1;
x?.y |= 1;
x?.y &= 1;
x?.y ^= 1;
x?.y <<= 1;
x?.y >>= 1;
x?.y >>>= 1;
x?.y++;
x?.y--;
++x?.y;
--x?.y;
delete x?.y;
x?.["y"] = 1
x?.["y"] += 1;
x?.["y"] -= 1;
x?.["y"] *= 1;
x?.["y"] /= 1;
x?.["y"] %= 1;
x?.["y"] **= 1;
x?.["y"] |= 1;
x?.["y"] &= 1;
x?.["y"] ^= 1;
x?.["y"] <<= 1;
x?.["y"] >>= 1;
x?.["y"] >>>= 1;
x?.["y"]++;
x?.["y"]--;
++x?.["y"];
--x?.["y"];
delete x?.["y"];
// @filename: arrayAssignmentPatternOk.ts
[x?.y] = [1];
[x?.["y"]] = [1];
[...x?.y] = [1];
[...x?.["y"]] = [1];
// @filename: objectAssignmentPatternOk.ts
({ a: x?.y } = { a: 1 });
({ a: x?.["y"] } = { a: 1 });
// @filename: questionDotDigitIsConditionalOk.ts
x?.3:1;
// @filename: superPropertyInvocationOk.ts
// supported for invocation of super property
void class extends Base {
m() {
super.x?.();
super["x"]?.();
}
}
// @filename: generalParsingOk.ts
// object literals
// - computed property names
void { [x?.y]: 1 }
void { [x?.["y"]]: 1 }
void { [x?.()]: 1 }
void { [new x?.()]: 1 }
// - property assignments
void { a: x?.y }
void { a: x?.["y"] }
void { a: x?.() }
void { a: new x?.() }
// classes
// - computed property names
// void class { [x?.y] = 1 } // legal parse, but causes a checker error
// void class { [x?.["y"]] = 1 } // legal parse, but causes a checker error
// void class { [x?.()] = 1 } // legal parse, but causes a checker error
// void class { [new f?.()] = 1 } // legal parse, but causes a checker error
void class { [Symbol?.toStringTag] = "" }
// - property declarations
void class { a = x?.y }
void class { a = x?.["y"] }
void class { a = x?.() }
void class { a = new x?.() }
// - heritage clauses
void class extends M?.y {}
void class extends M?.["y"] {}
void class extends M?.z<number> {}
// - class decorators
@x?.y class C1 {}
@x?.["y"] class C2 {}
@x?.() class C3 {}
@new x?.() class C4 {}
// - member decorators
class C5 { @x?.y m() {} }
class C6 { @x?.["y"] m() {} } // allowed as ?.[ is not ambiguous with computed property names
class C7 { @x?.() m() {} }
class C8 { @new x?.() m () {} }
// - parameter decorators
class C9 { m(@x?.y a) {} }
class C10 { m(@x?.["y"] a) {} }
class C11 { m(@x?.() a) {} }
class C12 { m(@new x?.() a) {} }
// functions
// - parameters
void function (a = x?.y) {}
void function (a = x?.["y"]) {}
void function (a = x?.()) {}
void function (a = new x?.()) {}
// - binding elements
// - initializers
void function ({ a = x?.y }) {}
void function ({ a = x?.["y"] }) {}
void function ({ a = x?.() }) {}
void function ({ a = new x?.() }) {}
// - computed properties
void function ({ [x?.y]: a }) {}
void function ({ [x?.["y"]]: a }) {}
void function ({ [x?.()]: a }) {}
void function ({ [new x?.()]: a }) {}
// arrow functions
// - parameters
((a = x?.y) => {});
((a = x?.["y"]) => {});
((a = x?.()) => {});
((a = new x?.()) => {});
// - expression bodies
(() => x?.y);
(() => x?.["y"]);
(() => x?.());
(() => new x?.());
// parenthesis
(x?.y);
// comma
x?.y, f();
f(), x?.y;
// conditional
x?.y ? 0 : 1
0 ? x?.y : 1;
0 ? 1 : x?.y;
// binary
x?.y + 1;
x?.y - 1;
x?.y * 1;
x?.y / 1;
x?.y ** 1;
x?.y % 1;
x?.y ^ 1;
x?.y & 1;
x?.y | 1;
x?.y << 1;
x?.y >> 1;
x?.y >>> 1;
x?.y && 1;
x?.y || 1;
x?.y == 1;
x?.y === 1;
x?.y != 1;
x?.y !== 1;
x?.y < 1;
x?.y <= 1;
x?.y > 1;
x?.y >= 1;
1 + x?.y;
1 - x?.y;
1 * x?.y;
1 / x?.y;
1 ** x?.y;
1 % x?.y;
1 ^ x?.y;
1 & x?.y;
1 | x?.y;
1 << x?.y;
1 >> x?.y;
1 >>> x?.y;
1 && x?.y;
1 || x?.y;
1 == x?.y;
1 === x?.y;
1 != x?.y;
1 !== x?.y;
1 < x?.y;
1 <= x?.y;
1 > x?.y;
1 >= x?.y;
// prefix unary
+x?.y;
-x?.y;
!x?.y;
~x?.y;
// unary
void x?.y;
typeof x?.y;
void function * () { yield x?.y; }
void async function() { await x?.y; }
// notnull
x?.y!.z;
// assertions
<string>x?.y;
x?.y as string;
// array literals
[x?.y];
[, x?.y];
[...x?.y];
// literals
1?.toString(); // no need for `..`
1.?.toString();
.0?.toString();
4e3?.toString();
1.e3?.toString();
""?.toString();
''?.toString();
``?.toString();
/./?.toString();
/./g?.toString();
true?.toString();
false?.toString();
// templates
`${x?.y}`;
// variables
var v = x?.y;
var [v] = x?.y;
var [v = x?.y] = [1];
var {v} = x?.y;
var {v = x?.y} = {v:1};
var {[x?.y]: v} = null;
// if/else if
if (x?.y) {}
if (1) {} else if (x?.y) {}
// switch
switch (x?.y) {}
switch (1) { case x?.y: break; }
// do/while
do {} while (x?.y)
while (x?.y) {}
// for
for (x?.y; x?.y; x?.y);
// for..in
for (x?.y in {});
// for..of
for (x?.y of []);
// enums
enum E {
a = x?.y
}
// @filename: exportsOk.ts
export default x?.y;
@@ -0,0 +1,322 @@
// @target: es3
// @lib: esnext
// @module: commonjs
// @experimentalDecorators: true
// @filename: declarations.d.ts
declare var x: any;
declare var y: any;
declare var f: ({
(): void;
<T>(): void;
new (): any;
new <T>(): any;
}) | undefined;
declare var o: { y: typeof f; }
declare class Base { x(): any; }
declare namespace M {
export class y {}
export class z<T> {}
}
// @filename: propertyAccessOk.ts
x.y
x?.y
x?.y.z
x.y?.z
x?.y?.z
// @filename: elementAccessOk.ts
x["y"]
x?.["y"]
x?.["y"]["z"]
x["y"]?.["z"]
x?.["y"]?.["z"]
// @filename: callExpressionOk.ts
x()
x?.()
x.y?.()
x["y"]?.()
f?.<number>()
o.y?.<number>()
o["y"]?.<number>()
// @filename: newExpressionOk.ts
new x()
new x.y?.()
new x["y"]?.()
new f?.<number>()
new o.y?.<number>()
new o["y"]?.<number>()
// @filename: mixedOk.ts
x?.y?.["z"]
x?.["y"]?.z
x?.y()
x?.y?.()
o?.y<number>()
o?.y?.<number>()
x?.["z"]()
x?.["z"]?.()
o?.["y"]<number>()
o?.["y"]?.<number>()
// @filename: mutationOk.ts
x?.y = 1
x?.y += 1;
x?.y -= 1;
x?.y *= 1;
x?.y /= 1;
x?.y %= 1;
x?.y **= 1;
x?.y |= 1;
x?.y &= 1;
x?.y ^= 1;
x?.y <<= 1;
x?.y >>= 1;
x?.y >>>= 1;
x?.y++;
x?.y--;
++x?.y;
--x?.y;
delete x?.y;
x?.["y"] = 1
x?.["y"] += 1;
x?.["y"] -= 1;
x?.["y"] *= 1;
x?.["y"] /= 1;
x?.["y"] %= 1;
x?.["y"] **= 1;
x?.["y"] |= 1;
x?.["y"] &= 1;
x?.["y"] ^= 1;
x?.["y"] <<= 1;
x?.["y"] >>= 1;
x?.["y"] >>>= 1;
x?.["y"]++;
x?.["y"]--;
++x?.["y"];
--x?.["y"];
delete x?.["y"];
// @filename: arrayAssignmentPatternOk.ts
[x?.y] = [1];
[x?.["y"]] = [1];
[...x?.y] = [1];
[...x?.["y"]] = [1];
// @filename: objectAssignmentPatternOk.ts
({ a: x?.y } = { a: 1 });
({ a: x?.["y"] } = { a: 1 });
// @filename: questionDotDigitIsConditionalOk.ts
x?.3:1;
// @filename: superPropertyInvocationOk.ts
// supported for invocation of super property
void class extends Base {
m() {
super.x?.();
}
}
// @filename: generalParsingOk.ts
// object literals
// - computed property names
void { [x?.y]: 1 }
void { [x?.["y"]]: 1 }
void { [x?.()]: 1 }
void { [new x?.()]: 1 }
// - property assignments
void { a: x?.y }
void { a: x?.["y"] }
void { a: x?.() }
void { a: new x?.() }
// classes
// - computed property names
// void class { [x?.y] = 1 } // legal parse, but causes a checker error
// void class { [x?.["y"]] = 1 } // legal parse, but causes a checker error
// void class { [x?.()] = 1 } // legal parse, but causes a checker error
// void class { [new f?.()] = 1 } // legal parse, but causes a checker error
void class { [Symbol?.toStringTag] = "" }
// - property declarations
void class { a = x?.y }
void class { a = x?.["y"] }
void class { a = x?.() }
void class { a = new x?.() }
// - heritage clauses
void class extends M?.y {}
void class extends M?.["y"] {}
void class extends M?.z<number> {}
// - class decorators
@x?.y class C1 {}
@x?.["y"] class C2 {}
@x?.() class C3 {}
@new x?.() class C4 {}
// - member decorators
class C5 { @x?.y m() {} }
class C6 { @x?.["y"] m() {} } // allowed as ?.[ is not ambiguous with computed property names
class C7 { @x?.() m() {} }
class C8 { @new x?.() m () {} }
// - parameter decorators
class C9 { m(@x?.y a) {} }
class C10 { m(@x?.["y"] a) {} }
class C11 { m(@x?.() a) {} }
class C12 { m(@new x?.() a) {} }
// functions
// - parameters
void function (a = x?.y) {}
void function (a = x?.["y"]) {}
void function (a = x?.()) {}
void function (a = new x?.()) {}
// - binding elements
// - initializers
void function ({ a = x?.y }) {}
void function ({ a = x?.["y"] }) {}
void function ({ a = x?.() }) {}
void function ({ a = new x?.() }) {}
// - computed properties
void function ({ [x?.y]: a }) {}
void function ({ [x?.["y"]]: a }) {}
void function ({ [x?.()]: a }) {}
void function ({ [new x?.()]: a }) {}
// arrow functions
// - parameters
((a = x?.y) => {});
((a = x?.["y"]) => {});
((a = x?.()) => {});
((a = new x?.()) => {});
// - expression bodies
(() => x?.y);
(() => x?.["y"]);
(() => x?.());
(() => new x?.());
// parenthesis
(x?.y);
// comma
x?.y, f();
f(), x?.y;
// conditional
x?.y ? 0 : 1
0 ? x?.y : 1;
0 ? 1 : x?.y;
// binary
x?.y + 1;
x?.y - 1;
x?.y * 1;
x?.y / 1;
x?.y ** 1;
x?.y % 1;
x?.y ^ 1;
x?.y & 1;
x?.y | 1;
x?.y << 1;
x?.y >> 1;
x?.y >>> 1;
x?.y && 1;
x?.y || 1;
x?.y == 1;
x?.y === 1;
x?.y != 1;
x?.y !== 1;
x?.y < 1;
x?.y <= 1;
x?.y > 1;
x?.y >= 1;
1 + x?.y;
1 - x?.y;
1 * x?.y;
1 / x?.y;
1 ** x?.y;
1 % x?.y;
1 ^ x?.y;
1 & x?.y;
1 | x?.y;
1 << x?.y;
1 >> x?.y;
1 >>> x?.y;
1 && x?.y;
1 || x?.y;
1 == x?.y;
1 === x?.y;
1 != x?.y;
1 !== x?.y;
1 < x?.y;
1 <= x?.y;
1 > x?.y;
1 >= x?.y;
// prefix unary
+x?.y;
-x?.y;
!x?.y;
~x?.y;
// unary
void x?.y;
typeof x?.y;
void function * () { yield x?.y; }
void async function() { await x?.y; }
// notnull
x?.y!.z;
// assertions
<string>x?.y;
x?.y as string;
// array literals
[x?.y];
[, x?.y];
[...x?.y];
// literals
1?.toString(); // no need for `..`
1.?.toString();
.0?.toString();
4e3?.toString();
1.e3?.toString();
""?.toString();
''?.toString();
``?.toString();
/./?.toString();
/./g?.toString();
true?.toString();
false?.toString();
// templates
`${x?.y}`;
// variables
var v = x?.y;
var [v] = x?.y;
var [v = x?.y] = [1];
var {v} = x?.y;
var {v = x?.y} = {v:1};
var {[x?.y]: v} = null;
// if/else if
if (x?.y) {}
if (1) {} else if (x?.y) {}
// switch
switch (x?.y) {}
switch (1) { case x?.y: break; }
// do/while
do {} while (x?.y)
while (x?.y) {}
// for
for (x?.y; x?.y; x?.y);
// for..in
for (x?.y in {});
// for..of
for (x?.y of []);
// enums
enum E {
a = x?.y
}
// @filename: exportsOk.ts
export default x?.y;
@@ -0,0 +1,322 @@
// @target: es5
// @lib: esnext
// @module: commonjs
// @experimentalDecorators: true
// @filename: declarations.d.ts
declare var x: any;
declare var y: any;
declare var f: ({
(): void;
<T>(): void;
new (): any;
new <T>(): any;
}) | undefined;
declare var o: { y: typeof f; }
declare class Base { x(): any; }
declare namespace M {
export class y {}
export class z<T> {}
}
// @filename: propertyAccessOk.ts
x.y
x?.y
x?.y.z
x.y?.z
x?.y?.z
// @filename: elementAccessOk.ts
x["y"]
x?.["y"]
x?.["y"]["z"]
x["y"]?.["z"]
x?.["y"]?.["z"]
// @filename: callExpressionOk.ts
x()
x?.()
x.y?.()
x["y"]?.()
f?.<number>()
o.y?.<number>()
o["y"]?.<number>()
// @filename: newExpressionOk.ts
new x()
new x.y?.()
new x["y"]?.()
new f?.<number>()
new o.y?.<number>()
new o["y"]?.<number>()
// @filename: mixedOk.ts
x?.y?.["z"]
x?.["y"]?.z
x?.y()
x?.y?.()
o?.y<number>()
o?.y?.<number>()
x?.["z"]()
x?.["z"]?.()
o?.["y"]<number>()
o?.["y"]?.<number>()
// @filename: mutationOk.ts
x?.y = 1
x?.y += 1;
x?.y -= 1;
x?.y *= 1;
x?.y /= 1;
x?.y %= 1;
x?.y **= 1;
x?.y |= 1;
x?.y &= 1;
x?.y ^= 1;
x?.y <<= 1;
x?.y >>= 1;
x?.y >>>= 1;
x?.y++;
x?.y--;
++x?.y;
--x?.y;
delete x?.y;
x?.["y"] = 1
x?.["y"] += 1;
x?.["y"] -= 1;
x?.["y"] *= 1;
x?.["y"] /= 1;
x?.["y"] %= 1;
x?.["y"] **= 1;
x?.["y"] |= 1;
x?.["y"] &= 1;
x?.["y"] ^= 1;
x?.["y"] <<= 1;
x?.["y"] >>= 1;
x?.["y"] >>>= 1;
x?.["y"]++;
x?.["y"]--;
++x?.["y"];
--x?.["y"];
delete x?.["y"];
// @filename: arrayAssignmentPatternOk.ts
[x?.y] = [1];
[x?.["y"]] = [1];
[...x?.y] = [1];
[...x?.["y"]] = [1];
// @filename: objectAssignmentPatternOk.ts
({ a: x?.y } = { a: 1 });
({ a: x?.["y"] } = { a: 1 });
// @filename: questionDotDigitIsConditionalOk.ts
x?.3:1;
// @filename: superPropertyInvocationOk.ts
// supported for invocation of super property
void class extends Base {
m() {
super.x?.();
}
}
// @filename: generalParsingOk.ts
// object literals
// - computed property names
void { [x?.y]: 1 }
void { [x?.["y"]]: 1 }
void { [x?.()]: 1 }
void { [new x?.()]: 1 }
// - property assignments
void { a: x?.y }
void { a: x?.["y"] }
void { a: x?.() }
void { a: new x?.() }
// classes
// - computed property names
// void class { [x?.y] = 1 } // legal parse, but causes a checker error
// void class { [x?.["y"]] = 1 } // legal parse, but causes a checker error
// void class { [x?.()] = 1 } // legal parse, but causes a checker error
// void class { [new f?.()] = 1 } // legal parse, but causes a checker error
void class { [Symbol?.toStringTag] = "" }
// - property declarations
void class { a = x?.y }
void class { a = x?.["y"] }
void class { a = x?.() }
void class { a = new x?.() }
// - heritage clauses
void class extends M?.y {}
void class extends M?.["y"] {}
void class extends M?.z<number> {}
// - class decorators
@x?.y class C1 {}
@x?.["y"] class C2 {}
@x?.() class C3 {}
@new x?.() class C4 {}
// - member decorators
class C5 { @x?.y m() {} }
class C6 { @x?.["y"] m() {} } // allowed as ?.[ is not ambiguous with computed property names
class C7 { @x?.() m() {} }
class C8 { @new x?.() m () {} }
// - parameter decorators
class C9 { m(@x?.y a) {} }
class C10 { m(@x?.["y"] a) {} }
class C11 { m(@x?.() a) {} }
class C12 { m(@new x?.() a) {} }
// functions
// - parameters
void function (a = x?.y) {}
void function (a = x?.["y"]) {}
void function (a = x?.()) {}
void function (a = new x?.()) {}
// - binding elements
// - initializers
void function ({ a = x?.y }) {}
void function ({ a = x?.["y"] }) {}
void function ({ a = x?.() }) {}
void function ({ a = new x?.() }) {}
// - computed properties
void function ({ [x?.y]: a }) {}
void function ({ [x?.["y"]]: a }) {}
void function ({ [x?.()]: a }) {}
void function ({ [new x?.()]: a }) {}
// arrow functions
// - parameters
((a = x?.y) => {});
((a = x?.["y"]) => {});
((a = x?.()) => {});
((a = new x?.()) => {});
// - expression bodies
(() => x?.y);
(() => x?.["y"]);
(() => x?.());
(() => new x?.());
// parenthesis
(x?.y);
// comma
x?.y, f();
f(), x?.y;
// conditional
x?.y ? 0 : 1
0 ? x?.y : 1;
0 ? 1 : x?.y;
// binary
x?.y + 1;
x?.y - 1;
x?.y * 1;
x?.y / 1;
x?.y ** 1;
x?.y % 1;
x?.y ^ 1;
x?.y & 1;
x?.y | 1;
x?.y << 1;
x?.y >> 1;
x?.y >>> 1;
x?.y && 1;
x?.y || 1;
x?.y == 1;
x?.y === 1;
x?.y != 1;
x?.y !== 1;
x?.y < 1;
x?.y <= 1;
x?.y > 1;
x?.y >= 1;
1 + x?.y;
1 - x?.y;
1 * x?.y;
1 / x?.y;
1 ** x?.y;
1 % x?.y;
1 ^ x?.y;
1 & x?.y;
1 | x?.y;
1 << x?.y;
1 >> x?.y;
1 >>> x?.y;
1 && x?.y;
1 || x?.y;
1 == x?.y;
1 === x?.y;
1 != x?.y;
1 !== x?.y;
1 < x?.y;
1 <= x?.y;
1 > x?.y;
1 >= x?.y;
// prefix unary
+x?.y;
-x?.y;
!x?.y;
~x?.y;
// unary
void x?.y;
typeof x?.y;
void function * () { yield x?.y; }
void async function() { await x?.y; }
// notnull
x?.y!.z;
// assertions
<string>x?.y;
x?.y as string;
// array literals
[x?.y];
[, x?.y];
[...x?.y];
// literals
1?.toString(); // no need for `..`
1.?.toString();
.0?.toString();
4e3?.toString();
1.e3?.toString();
""?.toString();
''?.toString();
``?.toString();
/./?.toString();
/./g?.toString();
true?.toString();
false?.toString();
// templates
`${x?.y}`;
// variables
var v = x?.y;
var [v] = x?.y;
var [v = x?.y] = [1];
var {v} = x?.y;
var {v = x?.y} = {v:1};
var {[x?.y]: v} = null;
// if/else if
if (x?.y) {}
if (1) {} else if (x?.y) {}
// switch
switch (x?.y) {}
switch (1) { case x?.y: break; }
// do/while
do {} while (x?.y)
while (x?.y) {}
// for
for (x?.y; x?.y; x?.y);
// for..in
for (x?.y in {});
// for..of
for (x?.y of []);
// enums
enum E {
a = x?.y
}
// @filename: exportsOk.ts
export default x?.y;
@@ -0,0 +1,323 @@
// @target: esnext
// @lib: esnext
// @module: commonjs
// @experimentalDecorators: true
// @filename: declarations.d.ts
declare var x: any;
declare var y: any;
declare var f: ({
(): void;
<T>(): void;
new (): any;
new <T>(): any;
}) | undefined;
declare var o: { y: typeof f; }
declare class Base { x(): any; }
declare namespace M {
export class y {}
export class z<T> {}
}
// @filename: propertyAccessOk.ts
x.y
x?.y
x?.y.z
x.y?.z
x?.y?.z
// @filename: elementAccessOk.ts
x["y"]
x?.["y"]
x?.["y"]["z"]
x["y"]?.["z"]
x?.["y"]?.["z"]
// @filename: callExpressionOk.ts
x()
x?.()
x.y?.()
x["y"]?.()
f?.<number>()
o.y?.<number>()
o["y"]?.<number>()
// @filename: newExpressionOk.ts
new x()
new x.y?.()
new x["y"]?.()
new f?.<number>()
new o.y?.<number>()
new o["y"]?.<number>()
// @filename: mixedOk.ts
x?.y?.["z"]
x?.["y"]?.z
x?.y()
x?.y?.()
o?.y<number>()
o?.y?.<number>()
x?.["z"]()
x?.["z"]?.()
o?.["y"]<number>()
o?.["y"]?.<number>()
// @filename: mutationOk.ts
x?.y = 1
x?.y += 1;
x?.y -= 1;
x?.y *= 1;
x?.y /= 1;
x?.y %= 1;
x?.y **= 1;
x?.y |= 1;
x?.y &= 1;
x?.y ^= 1;
x?.y <<= 1;
x?.y >>= 1;
x?.y >>>= 1;
x?.y++;
x?.y--;
++x?.y;
--x?.y;
delete x?.y;
x?.["y"] = 1
x?.["y"] += 1;
x?.["y"] -= 1;
x?.["y"] *= 1;
x?.["y"] /= 1;
x?.["y"] %= 1;
x?.["y"] **= 1;
x?.["y"] |= 1;
x?.["y"] &= 1;
x?.["y"] ^= 1;
x?.["y"] <<= 1;
x?.["y"] >>= 1;
x?.["y"] >>>= 1;
x?.["y"]++;
x?.["y"]--;
++x?.["y"];
--x?.["y"];
delete x?.["y"];
// @filename: arrayAssignmentPatternOk.ts
[x?.y] = [1];
[x?.["y"]] = [1];
[...x?.y] = [1];
[...x?.["y"]] = [1];
// @filename: objectAssignmentPatternOk.ts
({ a: x?.y } = { a: 1 });
({ a: x?.["y"] } = { a: 1 });
// @filename: questionDotDigitIsConditionalOk.ts
x?.3:1;
// @filename: superPropertyInvocationOk.ts
// supported for invocation of super property
void class extends Base {
m() {
super.x?.();
super["x"]?.();
}
}
// @filename: generalParsingOk.ts
// object literals
// - computed property names
void { [x?.y]: 1 }
void { [x?.["y"]]: 1 }
void { [x?.()]: 1 }
void { [new x?.()]: 1 }
// - property assignments
void { a: x?.y }
void { a: x?.["y"] }
void { a: x?.() }
void { a: new x?.() }
// classes
// - computed property names
// void class { [x?.y] = 1 } // legal parse, but causes a checker error
// void class { [x?.["y"]] = 1 } // legal parse, but causes a checker error
// void class { [x?.()] = 1 } // legal parse, but causes a checker error
// void class { [new f?.()] = 1 } // legal parse, but causes a checker error
void class { [Symbol?.toStringTag] = "" }
// - property declarations
void class { a = x?.y }
void class { a = x?.["y"] }
void class { a = x?.() }
void class { a = new x?.() }
// - heritage clauses
void class extends M?.y {}
void class extends M?.["y"] {}
void class extends M?.z<number> {}
// - class decorators
@x?.y class C1 {}
@x?.["y"] class C2 {}
@x?.() class C3 {}
@new x?.() class C4 {}
// - member decorators
class C5 { @x?.y m() {} }
class C6 { @x?.["y"] m() {} } // allowed as ?.[ is not ambiguous with computed property names
class C7 { @x?.() m() {} }
class C8 { @new x?.() m () {} }
// - parameter decorators
class C9 { m(@x?.y a) {} }
class C10 { m(@x?.["y"] a) {} }
class C11 { m(@x?.() a) {} }
class C12 { m(@new x?.() a) {} }
// functions
// - parameters
void function (a = x?.y) {}
void function (a = x?.["y"]) {}
void function (a = x?.()) {}
void function (a = new x?.()) {}
// - binding elements
// - initializers
void function ({ a = x?.y }) {}
void function ({ a = x?.["y"] }) {}
void function ({ a = x?.() }) {}
void function ({ a = new x?.() }) {}
// - computed properties
void function ({ [x?.y]: a }) {}
void function ({ [x?.["y"]]: a }) {}
void function ({ [x?.()]: a }) {}
void function ({ [new x?.()]: a }) {}
// arrow functions
// - parameters
((a = x?.y) => {});
((a = x?.["y"]) => {});
((a = x?.()) => {});
((a = new x?.()) => {});
// - expression bodies
(() => x?.y);
(() => x?.["y"]);
(() => x?.());
(() => new x?.());
// parenthesis
(x?.y);
// comma
x?.y, f();
f(), x?.y;
// conditional
x?.y ? 0 : 1
0 ? x?.y : 1;
0 ? 1 : x?.y;
// binary
x?.y + 1;
x?.y - 1;
x?.y * 1;
x?.y / 1;
x?.y ** 1;
x?.y % 1;
x?.y ^ 1;
x?.y & 1;
x?.y | 1;
x?.y << 1;
x?.y >> 1;
x?.y >>> 1;
x?.y && 1;
x?.y || 1;
x?.y == 1;
x?.y === 1;
x?.y != 1;
x?.y !== 1;
x?.y < 1;
x?.y <= 1;
x?.y > 1;
x?.y >= 1;
1 + x?.y;
1 - x?.y;
1 * x?.y;
1 / x?.y;
1 ** x?.y;
1 % x?.y;
1 ^ x?.y;
1 & x?.y;
1 | x?.y;
1 << x?.y;
1 >> x?.y;
1 >>> x?.y;
1 && x?.y;
1 || x?.y;
1 == x?.y;
1 === x?.y;
1 != x?.y;
1 !== x?.y;
1 < x?.y;
1 <= x?.y;
1 > x?.y;
1 >= x?.y;
// prefix unary
+x?.y;
-x?.y;
!x?.y;
~x?.y;
// unary
void x?.y;
typeof x?.y;
void function * () { yield x?.y; }
void async function() { await x?.y; }
// notnull
x?.y!.z;
// assertions
<string>x?.y;
x?.y as string;
// array literals
[x?.y];
[, x?.y];
[...x?.y];
// literals
1?.toString(); // no need for `..`
1.?.toString();
.0?.toString();
4e3?.toString();
1.e3?.toString();
""?.toString();
''?.toString();
``?.toString();
/./?.toString();
/./g?.toString();
true?.toString();
false?.toString();
// templates
`${x?.y}`;
// variables
var v = x?.y;
var [v] = x?.y;
var [v = x?.y] = [1];
var {v} = x?.y;
var {v = x?.y} = {v:1};
var {[x?.y]: v} = null;
// if/else if
if (x?.y) {}
if (1) {} else if (x?.y) {}
// switch
switch (x?.y) {}
switch (1) { case x?.y: break; }
// do/while
do {} while (x?.y)
while (x?.y) {}
// for
for (x?.y; x?.y; x?.y);
// for..in
for (x?.y in {});
// for..of
for (x?.y of []);
// enums
enum E {
a = x?.y
}
// @filename: exportsOk.ts
export default x?.y;
@@ -0,0 +1,359 @@
// @target: esnext
// @lib: esnext
// @noEmit: true
// @module: commonjs
// @experimentalDecorators: true
// @filename: declarations.d.ts
declare var x: any;
declare var y: any;
declare var f: ({
(): void;
<T>(): void;
new (): any;
new <T>(): any;
}) | undefined;
declare var o: { y: typeof f; }
declare class Base { x: any; }
declare namespace M {
export class y {}
export class z<T> {}
}
// @filename: propertyAccessOk.ts
x.y
x?.y
x?.y.z
x.y?.z
x?.y?.z
// @filename: elementAccessOk.ts
x["y"]
x?.["y"]
x?.["y"]["z"]
x["y"]?.["z"]
x?.["y"]?.["z"]
// @filename: callExpressionOk.ts
x()
x?.()
x.y?.()
x["y"]?.()
f?.<number>()
o.y?.<number>()
o["y"]?.<number>()
// @filename: newExpressionOk.ts
new x()
new x.y?.()
new x["y"]?.()
new f?.<number>()
new o.y?.<number>()
new o["y"]?.<number>()
// @filename: mixedOk.ts
x?.y?.["z"]
x?.["y"]?.z
x?.y()
x?.y?.()
o?.y<number>()
o?.y?.<number>()
x?.["z"]()
x?.["z"]?.()
o?.["y"]<number>()
o?.["y"]?.<number>()
// @filename: mutationOk.ts
x?.y = 1
x?.y += 1;
x?.y -= 1;
x?.y *= 1;
x?.y /= 1;
x?.y %= 1;
x?.y **= 1;
x?.y |= 1;
x?.y &= 1;
x?.y ^= 1;
x?.y <<= 1;
x?.y >>= 1;
x?.y >>>= 1;
x?.y++;
x?.y--;
++x?.y;
--x?.y;
delete x?.y;
x?.["y"] = 1
x?.["y"] += 1;
x?.["y"] -= 1;
x?.["y"] *= 1;
x?.["y"] /= 1;
x?.["y"] %= 1;
x?.["y"] **= 1;
x?.["y"] |= 1;
x?.["y"] &= 1;
x?.["y"] ^= 1;
x?.["y"] <<= 1;
x?.["y"] >>= 1;
x?.["y"] >>>= 1;
x?.["y"]++;
x?.["y"]--;
++x?.["y"];
--x?.["y"];
delete x?.["y"];
// @filename: arrayAssignmentPatternOk.ts
[x?.y] = [1];
[x?.["y"]] = [1];
[...x?.y] = [1];
[...x?.["y"]] = [1];
// @filename: objectAssignmentPatternOk.ts
({ a: x?.y } = { a: 1 });
({ a: x?.["y"] } = { a: 1 });
// @filename: questionDotDigitIsConditionalOk.ts
x?.3:1;
// @filename: spaceInTokenError.ts
x? .y
// @filename: missingIdentifierError.ts
x?.
// @filename: taggedTemplateError.ts
// not supported for tagged templates
x?.`foo${bar}`
// @filename: superError.ts
// not supported for super
void class extends Base {
constructor() {
super?.();
}
}
// @filename: superProperty1Error.ts
// not supported for super property
void class extends Base {
m() {
super?.x;
}
}
// @filename: superProperty2Error.ts
// not supported for super property
void class extends Base {
m() {
super?.["x"];
}
}
// @filename: superPropertyInvocationOk.ts
// supported for invocation of super property
void class extends Base {
m() {
super.x?.();
super["x"]?.();
}
}
// @filename: metaPropertyError.ts
// not supported for meta property
void class {
constructor() {
new?.target;
}
}
// @filename: generalParsingOk.ts
// object literals
// - computed property names
void { [x?.y]: 1 }
void { [x?.["y"]]: 1 }
void { [x?.()]: 1 }
void { [new x?.()]: 1 }
// - property assignments
void { a: x?.y }
void { a: x?.["y"] }
void { a: x?.() }
void { a: new x?.() }
// classes
// - computed property names
// void class { [x?.y] = 1 } // legal parse, but causes a checker error
// void class { [x?.["y"]] = 1 } // legal parse, but causes a checker error
// void class { [x?.()] = 1 } // legal parse, but causes a checker error
// void class { [new f?.()] = 1 } // legal parse, but causes a checker error
void class { [Symbol?.toStringTag] = "" }
// - property declarations
void class { a = x?.y }
void class { a = x?.["y"] }
void class { a = x?.() }
void class { a = new x?.() }
// - heritage clauses
void class extends M?.y {}
void class extends M?.["y"] {}
void class extends M?.z<number> {}
// - class decorators
@x?.y class C1 {}
@x?.["y"] class C2 {}
@x?.() class C3 {}
@new x?.() class C4 {}
// - member decorators
class C5 { @x?.y m() {} }
class C6 { @x?.["y"] m() {} } // allowed as ?.[ is not ambiguous with computed property names
class C7 { @x?.() m() {} }
class C8 { @new x?.() m () {} }
// - parameter decorators
class C9 { m(@x?.y a) {} }
class C10 { m(@x?.["y"] a) {} }
class C11 { m(@x?.() a) {} }
class C12 { m(@new x?.() a) {} }
// functions
// - parameters
void function (a = x?.y) {}
void function (a = x?.["y"]) {}
void function (a = x?.()) {}
void function (a = new x?.()) {}
// - binding elements
// - initializers
void function ({ a = x?.y }) {}
void function ({ a = x?.["y"] }) {}
void function ({ a = x?.() }) {}
void function ({ a = new x?.() }) {}
// - computed properties
void function ({ [x?.y]: a }) {}
void function ({ [x?.["y"]]: a }) {}
void function ({ [x?.()]: a }) {}
void function ({ [new x?.()]: a }) {}
// arrow functions
// - parameters
((a = x?.y) => {});
((a = x?.["y"]) => {});
((a = x?.()) => {});
((a = new x?.()) => {});
// - expression bodies
(() => x?.y);
(() => x?.["y"]);
(() => x?.());
(() => new x?.());
// parenthesis
(x?.y);
// comma
x?.y, f();
f(), x?.y;
// conditional
x?.y ? 0 : 1
0 ? x?.y : 1;
0 ? 1 : x?.y;
// binary
x?.y + 1;
x?.y - 1;
x?.y * 1;
x?.y / 1;
x?.y ** 1;
x?.y % 1;
x?.y ^ 1;
x?.y & 1;
x?.y | 1;
x?.y << 1;
x?.y >> 1;
x?.y >>> 1;
x?.y && 1;
x?.y || 1;
x?.y == 1;
x?.y === 1;
x?.y != 1;
x?.y !== 1;
x?.y < 1;
x?.y <= 1;
x?.y > 1;
x?.y >= 1;
1 + x?.y;
1 - x?.y;
1 * x?.y;
1 / x?.y;
1 ** x?.y;
1 % x?.y;
1 ^ x?.y;
1 & x?.y;
1 | x?.y;
1 << x?.y;
1 >> x?.y;
1 >>> x?.y;
1 && x?.y;
1 || x?.y;
1 == x?.y;
1 === x?.y;
1 != x?.y;
1 !== x?.y;
1 < x?.y;
1 <= x?.y;
1 > x?.y;
1 >= x?.y;
// prefix unary
+x?.y;
-x?.y;
!x?.y;
~x?.y;
// unary
void x?.y;
typeof x?.y;
void function * () { yield x?.y; }
void async function() { await x?.y; }
// notnull
x?.y!.z;
// assertions
<string>x?.y;
x?.y as string;
// array literals
[x?.y];
[, x?.y];
[...x?.y];
// literals
1?.toString(); // no need for `..`
1.?.toString();
.0?.toString();
4e3?.toString();
1.e3?.toString();
""?.toString();
''?.toString();
``?.toString();
/./?.toString();
/./g?.toString();
true?.toString();
false?.toString();
// templates
`${x?.y}`;
// variables
var v = x?.y;
var [v] = x?.y;
var [v = x?.y] = [1];
var {v} = x?.y;
var {v = x?.y} = {v:1};
var {[x?.y]: v} = null;
// if/else if
if (x?.y) {}
if (1) {} else if (x?.y) {}
// switch
switch (x?.y) {}
switch (1) { case x?.y: break; }
// do/while
do {} while (x?.y)
while (x?.y) {}
// for
for (x?.y; x?.y; x?.y);
// for..in
for (x?.y in {});
// for..of
for (x?.y of []);
// enums
enum E {
a = x?.y
}
// @filename: exportsOk.ts
export default x?.y;
@@ -0,0 +1,39 @@
// @target: esnext
// @lib: esnext
// @noEmit: true
// @module: commonjs
// @strictNullChecks: false
declare const x1: (() => number) | undefined | null;
declare const x2: { y: (() => number) | undefined | null; };
declare const x3: { y: (() => number) | undefined | null; } | undefined | null;
declare const x4: { y: { z: (() => number) | undefined | null; } };
declare const x5: { y: { z: (() => number) | undefined | null; } | undefined | null } | undefined | null;
declare const x6: { y: number } | undefined | null;
declare const x7: { y: any };
declare const x8: { y: { z: number } | undefined | null } | undefined | null;
declare const y: "y";
declare const z: "z";
x1?.();
(x1)?.();
x2.y?.();
x2[y]?.();
(x2.y)?.();
(x2[y])?.();
x3?.y?.();
x3?.[y]?.();
x4.y.z?.();
x4.y[z]?.();
(x4.y.z)?.();
(x4.y[z])?.();
x5?.y?.z?.();
x5?.y?.z;
x5?.[y]?.[z];
x6?.y = 1;
x6?.y += 1;
x6?.y *= 1;
x6?.y++;
++x6?.y;
@@ -0,0 +1,39 @@
// @target: esnext
// @lib: esnext
// @noEmit: true
// @module: commonjs
// @strictNullChecks: true
declare const x1: (() => number) | undefined | null;
declare const x2: { y: (() => number) | undefined | null; };
declare const x3: { y: (() => number) | undefined | null; } | undefined | null;
declare const x4: { y: { z: (() => number) | undefined | null; } };
declare const x5: { y: { z: (() => number) | undefined | null; } | undefined | null } | undefined | null;
declare const x6: { y: number } | undefined | null;
declare const x7: { y: any };
declare const x8: { y: { z: number } | undefined | null } | undefined | null;
declare const y: "y";
declare const z: "z";
const a1 = x1?.();
const a2 = (x1)?.();
const a3 = x2.y?.();
const a4 = x2[y]?.();
const a5 = (x2.y)?.();
const a6 = (x2[y])?.();
const a7 = x3?.y?.();
const a8 = x3?.[y]?.();
const a9 = x4.y.z?.();
const a10 = x4.y[z]?.();
const a11 = (x4.y.z)?.();
const a12 = (x4.y[z])?.();
const a13 = x5?.y?.z?.();
const a14 = x5?.y?.z;
const a15 = x5?.[y]?.[z];
const a16 = x6?.y = 1;
const a17 = x6?.y += 1;
const a17a = x6?.y *= 1;
const a18 = x6?.y++;
const a19 = ++x6?.y;