Add {create|update}InterfaceDeclaration methods#15500
Add {create|update}InterfaceDeclaration methods#15500rbuckton merged 2 commits intomicrosoft:mastermicrosoft/TypeScript:masterfrom phated:interface-declarationphated/TypeScript:interface-declarationCopy head branch name to clipboard
Conversation
|
@phated, It will cover your contributions to all Microsoft-managed open source projects. |
|
@phated, thanks for signing the contribution license agreement. We will now validate the agreement and then the pull request. |
|
|
||
| export function createInterfaceDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, heritageClauses: HeritageClause[], members: TypeElement[]) { | ||
| const node = <InterfaceDeclaration>createSynthesizedNode(SyntaxKind.InterfaceDeclaration); | ||
| node.decorators = asNodeArray(decorators); |
There was a problem hiding this comment.
Interfaces don't have decorators AFAIK.
There was a problem hiding this comment.
Interesting that it didn't give me a type like some of the other members.
There was a problem hiding this comment.
We parse decorators for interfaces but only to report errors currently. We do plan to support "ambient" decorators (compiler only) at some point in the future, so it is better to have them included in the signature.
| : node; | ||
| } | ||
|
|
||
| export function createInterfaceDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, heritageClauses: HeritageClause[], members: TypeElement[]) { |
There was a problem hiding this comment.
An interface must always have a name, so name should be string | Identifier. undefined is not permitted.
There was a problem hiding this comment.
heritageClauses can be undefined, so the type should be HeritageClause[] | undefined.
| return node; | ||
| } | ||
|
|
||
| export function updateInterfaceDeclaration(node: InterfaceDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, heritageClauses: HeritageClause[], members: TypeElement[]) { |
There was a problem hiding this comment.
An interface must always have a name, so name should be Identifier here. undefined is not permitted.
There was a problem hiding this comment.
heritageClauses can be undefined, so the type should be HeritageClause[] | undefined.
|
Updated |
rbuckton
left a comment
There was a problem hiding this comment.
Looks great! Thanks for the contribution.
Fixes #15497