Skip to content

Commit

Permalink
feat: #530 - Add JSDocTypeExpression
Browse files Browse the repository at this point in the history
Also added `JSDocPropertyLikeTag#getTypeExpression()`
  • Loading branch information
Pineapples authored and dsherret committed Feb 14, 2019
1 parent 1acc955 commit ddc1dd3
Show file tree
Hide file tree
Showing 16 changed files with 11,440 additions and 11,350 deletions.
420 changes: 210 additions & 210 deletions lib/code-block-writer.d.ts

Large diffs are not rendered by default.

20,865 changes: 10,443 additions & 10,422 deletions lib/ts-morph.d.ts

Large diffs are not rendered by default.

440 changes: 220 additions & 220 deletions src/codeBlockWriter/code-block-writer.ts

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/compiler/ast/CompilerNodeToWrappedType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type CompilerNodeToWrappedType<T extends ts.Node> =
T extends ts.AssignmentExpression<infer U> ? compiler.AssignmentExpression<ts.AssignmentExpression<U>> :
T["kind"] extends keyof ImplementedKindToNodeMappings ? ImplementedKindToNodeMappings[T["kind"]] :
T extends ts.SyntaxList ? compiler.SyntaxList :
T extends ts.JSDocTypeExpression ? compiler.JSDocTypeExpression :
T extends ts.TypeNode ? compiler.TypeNode :
T extends ts.TypeElement ? compiler.TypeElement :
T extends ts.JSDocTag ? compiler.JSDocTag :
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/ast/doc/JSDocTag.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ts, SyntaxKind } from "../../../typescript";
import { ts } from "../../../typescript";
import { Identifier, Node } from "../common";

/**
Expand Down
14 changes: 14 additions & 0 deletions src/compiler/ast/doc/JSDocTypeExpression.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { ts } from "../../../typescript";
import { Node } from "..";

/**
* JS doc type expression node.
*/
export class JSDocTypeExpression extends Node<ts.JSDocTypeExpression> {
/**
* Gets the type node of the JS doc type expression.
*/
getTypeNode() {
return this._getNodeFromCompilerNode(this.compilerNode.type);
}
}
7 changes: 7 additions & 0 deletions src/compiler/ast/doc/base/JSDocPropertyLikeTag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ import { ts } from "../../../../typescript";
import { EntityName } from "../../aliases";
import { Node } from "../../common";
import { JSDocTag } from "../JSDocTag";
import { JSDocTypeExpression } from "../JSDocTypeExpression";

export type JSDocPropertyLikeTagExtensionType = Node<ts.JSDocPropertyLikeTag> & JSDocTag;

export interface JSDocPropertyLikeTag {
/** Gets the type expression node of the JS doc property like tag. */
getTypeExpression(): JSDocTypeExpression | undefined;
/** Gets the name of the JS doc property like tag. */
getName(): string;
/** Gets the name node of the JS doc property like tag. */
Expand All @@ -18,6 +21,10 @@ export interface JSDocPropertyLikeTag {
export function JSDocPropertyLikeTag<T extends Constructor<JSDocPropertyLikeTagExtensionType>>(Base: T): Constructor<JSDocPropertyLikeTag> & T {
return class extends Base implements JSDocPropertyLikeTag {
// todo: more methods
getTypeExpression() {
return this._getNodeFromCompilerNodeIfExists(this.compilerNode.typeExpression);
}

getName() {
return this.getNameNode().getText();
}
Expand Down
1 change: 1 addition & 0 deletions src/compiler/ast/doc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export * from "./JSDocTagInfo";
export * from "./JSDocTypedefTag";
export * from "./JSDocTypeTag";
export * from "./JSDocUnknownTag";
export * from "./JSDocTypeExpression";
476 changes: 239 additions & 237 deletions src/compiler/ast/kindToNodeMappings.ts

Large diffs are not rendered by default.

0 comments on commit ddc1dd3

Please sign in to comment.