mirror of
https://github.com/aphrody-labs/oxc.git
synced 2026-10-15 06:39:17 +00:00
docs(ast): Add docs for TSNonNullExpression (#26910)
The non-null assertion operator (`!`) is common in TypeScript but this node lacked any documentation in the code. This adds an example of the syntax to the node.
This commit is contained in:
1 parent
4a76723a15
commit
d5f92b5daf
2 files changed
+30
-15
No files matched your search
@@ -1743,6 +1743,20 @@ pub struct TSExternalModuleReference<'a> {
|
||||
pub expression: StringLiteral<'a>,
|
||||
}
|
||||
|
||||
/// TypeScript non-null expression (`!`)
|
||||
///
|
||||
/// This expression assumes that the type of the inner expression is not null
|
||||
/// and changes it from `T | null` to just `T`.
|
||||
///
|
||||
/// ## Example
|
||||
///
|
||||
/// ```ts
|
||||
/// x!
|
||||
/// ^ expression
|
||||
///
|
||||
/// a.b.c!
|
||||
/// ^^^^^ expression
|
||||
/// ```
|
||||
#[ast(visit)]
|
||||
#[derive(Debug)]
|
||||
#[generate_derive(CloneIn, Dummy, ReplaceWith, TakeIn)]
|
||||
@@ -1750,6 +1764,7 @@ pub struct TSExternalModuleReference<'a> {
|
||||
pub struct TSNonNullExpression<'a> {
|
||||
pub node_id: Cell<NodeId>,
|
||||
pub span: Span,
|
||||
/// The expression to assume as not null, e.g., `x` in `x!`.
|
||||
pub expression: Expression<'a>,
|
||||
}
|
||||
|
||||
|
||||
@@ -1173,7 +1173,7 @@ impl<'a> Expression<'a> {
|
||||
///
|
||||
/// ## Parameters
|
||||
/// * `span`: The [`Span`] covering this node
|
||||
/// * `expression`
|
||||
/// * `expression`: The expression to assume as not null, e.g., `x` in `x!`.
|
||||
#[inline]
|
||||
pub fn new_ts_non_null_expression(
|
||||
span: Span,
|
||||
@@ -2701,7 +2701,7 @@ impl<'a> ArrayExpressionElement<'a> {
|
||||
///
|
||||
/// ## Parameters
|
||||
/// * `span`: The [`Span`] covering this node
|
||||
/// * `expression`
|
||||
/// * `expression`: The expression to assume as not null, e.g., `x` in `x!`.
|
||||
#[inline]
|
||||
pub fn new_ts_non_null_expression(
|
||||
span: Span,
|
||||
@@ -4136,7 +4136,7 @@ impl<'a> PropertyKey<'a> {
|
||||
///
|
||||
/// ## Parameters
|
||||
/// * `span`: The [`Span`] covering this node
|
||||
/// * `expression`
|
||||
/// * `expression`: The expression to assume as not null, e.g., `x` in `x!`.
|
||||
#[inline]
|
||||
pub fn new_ts_non_null_expression(
|
||||
span: Span,
|
||||
@@ -6078,7 +6078,7 @@ impl<'a> Argument<'a> {
|
||||
///
|
||||
/// ## Parameters
|
||||
/// * `span`: The [`Span`] covering this node
|
||||
/// * `expression`
|
||||
/// * `expression`: The expression to assume as not null, e.g., `x` in `x!`.
|
||||
#[inline]
|
||||
pub fn new_ts_non_null_expression(
|
||||
span: Span,
|
||||
@@ -6628,7 +6628,7 @@ impl<'a> AssignmentTarget<'a> {
|
||||
///
|
||||
/// ## Parameters
|
||||
/// * `span`: The [`Span`] covering this node
|
||||
/// * `expression`
|
||||
/// * `expression`: The expression to assume as not null, e.g., `x` in `x!`.
|
||||
#[inline]
|
||||
pub fn new_ts_non_null_expression(
|
||||
span: Span,
|
||||
@@ -6878,7 +6878,7 @@ impl<'a> SimpleAssignmentTarget<'a> {
|
||||
///
|
||||
/// ## Parameters
|
||||
/// * `span`: The [`Span`] covering this node
|
||||
/// * `expression`
|
||||
/// * `expression`: The expression to assume as not null, e.g., `x` in `x!`.
|
||||
#[inline]
|
||||
pub fn new_ts_non_null_expression(
|
||||
span: Span,
|
||||
@@ -7281,7 +7281,7 @@ impl<'a> AssignmentTargetMaybeDefault<'a> {
|
||||
///
|
||||
/// ## Parameters
|
||||
/// * `span`: The [`Span`] covering this node
|
||||
/// * `expression`
|
||||
/// * `expression`: The expression to assume as not null, e.g., `x` in `x!`.
|
||||
#[inline]
|
||||
pub fn new_ts_non_null_expression(
|
||||
span: Span,
|
||||
@@ -7837,7 +7837,7 @@ impl<'a> ChainElement<'a> {
|
||||
///
|
||||
/// ## Parameters
|
||||
/// * `span`: The [`Span`] covering this node
|
||||
/// * `expression`
|
||||
/// * `expression`: The expression to assume as not null, e.g., `x` in `x!`.
|
||||
#[inline]
|
||||
pub fn new_ts_non_null_expression(
|
||||
span: Span,
|
||||
@@ -11414,7 +11414,7 @@ impl<'a> ForStatementInit<'a> {
|
||||
///
|
||||
/// ## Parameters
|
||||
/// * `span`: The [`Span`] covering this node
|
||||
/// * `expression`
|
||||
/// * `expression`: The expression to assume as not null, e.g., `x` in `x!`.
|
||||
#[inline]
|
||||
pub fn new_ts_non_null_expression(
|
||||
span: Span,
|
||||
@@ -11778,7 +11778,7 @@ impl<'a> ForStatementLeft<'a> {
|
||||
///
|
||||
/// ## Parameters
|
||||
/// * `span`: The [`Span`] covering this node
|
||||
/// * `expression`
|
||||
/// * `expression`: The expression to assume as not null, e.g., `x` in `x!`.
|
||||
#[inline]
|
||||
pub fn new_ts_non_null_expression(
|
||||
span: Span,
|
||||
@@ -14476,7 +14476,7 @@ impl<'a> ArrowFunctionBody<'a> {
|
||||
///
|
||||
/// ## Parameters
|
||||
/// * `span`: The [`Span`] covering this node
|
||||
/// * `expression`
|
||||
/// * `expression`: The expression to assume as not null, e.g., `x` in `x!`.
|
||||
#[inline]
|
||||
pub fn new_ts_non_null_expression(
|
||||
span: Span,
|
||||
@@ -17945,7 +17945,7 @@ impl<'a> ExportDefaultDeclarationKind<'a> {
|
||||
///
|
||||
/// ## Parameters
|
||||
/// * `span`: The [`Span`] covering this node
|
||||
/// * `expression`
|
||||
/// * `expression`: The expression to assume as not null, e.g., `x` in `x!`.
|
||||
#[inline]
|
||||
pub fn new_ts_non_null_expression(
|
||||
span: Span,
|
||||
@@ -20136,7 +20136,7 @@ impl<'a> JSXExpression<'a> {
|
||||
///
|
||||
/// ## Parameters
|
||||
/// * `span`: The [`Span`] covering this node
|
||||
/// * `expression`
|
||||
/// * `expression`: The expression to assume as not null, e.g., `x` in `x!`.
|
||||
#[inline]
|
||||
pub fn new_ts_non_null_expression(
|
||||
span: Span,
|
||||
@@ -27044,7 +27044,7 @@ impl<'a> TSNonNullExpression<'a> {
|
||||
///
|
||||
/// ## Parameters
|
||||
/// * `span`: The [`Span`] covering this node
|
||||
/// * `expression`
|
||||
/// * `expression`: The expression to assume as not null, e.g., `x` in `x!`.
|
||||
#[inline]
|
||||
pub fn new(span: Span, expression: Expression<'a>, builder: &impl GetAstBuilder<'a>) -> Self {
|
||||
let builder = builder.builder();
|
||||
@@ -27058,7 +27058,7 @@ impl<'a> TSNonNullExpression<'a> {
|
||||
///
|
||||
/// ## Parameters
|
||||
/// * `span`: The [`Span`] covering this node
|
||||
/// * `expression`
|
||||
/// * `expression`: The expression to assume as not null, e.g., `x` in `x!`.
|
||||
#[inline]
|
||||
pub fn boxed(
|
||||
span: Span,
|
||||
|
||||
Reference in new issue
Block a user