Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions crates/oxc_ast/src/ast_impl/ts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@ impl fmt::Display for TSAccessibility {

impl TSModuleDeclaration<'_> {
/// Returns `true` if this module's body exists and has a `"use strict"` directive.
///
/// Note that for a nested [`TSModuleDeclaration`], only returns `true` for the innermost `TSModuleDeclaration`.
/// e.g. this AST has 3 x `TSModuleDeclaration`s:
/// ```ts
/// namespace X.Y.Z {
/// "use strict";
/// }
/// ```
/// This method will only return `true` for the innermost one (`Z`).
pub fn has_use_strict_directive(&self) -> bool {
self.body.as_ref().is_some_and(TSModuleDeclarationBody::has_use_strict_directive)
}
Expand Down Expand Up @@ -232,6 +241,15 @@ impl fmt::Display for TSModuleDeclarationName<'_> {

impl<'a> TSModuleDeclarationBody<'a> {
/// Returns `true` if this module has a `"use strict"` directive.
///
/// Note that for a nested [`TSModuleDeclaration`], only returns `true` for the innermost [`TSModuleDeclarationBody`].
/// e.g. this AST has 3 x `TSModuleDeclarationBody`s:
/// ```ts
/// namespace X.Y.Z {
/// "use strict";
/// }
/// ```
/// This method will only return `true` for the innermost one (`Z`).
pub fn has_use_strict_directive(&self) -> bool {
matches!(self, Self::TSModuleBlock(block) if block.has_use_strict_directive())
}
Expand Down
Loading