use super::{HelperDef, HelperName};
pub const DEF: HelperDef = HelperDef {
name: HelperName::create_super,
local: "_create_super",
import_path: "@swc/helpers/_/_create_super",
#[cfg(feature = "inline-helpers")]
source: r#"function _create_super(Derived) {
var hasNativeReflectConstruct = _is_native_reflect_construct();
return function _createSuperInternal() {
var Super = _get_prototype_of(Derived), result;
if (hasNativeReflectConstruct) {
var NewTarget = _get_prototype_of(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possible_constructor_return(this, result);
};
}
"#,
#[cfg(feature = "inline-helpers")]
deps: super::HelperBitmap::from_bits(0x00000002000004002008040000000040),
};
#[cfg(feature = "inline-helpers")]
pub fn stmts() -> &'static [swc_ecma_ast::Stmt] {
static STMTS: once_cell::sync::Lazy<Vec<swc_ecma_ast::Stmt>> =
once_cell::sync::Lazy::new(|| super::super::parse(DEF.source, DEF.import_path));
&STMTS
}