-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Add {create|update}InterfaceDeclaration methods #15500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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. |
src/compiler/factory.ts
Outdated
@@ -1440,6 +1440,28 @@ namespace ts { | |||
: node; | |||
} | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interfaces don't have decorators AFAIK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting that it didn't give me a type like some of the other members.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
src/compiler/factory.ts
Outdated
@@ -1440,6 +1440,28 @@ namespace ts { | |||
: 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An interface must always have a name, so name
should be string | Identifier
. undefined
is not permitted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
heritageClauses
can be undefined
, so the type should be HeritageClause[] | undefined
.
src/compiler/factory.ts
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An interface must always have a name, so name
should be Identifier
here. undefined
is not permitted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
heritageClauses
can be undefined
, so the type should be HeritageClause[] | undefined
.
Updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thanks for the contribution.
Fixes #15497