docs(ast): clarify TSNonNullExpression docs (#26960)

Follow-up to [review feedback](https://github.com/oxc-project/oxc/pull/26910#discussion_r4070637601): clarify that `!` removes both `null` and `undefined` from its type.
This commit is contained in:
camc314 committed 2026-09-23 12:57:02 +00:00
1 parent 0b630e853c
commit 06dfd9f454
2 files changed
+18 -18

No files matched your search

+3 -3
View File
@@ -1745,8 +1745,8 @@ pub struct TSExternalModuleReference<'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`.
/// This expression asserts that the inner expression is neither `null` nor `undefined`,
/// removing both from its type (for example, `T | null | undefined` becomes `T`).
///
/// ## Example
///
@@ -1764,7 +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!`.
/// The expression to assert as neither `null` nor `undefined`, e.g., `x` in `x!`.
pub expression: Expression<'a>,
}
+15 -15
View File
@@ -1173,7 +1173,7 @@ impl<'a> Expression<'a> {
///
/// ## Parameters
/// * `span`: The [`Span`] covering this node
/// * `expression`: The expression to assume as not null, e.g., `x` in `x!`.
/// * `expression`: The expression to assert as neither `null` nor `undefined`, 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`: The expression to assume as not null, e.g., `x` in `x!`.
/// * `expression`: The expression to assert as neither `null` nor `undefined`, 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`: The expression to assume as not null, e.g., `x` in `x!`.
/// * `expression`: The expression to assert as neither `null` nor `undefined`, 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`: The expression to assume as not null, e.g., `x` in `x!`.
/// * `expression`: The expression to assert as neither `null` nor `undefined`, 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`: The expression to assume as not null, e.g., `x` in `x!`.
/// * `expression`: The expression to assert as neither `null` nor `undefined`, 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`: The expression to assume as not null, e.g., `x` in `x!`.
/// * `expression`: The expression to assert as neither `null` nor `undefined`, 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`: The expression to assume as not null, e.g., `x` in `x!`.
/// * `expression`: The expression to assert as neither `null` nor `undefined`, 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`: The expression to assume as not null, e.g., `x` in `x!`.
/// * `expression`: The expression to assert as neither `null` nor `undefined`, 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`: The expression to assume as not null, e.g., `x` in `x!`.
/// * `expression`: The expression to assert as neither `null` nor `undefined`, 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`: The expression to assume as not null, e.g., `x` in `x!`.
/// * `expression`: The expression to assert as neither `null` nor `undefined`, 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`: The expression to assume as not null, e.g., `x` in `x!`.
/// * `expression`: The expression to assert as neither `null` nor `undefined`, 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`: The expression to assume as not null, e.g., `x` in `x!`.
/// * `expression`: The expression to assert as neither `null` nor `undefined`, 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`: The expression to assume as not null, e.g., `x` in `x!`.
/// * `expression`: The expression to assert as neither `null` nor `undefined`, 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`: The expression to assume as not null, e.g., `x` in `x!`.
/// * `expression`: The expression to assert as neither `null` nor `undefined`, 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`: The expression to assume as not null, e.g., `x` in `x!`.
/// * `expression`: The expression to assert as neither `null` nor `undefined`, e.g., `x` in `x!`.
#[inline]
pub fn boxed(
span: Span,