Skip to content

Commit 5374485

Browse files
committed
docs(semantic): add docs for JSDoctagTypeNamePart
1 parent bcd5813 commit 5374485

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

crates/oxc_semantic/src/jsdoc/parser/jsdoc_parts.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,41 @@ impl<'a> JSDocTagTypePart<'a> {
127127
}
128128
}
129129

130+
/// Represents a single component of a type name in a JSDoc tag—
131+
/// typically seen within unions, generics, or optional/defaulted parameters.
132+
///
133+
/// This structure captures the raw source string, its span in the original code,
134+
/// and any modifiers like optional (`?`) or default (`=`).
135+
///
136+
/// For example, in a JSDoc tag like:
137+
///
138+
/// ```js
139+
/// /**
140+
/// * @param {foo=} bar
141+
/// * ^^^^
142+
/// * This is the `JSDocTagTypeNamePart`
143+
/// */
144+
/// ```
145+
///
146+
/// The type name part `foo` is considered to have a default value (`=`),
147+
/// and would be represented with `default: true`.
148+
///
149+
/// Note: `optional` and `default` can both be `true` if both modifiers appear.
130150
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
131151
pub struct JSDocTagTypeNamePart<'a> {
152+
/// The raw, unparsed text of the type name part (e.g., `"foo"` in `{foo}` or `{foo=}`).
132153
raw: &'a str,
154+
155+
/// The span in the source text corresponding to this part.
133156
pub span: Span,
157+
158+
/// Indicates whether the type name part is marked as optional (`foo?`).
134159
pub optional: bool,
160+
161+
/// Indicates whether the type name part has a default value (`foo=`).
135162
pub default: bool,
136163
}
164+
137165
impl<'a> JSDocTagTypeNamePart<'a> {
138166
pub fn new(part_content: &'a str, span: Span) -> Self {
139167
debug_assert!(part_content.trim() == part_content);

0 commit comments

Comments
 (0)