You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Not possible to create an Interface definition in synthetic AST #15497
// A *self-contained* demonstration of the problem follows...// There doesn't seem to be an API to create an Interface in the AST programmaticallyconst_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);letsrc=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.
Activity
mhegazy commentedon May 1, 2017
You need to add a
createInterfaceDeclarationto factory.ts, something a la createClassDeclaration.mhegazy commentedon May 1, 2017
PRs welcomed.
phated commentedon May 1, 2017
Mohamed Hegazy (@mhegazy) will do! One question though: are there tests around these APIs? I couldn't find any.
mhegazy commentedon May 1, 2017
No.
Add {create|update}InterfaceDeclaration methods (closes microsoft#15497)
mohsen1 commentedon May 1, 2017
Blaine Bublitz (@phated) can you also fix #15489 in your PR?
phated commentedon May 1, 2017
I'll submit another one for that but I'm tackling some interface stuff right now.