Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Not possible to create an Interface definition in synthetic AST #15497

Copy link
Copy link
@phated

Description

@phated
Issue body actions

TypeScript Version: 2.3.2

Code

// A *self-contained* demonstration of the problem follows...

// There doesn't seem to be an API to create an Interface in the AST programmatically
const _implementsClause = ts.createHeritageClause(ts.SyntaxKind.ImplementsKeyword, [
    ts.createExpressionWithTypeArguments([], ts.createIdentifier('MyInterface'))
]);
const _exportModifier = ts.createToken(ts.SyntaxKind.ExportKeyword);
const _classExpression = ts.createClassExpression([_exportModifier], 'MyClass', [], [_implementsClause], []);
const _classStatement = ts.createStatement(_classExpression);

let src = ts.createSourceFile('output.ts', '', ts.ScriptTarget.ES5, false, ts.ScriptKind.TS);
src = ts.updateSourceFileNode(src, [_classStatement]);

Expected behavior:
There should be an API for creating an Interface definition in a synthetic AST.

Actual behavior:
Doesn't seem like the API exists.

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

BugA 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

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.