Skip to content

Commit 7463860

Browse files
committed
Clean up types
1 parent 5ea7cb5 commit 7463860

File tree

3 files changed

+4
-57
lines changed

3 files changed

+4
-57
lines changed

src/compiler/binder.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1581,7 +1581,7 @@ namespace ts {
15811581
}
15821582
}
15831583

1584-
function bindOptionalChain(node: ValidOptionalChain, trueTarget: FlowLabel, falseTarget: FlowLabel) {
1584+
function bindOptionalChain(node: OptionalChain, trueTarget: FlowLabel, falseTarget: FlowLabel) {
15851585
// For an optional chain, we emulate the behavior of a logical expression:
15861586
//
15871587
// a?.b -> a && a.b
@@ -1605,7 +1605,7 @@ namespace ts {
16051605
}
16061606
}
16071607

1608-
function bindOptionalChainFlow(node: ValidOptionalChain) {
1608+
function bindOptionalChainFlow(node: OptionalChain) {
16091609
if (isTopLevelLogicalExpression(node)) {
16101610
const postExpressionLabel = createBranchLabel();
16111611
bindOptionalChain(node, postExpressionLabel, postExpressionLabel);
@@ -1617,7 +1617,7 @@ namespace ts {
16171617
}
16181618

16191619
function bindAccessExpressionFlow(node: AccessExpression) {
1620-
if (isValidOptionalChain(node)) {
1620+
if (isOptionalChain(node)) {
16211621
bindOptionalChainFlow(node);
16221622
}
16231623
else {
@@ -1626,7 +1626,7 @@ namespace ts {
16261626
}
16271627

16281628
function bindCallExpressionFlow(node: CallExpression) {
1629-
if (isValidOptionalChain(node)) {
1629+
if (isOptionalChain(node)) {
16301630
bindOptionalChainFlow(node);
16311631
}
16321632
else {

src/compiler/types.ts

-40
Original file line numberDiff line numberDiff line change
@@ -1806,17 +1806,6 @@ namespace ts {
18061806
questionDotToken: QuestionDotToken;
18071807
}
18081808

1809-
/* @internal */
1810-
export interface ValidPropertyAccessChainLink extends PropertyAccessChain {
1811-
questionDotToken: undefined;
1812-
expression: ValidOptionalChain;
1813-
}
1814-
1815-
/* @internal */
1816-
export type ValidPropertyAccessChain =
1817-
| PropertyAccessChainRoot
1818-
| ValidPropertyAccessChainLink;
1819-
18201809
export interface SuperPropertyAccessExpression extends PropertyAccessExpression {
18211810
expression: SuperExpression;
18221811
}
@@ -1843,17 +1832,6 @@ namespace ts {
18431832
questionDotToken: QuestionDotToken;
18441833
}
18451834

1846-
/* @internal */
1847-
export interface ValidElementAccessChainLink extends ElementAccessChain {
1848-
questionDotToken: undefined;
1849-
expression: ValidOptionalChain;
1850-
}
1851-
1852-
/* @internal */
1853-
export type ValidElementAccessChain =
1854-
| ElementAccessChainRoot
1855-
| ValidElementAccessChainLink;
1856-
18571835
export interface SuperElementAccessExpression extends ElementAccessExpression {
18581836
expression: SuperExpression;
18591837
}
@@ -1878,17 +1856,6 @@ namespace ts {
18781856
questionDotToken: QuestionDotToken;
18791857
}
18801858

1881-
/* @internal */
1882-
export interface ValidCallChainLink extends CallChain {
1883-
questionDotToken: undefined;
1884-
expression: ValidOptionalChain;
1885-
}
1886-
1887-
/* @internal */
1888-
export type ValidCallChain =
1889-
| CallChainRoot
1890-
| ValidCallChainLink;
1891-
18921859
export type OptionalChain =
18931860
| PropertyAccessChain
18941861
| ElementAccessChain
@@ -1902,13 +1869,6 @@ namespace ts {
19021869
| CallChainRoot
19031870
;
19041871

1905-
/* @internal */
1906-
export type ValidOptionalChain =
1907-
| ValidPropertyAccessChain
1908-
| ValidElementAccessChain
1909-
| ValidCallChain
1910-
;
1911-
19121872
/** @internal */
19131873
export type BindableObjectDefinePropertyCall = CallExpression & { arguments: { 0: EntityNameExpression, 1: StringLiteralLike | NumericLiteral, 2: ObjectLiteralExpression } };
19141874

src/compiler/utilities.ts

-13
Original file line numberDiff line numberDiff line change
@@ -7125,19 +7125,6 @@ namespace ts {
71257125
return node.kind === SyntaxKind.GetAccessor;
71267126
}
71277127

7128-
/**
7129-
* Tests whether an OptionalChain is valid. We can parse an invalid optional chain if it contains an
7130-
* invalid TaggedTemplateChain per the ECMAScript syntax.
7131-
*/
7132-
/* @internal */
7133-
export function isValidOptionalChain(node: Expression): node is ValidOptionalChain {
7134-
while (isOptionalChain(node)) {
7135-
if (node.questionDotToken) return true;
7136-
node = node.expression;
7137-
}
7138-
return false;
7139-
}
7140-
71417128
/* @internal */
71427129
export function isOptionalChainRoot(node: Node): node is OptionalChainRoot {
71437130
return isOptionalChain(node) && !!node.questionDotToken;

0 commit comments

Comments
 (0)