-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add
getTypeExpressionOrThrow()
to JSDocReturnTag
and `JSDoc…
…PropertyLikeTag`
- Loading branch information
Showing
4 changed files
with
53 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
import { ts } from "@ts-morph/common"; | ||
import { ts, errors } from "@ts-morph/common"; | ||
import { JSDocTag } from "./JSDocTag"; | ||
|
||
/** | ||
* JS doc return tag node. | ||
*/ | ||
export class JSDocReturnTag extends JSDocTag<ts.JSDocReturnTag> { | ||
/** | ||
* Gets the type expression node of the JS doc property return tag. | ||
* Gets the type expression node of the JS doc return tag if it exists. | ||
*/ | ||
getTypeExpression() { | ||
return this._getNodeFromCompilerNodeIfExists(this.compilerNode.typeExpression); | ||
} | ||
|
||
/** | ||
* Gets the type expression node of the JS doc return tag or throws if it doesn't exist. | ||
*/ | ||
getTypeExpressionOrThrow() { | ||
return errors.throwIfNullOrUndefined(this.getTypeExpression(), `Expected to find a ${nameof(JSDocReturnTag)}'s type expression.`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters