mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 20:28:58 +00:00
feat(ast): add "abstract" type to MethodDefinition and PropertyDefinition (#2536)
closes #2532 ``` pub enum PropertyDefinitionType { PropertyDefinition, TSAbstractPropertyDefinition, } pub enum MethodDefinitionType { MethodDefinition, TSAbstractMethodDefinition, } ```
This commit is contained in:
parent
3807d83767
commit
3efbbb2e1f
17 changed files with 57 additions and 175 deletions
|
|
@ -1948,8 +1948,6 @@ pub enum ClassElement<'a> {
|
|||
MethodDefinition(Box<'a, MethodDefinition<'a>>),
|
||||
PropertyDefinition(Box<'a, PropertyDefinition<'a>>),
|
||||
AccessorProperty(Box<'a, AccessorProperty<'a>>),
|
||||
TSAbstractMethodDefinition(Box<'a, TSAbstractMethodDefinition<'a>>),
|
||||
TSAbstractPropertyDefinition(Box<'a, TSAbstractPropertyDefinition<'a>>),
|
||||
TSIndexSignature(Box<'a, TSIndexSignature<'a>>),
|
||||
}
|
||||
|
||||
|
|
@ -1960,8 +1958,6 @@ impl<'a> ClassElement<'a> {
|
|||
Self::MethodDefinition(def) => def.r#static,
|
||||
Self::PropertyDefinition(def) => def.r#static,
|
||||
Self::AccessorProperty(def) => def.r#static,
|
||||
Self::TSAbstractMethodDefinition(def) => def.method_definition.r#static,
|
||||
Self::TSAbstractPropertyDefinition(def) => def.property_definition.r#static,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1971,8 +1967,6 @@ impl<'a> ClassElement<'a> {
|
|||
Self::MethodDefinition(def) => def.computed,
|
||||
Self::PropertyDefinition(def) => def.computed,
|
||||
Self::AccessorProperty(def) => def.computed,
|
||||
Self::TSAbstractMethodDefinition(def) => def.method_definition.computed,
|
||||
Self::TSAbstractPropertyDefinition(def) => def.property_definition.computed,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1981,8 +1975,6 @@ impl<'a> ClassElement<'a> {
|
|||
Self::StaticBlock(_) | Self::TSIndexSignature(_) | Self::AccessorProperty(_) => None,
|
||||
Self::MethodDefinition(def) => def.accessibility,
|
||||
Self::PropertyDefinition(def) => def.accessibility,
|
||||
Self::TSAbstractMethodDefinition(def) => def.method_definition.accessibility,
|
||||
Self::TSAbstractPropertyDefinition(def) => def.property_definition.accessibility,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1993,8 +1985,6 @@ impl<'a> ClassElement<'a> {
|
|||
| Self::PropertyDefinition(_)
|
||||
| Self::AccessorProperty(_) => None,
|
||||
Self::MethodDefinition(def) => Some(def.kind),
|
||||
Self::TSAbstractMethodDefinition(def) => Some(def.method_definition.kind),
|
||||
Self::TSAbstractPropertyDefinition(_def) => None,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2004,8 +1994,6 @@ impl<'a> ClassElement<'a> {
|
|||
Self::MethodDefinition(def) => Some(&def.key),
|
||||
Self::PropertyDefinition(def) => Some(&def.key),
|
||||
Self::AccessorProperty(def) => Some(&def.key),
|
||||
Self::TSAbstractMethodDefinition(def) => Some(&def.method_definition.key),
|
||||
Self::TSAbstractPropertyDefinition(def) => Some(&def.property_definition.key),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2015,18 +2003,11 @@ impl<'a> ClassElement<'a> {
|
|||
Self::MethodDefinition(def) => def.key.static_name(),
|
||||
Self::PropertyDefinition(def) => def.key.static_name(),
|
||||
Self::AccessorProperty(def) => def.key.static_name(),
|
||||
Self::TSAbstractMethodDefinition(_def) => None,
|
||||
Self::TSAbstractPropertyDefinition(_def) => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_property(&self) -> bool {
|
||||
matches!(
|
||||
self,
|
||||
Self::PropertyDefinition(_)
|
||||
| Self::AccessorProperty(_)
|
||||
| Self::TSAbstractPropertyDefinition(_)
|
||||
)
|
||||
matches!(self, Self::PropertyDefinition(_) | Self::AccessorProperty(_))
|
||||
}
|
||||
|
||||
pub fn is_ts_empty_body_function(&self) -> bool {
|
||||
|
|
@ -2034,20 +2015,18 @@ impl<'a> ClassElement<'a> {
|
|||
Self::PropertyDefinition(_)
|
||||
| Self::StaticBlock(_)
|
||||
| Self::AccessorProperty(_)
|
||||
| Self::TSAbstractPropertyDefinition(_)
|
||||
| Self::TSIndexSignature(_) => false,
|
||||
Self::MethodDefinition(method) => method.value.body.is_none(),
|
||||
Self::TSAbstractMethodDefinition(_) => true,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_typescript_syntax(&self) -> bool {
|
||||
match self {
|
||||
Self::TSIndexSignature(_)
|
||||
| Self::TSAbstractMethodDefinition(_)
|
||||
| Self::TSAbstractPropertyDefinition(_) => true,
|
||||
Self::TSIndexSignature(_) => true,
|
||||
Self::MethodDefinition(method) => method.value.is_typescript_syntax(),
|
||||
Self::PropertyDefinition(property) => property.declare,
|
||||
Self::PropertyDefinition(property) => {
|
||||
property.r#type == PropertyDefinitionType::TSAbstractPropertyDefinition
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
|
@ -2057,18 +2036,16 @@ impl<'a> ClassElement<'a> {
|
|||
Self::MethodDefinition(method) => !method.decorators.is_empty(),
|
||||
Self::PropertyDefinition(property) => !property.decorators.is_empty(),
|
||||
Self::AccessorProperty(property) => !property.decorators.is_empty(),
|
||||
Self::StaticBlock(_)
|
||||
| Self::TSIndexSignature(_)
|
||||
| Self::TSAbstractMethodDefinition(_)
|
||||
| Self::TSAbstractPropertyDefinition(_) => false,
|
||||
Self::StaticBlock(_) | Self::TSIndexSignature(_) => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize), serde(tag = "type"))]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize), serde(rename_all = "camelCase"))]
|
||||
#[cfg_attr(all(feature = "serde", feature = "wasm"), derive(tsify::Tsify))]
|
||||
pub struct MethodDefinition<'a> {
|
||||
pub r#type: MethodDefinitionType,
|
||||
#[cfg_attr(feature = "serde", serde(flatten))]
|
||||
pub span: Span,
|
||||
pub key: PropertyKey<'a>,
|
||||
|
|
@ -2082,10 +2059,19 @@ pub struct MethodDefinition<'a> {
|
|||
pub decorators: Vec<'a, Decorator<'a>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize))]
|
||||
#[cfg_attr(all(feature = "serde", feature = "wasm"), derive(tsify::Tsify))]
|
||||
pub enum MethodDefinitionType {
|
||||
MethodDefinition,
|
||||
TSAbstractMethodDefinition,
|
||||
}
|
||||
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize), serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize), serde(rename_all = "camelCase"))]
|
||||
#[cfg_attr(all(feature = "serde", feature = "wasm"), derive(tsify::Tsify))]
|
||||
pub struct PropertyDefinition<'a> {
|
||||
pub r#type: PropertyDefinitionType,
|
||||
#[cfg_attr(feature = "serde", serde(flatten))]
|
||||
pub span: Span,
|
||||
pub key: PropertyKey<'a>,
|
||||
|
|
@ -2102,6 +2088,14 @@ pub struct PropertyDefinition<'a> {
|
|||
pub decorators: Vec<'a, Decorator<'a>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize))]
|
||||
#[cfg_attr(all(feature = "serde", feature = "wasm"), derive(tsify::Tsify))]
|
||||
pub enum PropertyDefinitionType {
|
||||
PropertyDefinition,
|
||||
TSAbstractPropertyDefinition,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize), serde(rename_all = "lowercase"))]
|
||||
#[cfg_attr(all(feature = "serde", feature = "wasm"), derive(tsify::Tsify))]
|
||||
|
|
|
|||
|
|
@ -11,16 +11,6 @@ use serde::Serialize;
|
|||
#[allow(clippy::wildcard_imports)]
|
||||
use crate::ast::*;
|
||||
|
||||
#[cfg_attr(
|
||||
all(feature = "serde", feature = "wasm"),
|
||||
wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)
|
||||
)]
|
||||
#[allow(dead_code)]
|
||||
const TS_APPEND_CONTENT: &'static str = r#"
|
||||
export interface TSAbstractPropertyDefinition extends Omit<PropertyDefinition, 'type'> {}
|
||||
export interface TSAbstractMethodDefinition extends Omit<MethodDefinition, 'type'> {}
|
||||
"#;
|
||||
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize), serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[cfg_attr(all(feature = "serde", feature = "wasm"), derive(tsify::Tsify))]
|
||||
|
|
@ -504,20 +494,6 @@ pub struct TSTypeAliasDeclaration<'a> {
|
|||
pub modifiers: Modifiers<'a>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize), serde(tag = "type", rename_all = "camelCase"))]
|
||||
pub struct TSAbstractMethodDefinition<'a> {
|
||||
#[cfg_attr(feature = "serde", serde(flatten))]
|
||||
pub method_definition: MethodDefinition<'a>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize), serde(tag = "type", rename_all = "camelCase"))]
|
||||
pub struct TSAbstractPropertyDefinition<'a> {
|
||||
#[cfg_attr(feature = "serde", serde(flatten))]
|
||||
pub property_definition: PropertyDefinition<'a>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Hash, Clone, PartialEq, Eq, Copy)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize), serde(rename_all = "lowercase"))]
|
||||
#[cfg_attr(all(feature = "serde", feature = "wasm"), derive(tsify::Tsify))]
|
||||
|
|
|
|||
|
|
@ -895,6 +895,7 @@ impl<'a> AstBuilder<'a> {
|
|||
|
||||
pub fn class_property(
|
||||
&self,
|
||||
r#type: PropertyDefinitionType,
|
||||
span: Span,
|
||||
key: PropertyKey<'a>,
|
||||
value: Option<Expression<'a>>,
|
||||
|
|
@ -903,6 +904,7 @@ impl<'a> AstBuilder<'a> {
|
|||
decorators: Vec<'a, Decorator<'a>>,
|
||||
) -> ClassElement<'a> {
|
||||
ClassElement::PropertyDefinition(self.alloc(PropertyDefinition {
|
||||
r#type,
|
||||
span,
|
||||
key,
|
||||
value,
|
||||
|
|
@ -921,6 +923,7 @@ impl<'a> AstBuilder<'a> {
|
|||
|
||||
pub fn class_constructor(&self, span: Span, value: Box<'a, Function<'a>>) -> ClassElement<'a> {
|
||||
ClassElement::MethodDefinition(self.alloc(MethodDefinition {
|
||||
r#type: MethodDefinitionType::MethodDefinition,
|
||||
span,
|
||||
key: self.property_key_expression(self.identifier_reference_expression(
|
||||
IdentifierReference::new(SPAN, "constructor".into()),
|
||||
|
|
|
|||
|
|
@ -117,8 +117,6 @@ impl<'a> GetSpan for ClassElement<'a> {
|
|||
Self::MethodDefinition(def) => def.span,
|
||||
Self::PropertyDefinition(def) => def.span,
|
||||
Self::AccessorProperty(def) => def.span,
|
||||
Self::TSAbstractMethodDefinition(def) => def.method_definition.span,
|
||||
Self::TSAbstractPropertyDefinition(def) => def.property_definition.span,
|
||||
Self::TSIndexSignature(sig) => sig.span,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,12 +12,6 @@ impl<'a> PrivateBoundIdentifiers for ClassElement<'a> {
|
|||
ClassElement::MethodDefinition(def) => def.private_bound_identifiers(),
|
||||
ClassElement::PropertyDefinition(def) => def.private_bound_identifiers(),
|
||||
ClassElement::AccessorProperty(def) => def.private_bound_identifiers(),
|
||||
ClassElement::TSAbstractMethodDefinition(def) => {
|
||||
def.method_definition.private_bound_identifiers()
|
||||
}
|
||||
ClassElement::TSAbstractPropertyDefinition(def) => {
|
||||
def.property_definition.private_bound_identifiers()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,9 +43,7 @@ impl<'a> PropName for ClassElement<'a> {
|
|||
fn prop_name(&self) -> Option<(&str, Span)> {
|
||||
match self {
|
||||
ClassElement::MethodDefinition(def) => def.prop_name(),
|
||||
ClassElement::TSAbstractMethodDefinition(def) => def.method_definition.prop_name(),
|
||||
ClassElement::PropertyDefinition(def) => def.prop_name(),
|
||||
ClassElement::TSAbstractPropertyDefinition(def) => def.property_definition.prop_name(),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -482,12 +482,6 @@ pub trait Visit<'a>: Sized {
|
|||
ClassElement::MethodDefinition(def) => self.visit_method_definition(def),
|
||||
ClassElement::PropertyDefinition(def) => self.visit_property_definition(def),
|
||||
ClassElement::AccessorProperty(_def) => { /* TODO */ }
|
||||
ClassElement::TSAbstractMethodDefinition(def) => {
|
||||
self.visit_method_definition(&def.method_definition);
|
||||
}
|
||||
ClassElement::TSAbstractPropertyDefinition(def) => {
|
||||
self.visit_property_definition(&def.property_definition);
|
||||
}
|
||||
ClassElement::TSIndexSignature(_def) => {}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -482,12 +482,6 @@ pub trait VisitMut<'a>: Sized {
|
|||
ClassElement::MethodDefinition(def) => self.visit_method_definition(def),
|
||||
ClassElement::PropertyDefinition(def) => self.visit_property_definition(def),
|
||||
ClassElement::AccessorProperty(_def) => { /* TODO */ }
|
||||
ClassElement::TSAbstractMethodDefinition(def) => {
|
||||
self.visit_method_definition(&mut def.method_definition);
|
||||
}
|
||||
ClassElement::TSAbstractPropertyDefinition(def) => {
|
||||
self.visit_property_definition(&mut def.property_definition);
|
||||
}
|
||||
ClassElement::TSIndexSignature(_def) => {}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1981,8 +1981,6 @@ impl<'a, const MINIFY: bool> Gen<MINIFY> for ClassElement<'a> {
|
|||
Self::MethodDefinition(elem) => elem.gen(p, ctx),
|
||||
Self::PropertyDefinition(elem) => elem.gen(p, ctx),
|
||||
Self::AccessorProperty(elem) => elem.gen(p, ctx),
|
||||
Self::TSAbstractMethodDefinition(elem) => elem.gen(p, ctx),
|
||||
Self::TSAbstractPropertyDefinition(elem) => elem.gen(p, ctx),
|
||||
Self::TSIndexSignature(elem) => elem.gen(p, ctx),
|
||||
}
|
||||
}
|
||||
|
|
@ -2195,11 +2193,14 @@ impl<'a, const MINIFY: bool> Gen<MINIFY> for StaticBlock<'a> {
|
|||
|
||||
impl<'a, const MINIFY: bool> Gen<MINIFY> for MethodDefinition<'a> {
|
||||
fn gen(&self, p: &mut Codegen<{ MINIFY }>, ctx: Context) {
|
||||
if !p.options.enable_typescript && self.value.is_typescript_syntax() {
|
||||
return;
|
||||
}
|
||||
self.decorators.gen(p, ctx);
|
||||
|
||||
if p.options.enable_typescript
|
||||
&& self.r#type == MethodDefinitionType::TSAbstractMethodDefinition
|
||||
{
|
||||
p.print_str(b"abstract ");
|
||||
}
|
||||
|
||||
if self.r#static {
|
||||
p.print_str(b"static ");
|
||||
}
|
||||
|
|
@ -2248,6 +2249,9 @@ impl<'a, const MINIFY: bool> Gen<MINIFY> for PropertyDefinition<'a> {
|
|||
fn gen(&self, p: &mut Codegen<{ MINIFY }>, ctx: Context) {
|
||||
self.decorators.gen(p, ctx);
|
||||
if p.options.enable_typescript {
|
||||
if self.r#type == PropertyDefinitionType::TSAbstractPropertyDefinition {
|
||||
p.print_str(b"abstract ");
|
||||
}
|
||||
if let Some(accessibility) = &self.accessibility {
|
||||
match accessibility {
|
||||
TSAccessibility::Private => {
|
||||
|
|
|
|||
|
|
@ -646,27 +646,6 @@ impl<'a, const MINIFY: bool> Gen<MINIFY> for TSConstructorType<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, const MINIFY: bool> Gen<MINIFY> for TSAbstractPropertyDefinition<'a> {
|
||||
fn gen(&self, p: &mut Codegen<{ MINIFY }>, ctx: Context) {
|
||||
if !p.options.enable_typescript {
|
||||
return;
|
||||
}
|
||||
|
||||
p.print_str(b"abstract ");
|
||||
self.property_definition.gen(p, ctx);
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, const MINIFY: bool> Gen<MINIFY> for TSAbstractMethodDefinition<'a> {
|
||||
fn gen(&self, p: &mut Codegen<{ MINIFY }>, ctx: Context) {
|
||||
if !p.options.enable_typescript {
|
||||
return;
|
||||
}
|
||||
p.print_str(b"abstract ");
|
||||
self.method_definition.gen(p, ctx);
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, const MINIFY: bool> Gen<MINIFY> for TSImportEqualsDeclaration<'a> {
|
||||
fn gen(&self, p: &mut Codegen<{ MINIFY }>, ctx: Context) {
|
||||
if !p.options.enable_typescript {
|
||||
|
|
|
|||
|
|
@ -74,16 +74,6 @@ impl Rule for NoStaticOnlyClass {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
oxc_ast::ast::ClassElement::TSAbstractMethodDefinition(v) => {
|
||||
if v.method_definition.accessibility.is_some() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
oxc_ast::ast::ClassElement::TSAbstractPropertyDefinition(v) => {
|
||||
if v.property_definition.accessibility.is_some() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
oxc_ast::ast::ClassElement::AccessorProperty(_)
|
||||
| oxc_ast::ast::ClassElement::StaticBlock(_)
|
||||
| oxc_ast::ast::ClassElement::TSIndexSignature(_) => {}
|
||||
|
|
|
|||
|
|
@ -375,7 +375,13 @@ impl<'a> ParserImpl<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
let r#type = if r#abstract {
|
||||
MethodDefinitionType::TSAbstractMethodDefinition
|
||||
} else {
|
||||
MethodDefinitionType::MethodDefinition
|
||||
};
|
||||
let method_definition = MethodDefinition {
|
||||
r#type,
|
||||
span: self.end_span(span),
|
||||
key,
|
||||
value,
|
||||
|
|
@ -387,14 +393,7 @@ impl<'a> ParserImpl<'a> {
|
|||
optional,
|
||||
decorators,
|
||||
};
|
||||
|
||||
if r#abstract {
|
||||
Ok(ClassElement::TSAbstractMethodDefinition(
|
||||
self.ast.alloc(TSAbstractMethodDefinition { method_definition }),
|
||||
))
|
||||
} else {
|
||||
Ok(ClassElement::MethodDefinition(self.ast.alloc(method_definition)))
|
||||
}
|
||||
Ok(ClassElement::MethodDefinition(self.ast.alloc(method_definition)))
|
||||
}
|
||||
|
||||
/// `FieldDefinition`[?Yield, ?Await] ;
|
||||
|
|
@ -426,7 +425,13 @@ impl<'a> ParserImpl<'a> {
|
|||
};
|
||||
self.asi()?;
|
||||
|
||||
let r#type = if r#abstract {
|
||||
PropertyDefinitionType::TSAbstractPropertyDefinition
|
||||
} else {
|
||||
PropertyDefinitionType::PropertyDefinition
|
||||
};
|
||||
let property_definition = PropertyDefinition {
|
||||
r#type,
|
||||
span: self.end_span(span),
|
||||
key,
|
||||
value,
|
||||
|
|
@ -441,14 +446,7 @@ impl<'a> ParserImpl<'a> {
|
|||
definite,
|
||||
decorators: self.state.consume_decorators(),
|
||||
};
|
||||
|
||||
if r#abstract {
|
||||
Ok(ClassElement::TSAbstractPropertyDefinition(
|
||||
self.ast.alloc(TSAbstractPropertyDefinition { property_definition }),
|
||||
))
|
||||
} else {
|
||||
Ok(ClassElement::PropertyDefinition(self.ast.alloc(property_definition)))
|
||||
}
|
||||
Ok(ClassElement::PropertyDefinition(self.ast.alloc(property_definition)))
|
||||
}
|
||||
|
||||
/// `ClassStaticBlockStatementList` :
|
||||
|
|
|
|||
|
|
@ -219,9 +219,6 @@ fn should_print_semicolon_after_class_property<'a>(
|
|||
|
||||
match next_node {
|
||||
ClassElement::PropertyDefinition(property_definition) => property_definition.computed,
|
||||
ClassElement::TSAbstractPropertyDefinition(property_definition) => {
|
||||
property_definition.0.property_definition.computed
|
||||
}
|
||||
ClassElement::StaticBlock(_) => false,
|
||||
ClassElement::AccessorProperty(_) | ClassElement::TSIndexSignature(_) => true,
|
||||
ClassElement::MethodDefinition(method_definition) => {
|
||||
|
|
@ -240,24 +237,6 @@ fn should_print_semicolon_after_class_property<'a>(
|
|||
return true;
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
ClassElement::TSAbstractMethodDefinition(ts_abstract_method_definition) => {
|
||||
let is_async = ts_abstract_method_definition.method_definition.value.r#async;
|
||||
|
||||
if is_async
|
||||
|| ts_abstract_method_definition.method_definition.kind == MethodDefinitionKind::Get
|
||||
|| ts_abstract_method_definition.method_definition.kind == MethodDefinitionKind::Set
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
let is_generator = ts_abstract_method_definition.method_definition.value.generator;
|
||||
|
||||
if ts_abstract_method_definition.method_definition.computed || is_generator {
|
||||
return true;
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1966,8 +1966,6 @@ impl<'a> Format<'a> for ClassElement<'a> {
|
|||
ClassElement::MethodDefinition(c) => c.format(p),
|
||||
ClassElement::PropertyDefinition(c) => c.format(p),
|
||||
ClassElement::AccessorProperty(c) => c.format(p),
|
||||
ClassElement::TSAbstractMethodDefinition(c) => c.format(p),
|
||||
ClassElement::TSAbstractPropertyDefinition(c) => c.format(p),
|
||||
ClassElement::TSIndexSignature(c) => c.format(p),
|
||||
}
|
||||
}
|
||||
|
|
@ -2222,18 +2220,6 @@ impl<'a> Format<'a> for RegExpFlags {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> Format<'a> for TSAbstractMethodDefinition<'a> {
|
||||
fn format(&self, p: &mut Prettier<'a>) -> Doc<'a> {
|
||||
line!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Format<'a> for TSAbstractPropertyDefinition<'a> {
|
||||
fn format(&self, p: &mut Prettier<'a>) -> Doc<'a> {
|
||||
line!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Format<'a> for TSIndexSignature<'a> {
|
||||
fn format(&self, p: &mut Prettier<'a>) -> Doc<'a> {
|
||||
line!()
|
||||
|
|
|
|||
|
|
@ -102,7 +102,9 @@ impl<'a> ClassStaticBlock<'a> {
|
|||
}
|
||||
};
|
||||
|
||||
*element = self.ast.class_property(SPAN, key, value, false, true, self.ast.new_vec());
|
||||
let r#type = PropertyDefinitionType::PropertyDefinition;
|
||||
*element =
|
||||
self.ast.class_property(r#type, SPAN, key, value, false, true, self.ast.new_vec());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
prettier_babel Summary:
|
||||
AST Parsed : 2096/2096 (100.00%)
|
||||
Positive Passed: 1899/2096 (90.60%)
|
||||
Positive Passed: 1903/2096 (90.79%)
|
||||
Expect to Parse: "comments/attachComment-false/array-expression-trailing-comma/input.js"
|
||||
Expect to Parse: "comments/basic/array-expression-trailing-comma/input.js"
|
||||
Expect to Parse: "comments/basic/object-accessor-computed/input.js"
|
||||
|
|
@ -29,12 +29,8 @@ Expect to Parse: "esprima/es2015-generator/generator-method-with-yield-delegate/
|
|||
Expect to Parse: "esprima/es2015-import-declaration/import-module/input.js"
|
||||
Expect to Parse: "esprima/expression-primary-object/migrated_0036/input.js"
|
||||
Expect to Parse: "typescript/cast/as-const/input.ts"
|
||||
Expect to Parse: "typescript/class/abstract/input.ts"
|
||||
Expect to Parse: "typescript/class/declare/input.ts"
|
||||
Expect to Parse: "typescript/class/index-signature/input.ts"
|
||||
Expect to Parse: "typescript/class/modifiers-accessors/input.ts"
|
||||
Expect to Parse: "typescript/class/modifiers-methods-async/input.ts"
|
||||
Expect to Parse: "typescript/class/modifiers-properties/input.ts"
|
||||
Expect to Parse: "typescript/const/initializer-ambient-context/input.ts"
|
||||
Expect to Parse: "typescript/declare/interface/input.ts"
|
||||
Expect to Parse: "typescript/declare/interface-new-line/input.ts"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
prettier_typescript Summary:
|
||||
AST Parsed : 5243/5243 (100.00%)
|
||||
Positive Passed: 2861/5243 (54.57%)
|
||||
Positive Passed: 2864/5243 (54.63%)
|
||||
Expect to Parse: "compiler/DeclarationErrorsNoEmitOnError.ts"
|
||||
Expect to Parse: "compiler/abstractInterfaceIdentifierName.ts"
|
||||
Expect to Parse: "compiler/abstractPropertyBasics.ts"
|
||||
|
|
@ -1138,7 +1138,6 @@ Expect to Parse: "compiler/readonlyInDeclarationFile.ts"
|
|||
Expect to Parse: "compiler/reboundBaseClassSymbol.ts"
|
||||
Expect to Parse: "compiler/rectype.ts"
|
||||
Expect to Parse: "compiler/recursiveArrayNotCircular.ts"
|
||||
Expect to Parse: "compiler/recursiveClassBaseType.ts"
|
||||
Expect to Parse: "compiler/recursiveClassInstantiationsWithDefaultConstructors.ts"
|
||||
Expect to Parse: "compiler/recursiveCloduleReference.ts"
|
||||
Expect to Parse: "compiler/recursiveConditionalCrash1.ts"
|
||||
|
|
@ -1494,7 +1493,6 @@ Expect to Parse: "conformance/classes/mixinAbstractClasses.ts"
|
|||
Expect to Parse: "conformance/classes/mixinAbstractClassesReturnTypeInference.ts"
|
||||
Expect to Parse: "conformance/classes/mixinClassesAnnotated.ts"
|
||||
Expect to Parse: "conformance/classes/mixinClassesAnonymous.ts"
|
||||
Expect to Parse: "conformance/classes/propertyMemberDeclarations/abstractProperty.ts"
|
||||
Expect to Parse: "conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty5.ts"
|
||||
Expect to Parse: "conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty8.ts"
|
||||
Expect to Parse: "conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty9.ts"
|
||||
|
|
@ -1946,7 +1944,6 @@ Expect to Parse: "conformance/jsx/tsxTypeArgumentsJsxPreserveOutput.tsx"
|
|||
Expect to Parse: "conformance/jsx/tsxTypeErrors.tsx"
|
||||
Expect to Parse: "conformance/jsx/tsxUnionElementType5.tsx"
|
||||
Expect to Parse: "conformance/jsx/tsxUnionTypeComponent1.tsx"
|
||||
Expect to Parse: "conformance/override/override10.ts"
|
||||
Expect to Parse: "conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclarationIndexSignature1.ts"
|
||||
Expect to Parse: "conformance/parser/ecmascript5/EnumDeclarations/parserEnum1.ts"
|
||||
Expect to Parse: "conformance/parser/ecmascript5/EnumDeclarations/parserEnum2.ts"
|
||||
|
|
|
|||
Loading…
Reference in a new issue