mirror of
https://github.com/aphrody-labs/oxc.git
synced 2026-10-15 06:39:17 +00:00
docs(ast): Add docs for TSInstantiationExpression (#26908)
This is a relatively obscure type of expression that lets you pass type arguments to an expression that has type arguments (like a function expression). Since it's fairly uncommon and not obvious what it represents, I figured I should add some docs to it. For example: `(foo<string>)` where `foo` is some expression/value that supports type arguments.
This commit is contained in:
1 parent
dce64f6b1e
commit
de41927a4e
2 files changed
+35
-20
No files matched your search
@@ -1813,6 +1813,15 @@ pub struct TSNamespaceExportDeclaration<'a> {
|
||||
pub id: IdentifierName<'a>,
|
||||
}
|
||||
|
||||
/// An expression with instantiated type arguments.
|
||||
///
|
||||
/// ## Example
|
||||
///
|
||||
/// ```ts
|
||||
/// (foo<Bar>)()
|
||||
/// ^^^^^ type arguments
|
||||
/// ^^^^^^^^ expression
|
||||
/// ```
|
||||
#[ast(visit)]
|
||||
#[derive(Debug)]
|
||||
#[generate_derive(CloneIn, Dummy, ReplaceWith, TakeIn)]
|
||||
@@ -1820,7 +1829,13 @@ pub struct TSNamespaceExportDeclaration<'a> {
|
||||
pub struct TSInstantiationExpression<'a> {
|
||||
pub node_id: Cell<NodeId>,
|
||||
pub span: Span,
|
||||
/// The expression being instantiated with type arguments.
|
||||
///
|
||||
/// Example: `foo` in `(foo<Bar>)()`
|
||||
pub expression: Expression<'a>,
|
||||
/// The type arguments used to instantiate the expression.
|
||||
///
|
||||
/// Example: `X` and `Y` in `(foo<X, Y>)()`
|
||||
pub type_arguments: Box<'a, TSTypeParameterInstantiation<'a>>,
|
||||
}
|
||||
|
||||
|
||||
@@ -1189,8 +1189,8 @@ impl<'a> Expression<'a> {
|
||||
///
|
||||
/// ## Parameters
|
||||
/// * `span`: The [`Span`] covering this node
|
||||
/// * `expression`
|
||||
/// * `type_arguments`
|
||||
/// * `expression`: The expression being instantiated with type arguments.
|
||||
/// * `type_arguments`: The type arguments used to instantiate the expression.
|
||||
#[inline]
|
||||
pub fn new_ts_instantiation_expression(
|
||||
span: Span,
|
||||
@@ -2717,8 +2717,8 @@ impl<'a> ArrayExpressionElement<'a> {
|
||||
///
|
||||
/// ## Parameters
|
||||
/// * `span`: The [`Span`] covering this node
|
||||
/// * `expression`
|
||||
/// * `type_arguments`
|
||||
/// * `expression`: The expression being instantiated with type arguments.
|
||||
/// * `type_arguments`: The type arguments used to instantiate the expression.
|
||||
#[inline]
|
||||
pub fn new_ts_instantiation_expression(
|
||||
span: Span,
|
||||
@@ -4152,8 +4152,8 @@ impl<'a> PropertyKey<'a> {
|
||||
///
|
||||
/// ## Parameters
|
||||
/// * `span`: The [`Span`] covering this node
|
||||
/// * `expression`
|
||||
/// * `type_arguments`
|
||||
/// * `expression`: The expression being instantiated with type arguments.
|
||||
/// * `type_arguments`: The type arguments used to instantiate the expression.
|
||||
#[inline]
|
||||
pub fn new_ts_instantiation_expression(
|
||||
span: Span,
|
||||
@@ -6094,8 +6094,8 @@ impl<'a> Argument<'a> {
|
||||
///
|
||||
/// ## Parameters
|
||||
/// * `span`: The [`Span`] covering this node
|
||||
/// * `expression`
|
||||
/// * `type_arguments`
|
||||
/// * `expression`: The expression being instantiated with type arguments.
|
||||
/// * `type_arguments`: The type arguments used to instantiate the expression.
|
||||
#[inline]
|
||||
pub fn new_ts_instantiation_expression(
|
||||
span: Span,
|
||||
@@ -11430,8 +11430,8 @@ impl<'a> ForStatementInit<'a> {
|
||||
///
|
||||
/// ## Parameters
|
||||
/// * `span`: The [`Span`] covering this node
|
||||
/// * `expression`
|
||||
/// * `type_arguments`
|
||||
/// * `expression`: The expression being instantiated with type arguments.
|
||||
/// * `type_arguments`: The type arguments used to instantiate the expression.
|
||||
#[inline]
|
||||
pub fn new_ts_instantiation_expression(
|
||||
span: Span,
|
||||
@@ -14492,8 +14492,8 @@ impl<'a> ArrowFunctionBody<'a> {
|
||||
///
|
||||
/// ## Parameters
|
||||
/// * `span`: The [`Span`] covering this node
|
||||
/// * `expression`
|
||||
/// * `type_arguments`
|
||||
/// * `expression`: The expression being instantiated with type arguments.
|
||||
/// * `type_arguments`: The type arguments used to instantiate the expression.
|
||||
#[inline]
|
||||
pub fn new_ts_instantiation_expression(
|
||||
span: Span,
|
||||
@@ -17961,8 +17961,8 @@ impl<'a> ExportDefaultDeclarationKind<'a> {
|
||||
///
|
||||
/// ## Parameters
|
||||
/// * `span`: The [`Span`] covering this node
|
||||
/// * `expression`
|
||||
/// * `type_arguments`
|
||||
/// * `expression`: The expression being instantiated with type arguments.
|
||||
/// * `type_arguments`: The type arguments used to instantiate the expression.
|
||||
#[inline]
|
||||
pub fn new_ts_instantiation_expression(
|
||||
span: Span,
|
||||
@@ -20152,8 +20152,8 @@ impl<'a> JSXExpression<'a> {
|
||||
///
|
||||
/// ## Parameters
|
||||
/// * `span`: The [`Span`] covering this node
|
||||
/// * `expression`
|
||||
/// * `type_arguments`
|
||||
/// * `expression`: The expression being instantiated with type arguments.
|
||||
/// * `type_arguments`: The type arguments used to instantiate the expression.
|
||||
#[inline]
|
||||
pub fn new_ts_instantiation_expression(
|
||||
span: Span,
|
||||
@@ -27159,8 +27159,8 @@ impl<'a> TSInstantiationExpression<'a> {
|
||||
///
|
||||
/// ## Parameters
|
||||
/// * `span`: The [`Span`] covering this node
|
||||
/// * `expression`
|
||||
/// * `type_arguments`
|
||||
/// * `expression`: The expression being instantiated with type arguments.
|
||||
/// * `type_arguments`: The type arguments used to instantiate the expression.
|
||||
#[inline]
|
||||
pub fn new(
|
||||
span: Span,
|
||||
@@ -27184,8 +27184,8 @@ impl<'a> TSInstantiationExpression<'a> {
|
||||
///
|
||||
/// ## Parameters
|
||||
/// * `span`: The [`Span`] covering this node
|
||||
/// * `expression`
|
||||
/// * `type_arguments`
|
||||
/// * `expression`: The expression being instantiated with type arguments.
|
||||
/// * `type_arguments`: The type arguments used to instantiate the expression.
|
||||
#[inline]
|
||||
pub fn boxed(
|
||||
span: Span,
|
||||
|
||||
Reference in new issue
Block a user