Skip to content

factory: getLeftmostExpression needs to handle more kinds #25223

Closed
@ajafff

Description

@ajafff

TypeScript Version: 3.0.0-dev.20180621

Search Terms:

Code

import * as ts from 'typescript';
const n = ts.createStatement(ts.createAsExpression(ts.createObjectLiteral(), ts.createTypeReferenceNode('any', undefined)));
ts.createPrinter().printNode(ts.EmitHint.Unspecified, n, ts.createSourceFile('dummy.ts', '', ts.ScriptTarget.Latest));

Expected behavior:

({} as any);

The same applies to NonNullExpression.

Actual behavior:

Invalid code, this is a syntax error: {} as any;

Metadata

Metadata

Assignees

No one assigned

    Labels

    APIRelates to the public API for TypeScriptBugA bug in TypeScriptFixedA PR has been merged for this issueHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions