-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
APIRelates to the public API for TypeScriptRelates to the public API for TypeScriptBugA bug in TypeScriptA bug in 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;
Metadata
Metadata
Assignees
Labels
APIRelates to the public API for TypeScriptRelates to the public API for TypeScriptBugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issueHelp WantedYou can do thisYou can do this