-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: APIRelates to the public API for TypeScriptRelates to the public API for TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issueHelp WantedYou can do thisYou can do this
Milestone
Description
TypeScript Version: 3.0.0-dev.20180621
Search Terms:
Code
import * as ts from 'typescript';
const n = ts.createExportAssignment(
undefined,
undefined,
false,
ts.createPropertyAccess(
ts.createClassExpression(
undefined,
undefined,
undefined,
undefined,
[ts.createProperty(undefined, [ts.createToken(ts.SyntaxKind.StaticKeyword)], 'prop', undefined, undefined, ts.createLiteral('1'))],
),
'prop',
),
);
ts.createPrinter().printNode(ts.EmitHint.Unspecified, n, ts.createSourceFile('dummy.ts', '', ts.ScriptTarget.Latest));Expected behavior:
export default (class {static prop = '1'}.prop);
Note that this also applies to export default (function() {}());
To fix this, parenthesizeDefaultExpression needs to use getLeftmostExpression to get the leading class or function expression.
Actual behavior:
Invalid code: export default class {static prop = '1'}.prop;
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: APIRelates to the public API for TypeScriptRelates to the public API for TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issueHelp WantedYou can do thisYou can do this