mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
feat(semantic): align class scope with typescript (#4195)
```ts
class Klass <T> extends Root <R> {}
// ^^^^^ ^^^ ^^^^ ^^^ ^^
// id type_paramter super_class super_type_parameters body
```
I reorder fields according to the order above
The class scope is not defined in the spec. But we need to create a scope for `class` to store `TypeParamters`
This commit is contained in:
parent
ab41c52485
commit
20cdb1fe0a
14 changed files with 451 additions and 484 deletions
|
|
@ -1592,12 +1592,12 @@ pub struct Class<'a> {
|
|||
pub decorators: Vec<'a, Decorator<'a>>,
|
||||
#[scope(enter_before)]
|
||||
pub id: Option<BindingIdentifier<'a>>,
|
||||
pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
|
||||
#[visit_as(ClassHeritage)]
|
||||
pub super_class: Option<Expression<'a>>,
|
||||
pub body: Box<'a, ClassBody<'a>>,
|
||||
pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
|
||||
pub super_type_parameters: Option<Box<'a, TSTypeParameterInstantiation<'a>>>,
|
||||
pub implements: Option<Vec<'a, TSClassImplements<'a>>>,
|
||||
pub body: Box<'a, ClassBody<'a>>,
|
||||
pub r#abstract: bool,
|
||||
pub declare: bool,
|
||||
pub scope_id: Cell<Option<ScopeId>>,
|
||||
|
|
|
|||
|
|
@ -485,29 +485,29 @@ impl<'a> AstBuilder<'a> {
|
|||
span: Span,
|
||||
decorators: Vec<'a, Decorator<'a>>,
|
||||
id: Option<BindingIdentifier<'a>>,
|
||||
type_parameters: T1,
|
||||
super_class: Option<Expression<'a>>,
|
||||
body: T1,
|
||||
type_parameters: T2,
|
||||
super_type_parameters: T3,
|
||||
super_type_parameters: T2,
|
||||
implements: Option<Vec<'a, TSClassImplements<'a>>>,
|
||||
body: T3,
|
||||
r#abstract: bool,
|
||||
declare: bool,
|
||||
) -> Expression<'a>
|
||||
where
|
||||
T1: IntoIn<'a, Box<'a, ClassBody<'a>>>,
|
||||
T2: IntoIn<'a, Option<Box<'a, TSTypeParameterDeclaration<'a>>>>,
|
||||
T3: IntoIn<'a, Option<Box<'a, TSTypeParameterInstantiation<'a>>>>,
|
||||
T1: IntoIn<'a, Option<Box<'a, TSTypeParameterDeclaration<'a>>>>,
|
||||
T2: IntoIn<'a, Option<Box<'a, TSTypeParameterInstantiation<'a>>>>,
|
||||
T3: IntoIn<'a, Box<'a, ClassBody<'a>>>,
|
||||
{
|
||||
Expression::ClassExpression(self.alloc(self.class(
|
||||
r#type,
|
||||
span,
|
||||
decorators,
|
||||
id,
|
||||
super_class,
|
||||
body,
|
||||
type_parameters,
|
||||
super_class,
|
||||
super_type_parameters,
|
||||
implements,
|
||||
body,
|
||||
r#abstract,
|
||||
declare,
|
||||
)))
|
||||
|
|
@ -2728,29 +2728,29 @@ impl<'a> AstBuilder<'a> {
|
|||
span: Span,
|
||||
decorators: Vec<'a, Decorator<'a>>,
|
||||
id: Option<BindingIdentifier<'a>>,
|
||||
type_parameters: T1,
|
||||
super_class: Option<Expression<'a>>,
|
||||
body: T1,
|
||||
type_parameters: T2,
|
||||
super_type_parameters: T3,
|
||||
super_type_parameters: T2,
|
||||
implements: Option<Vec<'a, TSClassImplements<'a>>>,
|
||||
body: T3,
|
||||
r#abstract: bool,
|
||||
declare: bool,
|
||||
) -> Declaration<'a>
|
||||
where
|
||||
T1: IntoIn<'a, Box<'a, ClassBody<'a>>>,
|
||||
T2: IntoIn<'a, Option<Box<'a, TSTypeParameterDeclaration<'a>>>>,
|
||||
T3: IntoIn<'a, Option<Box<'a, TSTypeParameterInstantiation<'a>>>>,
|
||||
T1: IntoIn<'a, Option<Box<'a, TSTypeParameterDeclaration<'a>>>>,
|
||||
T2: IntoIn<'a, Option<Box<'a, TSTypeParameterInstantiation<'a>>>>,
|
||||
T3: IntoIn<'a, Box<'a, ClassBody<'a>>>,
|
||||
{
|
||||
Declaration::ClassDeclaration(self.alloc(self.class(
|
||||
r#type,
|
||||
span,
|
||||
decorators,
|
||||
id,
|
||||
super_class,
|
||||
body,
|
||||
type_parameters,
|
||||
super_class,
|
||||
super_type_parameters,
|
||||
implements,
|
||||
body,
|
||||
r#abstract,
|
||||
declare,
|
||||
)))
|
||||
|
|
@ -3942,29 +3942,29 @@ impl<'a> AstBuilder<'a> {
|
|||
span: Span,
|
||||
decorators: Vec<'a, Decorator<'a>>,
|
||||
id: Option<BindingIdentifier<'a>>,
|
||||
type_parameters: T1,
|
||||
super_class: Option<Expression<'a>>,
|
||||
body: T1,
|
||||
type_parameters: T2,
|
||||
super_type_parameters: T3,
|
||||
super_type_parameters: T2,
|
||||
implements: Option<Vec<'a, TSClassImplements<'a>>>,
|
||||
body: T3,
|
||||
r#abstract: bool,
|
||||
declare: bool,
|
||||
) -> Class<'a>
|
||||
where
|
||||
T1: IntoIn<'a, Box<'a, ClassBody<'a>>>,
|
||||
T2: IntoIn<'a, Option<Box<'a, TSTypeParameterDeclaration<'a>>>>,
|
||||
T3: IntoIn<'a, Option<Box<'a, TSTypeParameterInstantiation<'a>>>>,
|
||||
T1: IntoIn<'a, Option<Box<'a, TSTypeParameterDeclaration<'a>>>>,
|
||||
T2: IntoIn<'a, Option<Box<'a, TSTypeParameterInstantiation<'a>>>>,
|
||||
T3: IntoIn<'a, Box<'a, ClassBody<'a>>>,
|
||||
{
|
||||
Class {
|
||||
r#type,
|
||||
span,
|
||||
decorators,
|
||||
id,
|
||||
super_class,
|
||||
body: body.into_in(self.allocator),
|
||||
type_parameters: type_parameters.into_in(self.allocator),
|
||||
super_class,
|
||||
super_type_parameters: super_type_parameters.into_in(self.allocator),
|
||||
implements,
|
||||
body: body.into_in(self.allocator),
|
||||
r#abstract,
|
||||
declare,
|
||||
scope_id: Default::default(),
|
||||
|
|
@ -3978,29 +3978,29 @@ impl<'a> AstBuilder<'a> {
|
|||
span: Span,
|
||||
decorators: Vec<'a, Decorator<'a>>,
|
||||
id: Option<BindingIdentifier<'a>>,
|
||||
type_parameters: T1,
|
||||
super_class: Option<Expression<'a>>,
|
||||
body: T1,
|
||||
type_parameters: T2,
|
||||
super_type_parameters: T3,
|
||||
super_type_parameters: T2,
|
||||
implements: Option<Vec<'a, TSClassImplements<'a>>>,
|
||||
body: T3,
|
||||
r#abstract: bool,
|
||||
declare: bool,
|
||||
) -> Box<'a, Class<'a>>
|
||||
where
|
||||
T1: IntoIn<'a, Box<'a, ClassBody<'a>>>,
|
||||
T2: IntoIn<'a, Option<Box<'a, TSTypeParameterDeclaration<'a>>>>,
|
||||
T3: IntoIn<'a, Option<Box<'a, TSTypeParameterInstantiation<'a>>>>,
|
||||
T1: IntoIn<'a, Option<Box<'a, TSTypeParameterDeclaration<'a>>>>,
|
||||
T2: IntoIn<'a, Option<Box<'a, TSTypeParameterInstantiation<'a>>>>,
|
||||
T3: IntoIn<'a, Box<'a, ClassBody<'a>>>,
|
||||
{
|
||||
self.class(
|
||||
r#type,
|
||||
span,
|
||||
decorators,
|
||||
id,
|
||||
super_class,
|
||||
body,
|
||||
type_parameters,
|
||||
super_class,
|
||||
super_type_parameters,
|
||||
implements,
|
||||
body,
|
||||
r#abstract,
|
||||
declare,
|
||||
)
|
||||
|
|
@ -4943,29 +4943,29 @@ impl<'a> AstBuilder<'a> {
|
|||
span: Span,
|
||||
decorators: Vec<'a, Decorator<'a>>,
|
||||
id: Option<BindingIdentifier<'a>>,
|
||||
type_parameters: T1,
|
||||
super_class: Option<Expression<'a>>,
|
||||
body: T1,
|
||||
type_parameters: T2,
|
||||
super_type_parameters: T3,
|
||||
super_type_parameters: T2,
|
||||
implements: Option<Vec<'a, TSClassImplements<'a>>>,
|
||||
body: T3,
|
||||
r#abstract: bool,
|
||||
declare: bool,
|
||||
) -> ExportDefaultDeclarationKind<'a>
|
||||
where
|
||||
T1: IntoIn<'a, Box<'a, ClassBody<'a>>>,
|
||||
T2: IntoIn<'a, Option<Box<'a, TSTypeParameterDeclaration<'a>>>>,
|
||||
T3: IntoIn<'a, Option<Box<'a, TSTypeParameterInstantiation<'a>>>>,
|
||||
T1: IntoIn<'a, Option<Box<'a, TSTypeParameterDeclaration<'a>>>>,
|
||||
T2: IntoIn<'a, Option<Box<'a, TSTypeParameterInstantiation<'a>>>>,
|
||||
T3: IntoIn<'a, Box<'a, ClassBody<'a>>>,
|
||||
{
|
||||
ExportDefaultDeclarationKind::ClassDeclaration(self.alloc(self.class(
|
||||
r#type,
|
||||
span,
|
||||
decorators,
|
||||
id,
|
||||
super_class,
|
||||
body,
|
||||
type_parameters,
|
||||
super_class,
|
||||
super_type_parameters,
|
||||
implements,
|
||||
body,
|
||||
r#abstract,
|
||||
declare,
|
||||
)))
|
||||
|
|
|
|||
|
|
@ -803,6 +803,16 @@ pub trait Visit<'a>: Sized {
|
|||
walk_class_heritage(self, it);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_ts_class_implementses(&mut self, it: &Vec<'a, TSClassImplements<'a>>) {
|
||||
walk_ts_class_implementses(self, it);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_ts_class_implements(&mut self, it: &TSClassImplements<'a>) {
|
||||
walk_ts_class_implements(self, it);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_class_body(&mut self, it: &ClassBody<'a>) {
|
||||
walk_class_body(self, it);
|
||||
|
|
@ -843,16 +853,6 @@ pub trait Visit<'a>: Sized {
|
|||
walk_accessor_property(self, it);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_ts_class_implementses(&mut self, it: &Vec<'a, TSClassImplements<'a>>) {
|
||||
walk_ts_class_implementses(self, it);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_ts_class_implements(&mut self, it: &TSClassImplements<'a>) {
|
||||
walk_ts_class_implements(self, it);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_conditional_expression(&mut self, it: &ConditionalExpression<'a>) {
|
||||
walk_conditional_expression(self, it);
|
||||
|
|
@ -2929,19 +2929,19 @@ pub mod walk {
|
|||
if let Some(id) = &it.id {
|
||||
visitor.visit_binding_identifier(id);
|
||||
}
|
||||
if let Some(super_class) = &it.super_class {
|
||||
visitor.visit_class_heritage(super_class);
|
||||
}
|
||||
visitor.visit_class_body(&it.body);
|
||||
if let Some(type_parameters) = &it.type_parameters {
|
||||
visitor.visit_ts_type_parameter_declaration(type_parameters);
|
||||
}
|
||||
if let Some(super_class) = &it.super_class {
|
||||
visitor.visit_class_heritage(super_class);
|
||||
}
|
||||
if let Some(super_type_parameters) = &it.super_type_parameters {
|
||||
visitor.visit_ts_type_parameter_instantiation(super_type_parameters);
|
||||
}
|
||||
if let Some(implements) = &it.implements {
|
||||
visitor.visit_ts_class_implementses(implements);
|
||||
}
|
||||
visitor.visit_class_body(&it.body);
|
||||
visitor.leave_scope();
|
||||
visitor.leave_node(kind);
|
||||
}
|
||||
|
|
@ -2953,6 +2953,27 @@ pub mod walk {
|
|||
visitor.leave_node(kind);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn walk_ts_class_implementses<'a, V: Visit<'a>>(
|
||||
visitor: &mut V,
|
||||
it: &Vec<'a, TSClassImplements<'a>>,
|
||||
) {
|
||||
for el in it.iter() {
|
||||
visitor.visit_ts_class_implements(el);
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn walk_ts_class_implements<'a, V: Visit<'a>>(visitor: &mut V, it: &TSClassImplements<'a>) {
|
||||
let kind = AstKind::TSClassImplements(visitor.alloc(it));
|
||||
visitor.enter_node(kind);
|
||||
visitor.visit_ts_type_name(&it.expression);
|
||||
if let Some(type_parameters) = &it.type_parameters {
|
||||
visitor.visit_ts_type_parameter_instantiation(type_parameters);
|
||||
}
|
||||
visitor.leave_node(kind);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn walk_class_body<'a, V: Visit<'a>>(visitor: &mut V, it: &ClassBody<'a>) {
|
||||
let kind = AstKind::ClassBody(visitor.alloc(it));
|
||||
|
|
@ -3072,27 +3093,6 @@ pub mod walk {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn walk_ts_class_implementses<'a, V: Visit<'a>>(
|
||||
visitor: &mut V,
|
||||
it: &Vec<'a, TSClassImplements<'a>>,
|
||||
) {
|
||||
for el in it.iter() {
|
||||
visitor.visit_ts_class_implements(el);
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn walk_ts_class_implements<'a, V: Visit<'a>>(visitor: &mut V, it: &TSClassImplements<'a>) {
|
||||
let kind = AstKind::TSClassImplements(visitor.alloc(it));
|
||||
visitor.enter_node(kind);
|
||||
visitor.visit_ts_type_name(&it.expression);
|
||||
if let Some(type_parameters) = &it.type_parameters {
|
||||
visitor.visit_ts_type_parameter_instantiation(type_parameters);
|
||||
}
|
||||
visitor.leave_node(kind);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn walk_conditional_expression<'a, V: Visit<'a>>(
|
||||
visitor: &mut V,
|
||||
|
|
|
|||
|
|
@ -795,6 +795,16 @@ pub trait VisitMut<'a>: Sized {
|
|||
walk_class_heritage(self, it);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_ts_class_implementses(&mut self, it: &mut Vec<'a, TSClassImplements<'a>>) {
|
||||
walk_ts_class_implementses(self, it);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_ts_class_implements(&mut self, it: &mut TSClassImplements<'a>) {
|
||||
walk_ts_class_implements(self, it);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_class_body(&mut self, it: &mut ClassBody<'a>) {
|
||||
walk_class_body(self, it);
|
||||
|
|
@ -835,16 +845,6 @@ pub trait VisitMut<'a>: Sized {
|
|||
walk_accessor_property(self, it);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_ts_class_implementses(&mut self, it: &mut Vec<'a, TSClassImplements<'a>>) {
|
||||
walk_ts_class_implementses(self, it);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_ts_class_implements(&mut self, it: &mut TSClassImplements<'a>) {
|
||||
walk_ts_class_implements(self, it);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_conditional_expression(&mut self, it: &mut ConditionalExpression<'a>) {
|
||||
walk_conditional_expression(self, it);
|
||||
|
|
@ -3053,19 +3053,19 @@ pub mod walk_mut {
|
|||
if let Some(id) = &mut it.id {
|
||||
visitor.visit_binding_identifier(id);
|
||||
}
|
||||
if let Some(super_class) = &mut it.super_class {
|
||||
visitor.visit_class_heritage(super_class);
|
||||
}
|
||||
visitor.visit_class_body(&mut it.body);
|
||||
if let Some(type_parameters) = &mut it.type_parameters {
|
||||
visitor.visit_ts_type_parameter_declaration(type_parameters);
|
||||
}
|
||||
if let Some(super_class) = &mut it.super_class {
|
||||
visitor.visit_class_heritage(super_class);
|
||||
}
|
||||
if let Some(super_type_parameters) = &mut it.super_type_parameters {
|
||||
visitor.visit_ts_type_parameter_instantiation(super_type_parameters);
|
||||
}
|
||||
if let Some(implements) = &mut it.implements {
|
||||
visitor.visit_ts_class_implementses(implements);
|
||||
}
|
||||
visitor.visit_class_body(&mut it.body);
|
||||
visitor.leave_scope();
|
||||
visitor.leave_node(kind);
|
||||
}
|
||||
|
|
@ -3077,6 +3077,30 @@ pub mod walk_mut {
|
|||
visitor.leave_node(kind);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn walk_ts_class_implementses<'a, V: VisitMut<'a>>(
|
||||
visitor: &mut V,
|
||||
it: &mut Vec<'a, TSClassImplements<'a>>,
|
||||
) {
|
||||
for el in it.iter_mut() {
|
||||
visitor.visit_ts_class_implements(el);
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn walk_ts_class_implements<'a, V: VisitMut<'a>>(
|
||||
visitor: &mut V,
|
||||
it: &mut TSClassImplements<'a>,
|
||||
) {
|
||||
let kind = AstType::TSClassImplements;
|
||||
visitor.enter_node(kind);
|
||||
visitor.visit_ts_type_name(&mut it.expression);
|
||||
if let Some(type_parameters) = &mut it.type_parameters {
|
||||
visitor.visit_ts_type_parameter_instantiation(type_parameters);
|
||||
}
|
||||
visitor.leave_node(kind);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn walk_class_body<'a, V: VisitMut<'a>>(visitor: &mut V, it: &mut ClassBody<'a>) {
|
||||
let kind = AstType::ClassBody;
|
||||
|
|
@ -3205,30 +3229,6 @@ pub mod walk_mut {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn walk_ts_class_implementses<'a, V: VisitMut<'a>>(
|
||||
visitor: &mut V,
|
||||
it: &mut Vec<'a, TSClassImplements<'a>>,
|
||||
) {
|
||||
for el in it.iter_mut() {
|
||||
visitor.visit_ts_class_implements(el);
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn walk_ts_class_implements<'a, V: VisitMut<'a>>(
|
||||
visitor: &mut V,
|
||||
it: &mut TSClassImplements<'a>,
|
||||
) {
|
||||
let kind = AstType::TSClassImplements;
|
||||
visitor.enter_node(kind);
|
||||
visitor.visit_ts_type_name(&mut it.expression);
|
||||
if let Some(type_parameters) = &mut it.type_parameters {
|
||||
visitor.visit_ts_type_parameter_instantiation(type_parameters);
|
||||
}
|
||||
visitor.leave_node(kind);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn walk_conditional_expression<'a, V: VisitMut<'a>>(
|
||||
visitor: &mut V,
|
||||
|
|
|
|||
|
|
@ -490,11 +490,11 @@ impl<'a> IsolatedDeclarations<'a> {
|
|||
decl.span,
|
||||
self.ast.vec(),
|
||||
self.ast.copy(&decl.id),
|
||||
self.ast.copy(&decl.super_class),
|
||||
body,
|
||||
self.ast.copy(&decl.type_parameters),
|
||||
self.ast.copy(&decl.super_class),
|
||||
self.ast.copy(&decl.super_type_parameters),
|
||||
self.ast.copy(&decl.implements),
|
||||
body,
|
||||
decl.r#abstract,
|
||||
declare.unwrap_or_else(|| self.is_declare()),
|
||||
))
|
||||
|
|
|
|||
|
|
@ -175,6 +175,14 @@ source: crates/oxc_linter/src/tester.rs
|
|||
3 │ constructor(foo: String | Object | Function) {}
|
||||
╰────
|
||||
|
||||
⚠ typescript-eslint(ban-types): 'The `Object` type actually means "any non-nullish value"
|
||||
╭─[ban_types.tsx:2:68]
|
||||
1 │
|
||||
2 │ class Test<T = Boolean> extends Foo<String> implements Bar<Object> {
|
||||
· ──────
|
||||
3 │ constructor(foo: String | Object | Function) {}
|
||||
╰────
|
||||
|
||||
⚠ typescript-eslint(ban-types): Do not use "String" as a type. Use "string" instead
|
||||
╭─[ban_types.tsx:3:28]
|
||||
2 │ class Test<T = Boolean> extends Foo<String> implements Bar<Object> {
|
||||
|
|
|
|||
|
|
@ -99,11 +99,11 @@ impl<'a> ParserImpl<'a> {
|
|||
self.end_span(start_span),
|
||||
decorators,
|
||||
id,
|
||||
super_class,
|
||||
body,
|
||||
type_parameters,
|
||||
super_class,
|
||||
super_type_parameters,
|
||||
implements,
|
||||
body,
|
||||
modifiers.contains_abstract(),
|
||||
modifiers.contains_declare(),
|
||||
))
|
||||
|
|
|
|||
|
|
@ -78,13 +78,17 @@ impl<'a> Binder for VariableDeclarator<'a> {
|
|||
|
||||
impl<'a> Binder for Class<'a> {
|
||||
fn bind(&self, builder: &mut SemanticBuilder) {
|
||||
let Some(ident) = &self.id else { return };
|
||||
if !self.declare {
|
||||
let Some(ident) = &self.id else { return };
|
||||
let symbol_id = builder.declare_symbol(
|
||||
ident.span,
|
||||
&ident.name,
|
||||
SymbolFlags::Class,
|
||||
SymbolFlags::ClassExcludes,
|
||||
if self.is_declaration() {
|
||||
SymbolFlags::ClassExcludes
|
||||
} else {
|
||||
SymbolFlags::empty()
|
||||
},
|
||||
);
|
||||
ident.symbol_id.set(Some(symbol_id));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -414,6 +414,16 @@ impl<'a> SemanticBuilder<'a> {
|
|||
self.symbols.union_flag(symbol_id, SymbolFlags::Export);
|
||||
}
|
||||
}
|
||||
|
||||
fn bind_class_expression(&mut self) {
|
||||
if let AstKind::Class(class) = self.nodes.kind(self.current_node_id) {
|
||||
if class.is_expression() {
|
||||
// We must to bind class expression when enter BindingIdentifier,
|
||||
// because we should add binding to current scope
|
||||
class.bind(self);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Visit<'a> for SemanticBuilder<'a> {
|
||||
|
|
@ -444,6 +454,10 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
|
|||
if self.unresolved_references.len() <= self.current_scope_depth {
|
||||
self.unresolved_references.push(UnresolvedReferences::default());
|
||||
}
|
||||
|
||||
if !flags.is_top() {
|
||||
self.bind_class_expression();
|
||||
}
|
||||
}
|
||||
|
||||
fn leave_scope(&mut self) {
|
||||
|
|
@ -1453,46 +1467,6 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
|
|||
self.leave_scope();
|
||||
}
|
||||
|
||||
fn visit_class(&mut self, class: &Class<'a>) {
|
||||
// Class level decorators are transpiled as functions outside of the class taking the class
|
||||
// itself as argument. They should be visited before class is entered. E.g., they inherit
|
||||
// strict mode from the enclosing scope rather than from class.
|
||||
for decorator in &class.decorators {
|
||||
self.visit_decorator(decorator);
|
||||
}
|
||||
let kind = AstKind::Class(self.alloc(class));
|
||||
|
||||
// FIXME(don): Should we enter a scope when visiting class declarations?
|
||||
let is_class_expr = class.r#type == ClassType::ClassExpression;
|
||||
if is_class_expr {
|
||||
// Class expressions create a temporary scope with the class name as its only variable
|
||||
// E.g., `let c = class A { foo() { console.log(A) } }`
|
||||
self.enter_scope(ScopeFlags::empty(), &class.scope_id);
|
||||
}
|
||||
|
||||
self.enter_node(kind);
|
||||
|
||||
if let Some(id) = &class.id {
|
||||
self.visit_binding_identifier(id);
|
||||
}
|
||||
if let Some(parameters) = &class.type_parameters {
|
||||
self.visit_ts_type_parameter_declaration(parameters);
|
||||
}
|
||||
|
||||
if let Some(super_class) = &class.super_class {
|
||||
self.visit_class_heritage(super_class);
|
||||
}
|
||||
if let Some(super_parameters) = &class.super_type_parameters {
|
||||
self.visit_ts_type_parameter_instantiation(super_parameters);
|
||||
}
|
||||
self.visit_class_body(&class.body);
|
||||
|
||||
self.leave_node(kind);
|
||||
if is_class_expr {
|
||||
self.leave_scope();
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_arrow_function_expression(&mut self, expr: &ArrowFunctionExpression<'a>) {
|
||||
let kind = AstKind::ArrowFunctionExpression(self.alloc(expr));
|
||||
self.enter_scope(ScopeFlags::Function | ScopeFlags::Arrow, &expr.scope_id);
|
||||
|
|
@ -1606,7 +1580,9 @@ impl<'a> SemanticBuilder<'a> {
|
|||
}
|
||||
AstKind::Class(class) => {
|
||||
self.current_node_flags |= NodeFlags::Class;
|
||||
class.bind(self);
|
||||
if class.is_declaration() {
|
||||
class.bind(self);
|
||||
}
|
||||
self.current_symbol_flags -= SymbolFlags::Export;
|
||||
self.make_all_namespaces_valuelike();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,8 +137,15 @@ pub fn check_identifier<'a>(name: &str, span: Span, node: &AstNode<'a>, ctx: &Se
|
|||
if ctx.source_type.is_module() {
|
||||
return ctx.error(reserved_keyword(name, span));
|
||||
}
|
||||
|
||||
// It is a Syntax Error if ClassStaticBlockStatementList Contains await is true.
|
||||
if ctx.scope.get_flags(node.scope_id()).is_class_static_block() {
|
||||
if (matches!(ctx.nodes.parent_kind(node.id()), Some(AstKind::Class(_)))
|
||||
&& ctx
|
||||
.scope
|
||||
.get_parent_id(node.scope_id())
|
||||
.is_some_and(|id| ctx.scope.get_flags(id).is_class_static_block()))
|
||||
|| ctx.current_scope_flags().is_class_static_block()
|
||||
{
|
||||
return ctx.error(class_static_block_await(span));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -158,11 +158,11 @@ pub(crate) enum AncestorType {
|
|||
YieldExpressionArgument = 126,
|
||||
ClassDecorators = 127,
|
||||
ClassId = 128,
|
||||
ClassSuperClass = 129,
|
||||
ClassBody = 130,
|
||||
ClassTypeParameters = 131,
|
||||
ClassSuperTypeParameters = 132,
|
||||
ClassImplements = 133,
|
||||
ClassTypeParameters = 129,
|
||||
ClassSuperClass = 130,
|
||||
ClassSuperTypeParameters = 131,
|
||||
ClassImplements = 132,
|
||||
ClassBody = 133,
|
||||
ClassBodyBody = 134,
|
||||
MethodDefinitionDecorators = 135,
|
||||
MethodDefinitionKey = 136,
|
||||
|
|
@ -557,12 +557,12 @@ pub enum Ancestor<'a> {
|
|||
AncestorType::YieldExpressionArgument as u16,
|
||||
ClassDecorators(ClassWithoutDecorators<'a>) = AncestorType::ClassDecorators as u16,
|
||||
ClassId(ClassWithoutId<'a>) = AncestorType::ClassId as u16,
|
||||
ClassSuperClass(ClassWithoutSuperClass<'a>) = AncestorType::ClassSuperClass as u16,
|
||||
ClassBody(ClassWithoutBody<'a>) = AncestorType::ClassBody as u16,
|
||||
ClassTypeParameters(ClassWithoutTypeParameters<'a>) = AncestorType::ClassTypeParameters as u16,
|
||||
ClassSuperClass(ClassWithoutSuperClass<'a>) = AncestorType::ClassSuperClass as u16,
|
||||
ClassSuperTypeParameters(ClassWithoutSuperTypeParameters<'a>) =
|
||||
AncestorType::ClassSuperTypeParameters as u16,
|
||||
ClassImplements(ClassWithoutImplements<'a>) = AncestorType::ClassImplements as u16,
|
||||
ClassBody(ClassWithoutBody<'a>) = AncestorType::ClassBody as u16,
|
||||
ClassBodyBody(ClassBodyWithoutBody<'a>) = AncestorType::ClassBodyBody as u16,
|
||||
MethodDefinitionDecorators(MethodDefinitionWithoutDecorators<'a>) =
|
||||
AncestorType::MethodDefinitionDecorators as u16,
|
||||
|
|
@ -1284,11 +1284,11 @@ impl<'a> Ancestor<'a> {
|
|||
self,
|
||||
Self::ClassDecorators(_)
|
||||
| Self::ClassId(_)
|
||||
| Self::ClassSuperClass(_)
|
||||
| Self::ClassBody(_)
|
||||
| Self::ClassTypeParameters(_)
|
||||
| Self::ClassSuperClass(_)
|
||||
| Self::ClassSuperTypeParameters(_)
|
||||
| Self::ClassImplements(_)
|
||||
| Self::ClassBody(_)
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -6135,12 +6135,12 @@ pub(crate) const OFFSET_CLASS_TYPE: usize = offset_of!(Class, r#type);
|
|||
pub(crate) const OFFSET_CLASS_SPAN: usize = offset_of!(Class, span);
|
||||
pub(crate) const OFFSET_CLASS_DECORATORS: usize = offset_of!(Class, decorators);
|
||||
pub(crate) const OFFSET_CLASS_ID: usize = offset_of!(Class, id);
|
||||
pub(crate) const OFFSET_CLASS_SUPER_CLASS: usize = offset_of!(Class, super_class);
|
||||
pub(crate) const OFFSET_CLASS_BODY: usize = offset_of!(Class, body);
|
||||
pub(crate) const OFFSET_CLASS_TYPE_PARAMETERS: usize = offset_of!(Class, type_parameters);
|
||||
pub(crate) const OFFSET_CLASS_SUPER_CLASS: usize = offset_of!(Class, super_class);
|
||||
pub(crate) const OFFSET_CLASS_SUPER_TYPE_PARAMETERS: usize =
|
||||
offset_of!(Class, super_type_parameters);
|
||||
pub(crate) const OFFSET_CLASS_IMPLEMENTS: usize = offset_of!(Class, implements);
|
||||
pub(crate) const OFFSET_CLASS_BODY: usize = offset_of!(Class, body);
|
||||
pub(crate) const OFFSET_CLASS_ABSTRACT: usize = offset_of!(Class, r#abstract);
|
||||
pub(crate) const OFFSET_CLASS_DECLARE: usize = offset_of!(Class, declare);
|
||||
pub(crate) const OFFSET_CLASS_SCOPE_ID: usize = offset_of!(Class, scope_id);
|
||||
|
|
@ -6167,18 +6167,6 @@ impl<'a> ClassWithoutDecorators<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn super_class(&self) -> &Option<Expression<'a>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_CLASS) as *const Option<Expression<'a>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn body(&self) -> &Box<'a, ClassBody<'a>> {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn type_parameters(&self) -> &Option<Box<'a, TSTypeParameterDeclaration<'a>>> {
|
||||
unsafe {
|
||||
|
|
@ -6187,6 +6175,13 @@ impl<'a> ClassWithoutDecorators<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn super_class(&self) -> &Option<Expression<'a>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_CLASS) as *const Option<Expression<'a>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn super_type_parameters(&self) -> &Option<Box<'a, TSTypeParameterInstantiation<'a>>> {
|
||||
unsafe {
|
||||
|
|
@ -6203,6 +6198,11 @@ impl<'a> ClassWithoutDecorators<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn body(&self) -> &Box<'a, ClassBody<'a>> {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn r#abstract(&self) -> &bool {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_ABSTRACT) as *const bool) }
|
||||
|
|
@ -6243,18 +6243,6 @@ impl<'a> ClassWithoutId<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn super_class(&self) -> &Option<Expression<'a>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_CLASS) as *const Option<Expression<'a>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn body(&self) -> &Box<'a, ClassBody<'a>> {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn type_parameters(&self) -> &Option<Box<'a, TSTypeParameterDeclaration<'a>>> {
|
||||
unsafe {
|
||||
|
|
@ -6263,145 +6251,6 @@ impl<'a> ClassWithoutId<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn super_type_parameters(&self) -> &Option<Box<'a, TSTypeParameterInstantiation<'a>>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_TYPE_PARAMETERS)
|
||||
as *const Option<Box<'a, TSTypeParameterInstantiation<'a>>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn implements(&self) -> &Option<Vec<'a, TSClassImplements<'a>>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_CLASS_IMPLEMENTS)
|
||||
as *const Option<Vec<'a, TSClassImplements<'a>>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn r#abstract(&self) -> &bool {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_ABSTRACT) as *const bool) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn declare(&self) -> &bool {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_DECLARE) as *const bool) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn scope_id(&self) -> &Cell<Option<ScopeId>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_CLASS_SCOPE_ID) as *const Cell<Option<ScopeId>>)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(transparent)]
|
||||
#[derive(Debug)]
|
||||
pub struct ClassWithoutSuperClass<'a>(pub(crate) *const Class<'a>);
|
||||
|
||||
impl<'a> ClassWithoutSuperClass<'a> {
|
||||
#[inline]
|
||||
pub fn r#type(&self) -> &ClassType {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE) as *const ClassType) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn span(&self) -> &Span {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_SPAN) as *const Span) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn decorators(&self) -> &Vec<'a, Decorator<'a>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_CLASS_DECORATORS) as *const Vec<'a, Decorator<'a>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn id(&self) -> &Option<BindingIdentifier<'a>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_CLASS_ID) as *const Option<BindingIdentifier<'a>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn body(&self) -> &Box<'a, ClassBody<'a>> {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn type_parameters(&self) -> &Option<Box<'a, TSTypeParameterDeclaration<'a>>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_CLASS_TYPE_PARAMETERS)
|
||||
as *const Option<Box<'a, TSTypeParameterDeclaration<'a>>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn super_type_parameters(&self) -> &Option<Box<'a, TSTypeParameterInstantiation<'a>>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_TYPE_PARAMETERS)
|
||||
as *const Option<Box<'a, TSTypeParameterInstantiation<'a>>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn implements(&self) -> &Option<Vec<'a, TSClassImplements<'a>>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_CLASS_IMPLEMENTS)
|
||||
as *const Option<Vec<'a, TSClassImplements<'a>>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn r#abstract(&self) -> &bool {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_ABSTRACT) as *const bool) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn declare(&self) -> &bool {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_DECLARE) as *const bool) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn scope_id(&self) -> &Cell<Option<ScopeId>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_CLASS_SCOPE_ID) as *const Cell<Option<ScopeId>>)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(transparent)]
|
||||
#[derive(Debug)]
|
||||
pub struct ClassWithoutBody<'a>(pub(crate) *const Class<'a>);
|
||||
|
||||
impl<'a> ClassWithoutBody<'a> {
|
||||
#[inline]
|
||||
pub fn r#type(&self) -> &ClassType {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE) as *const ClassType) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn span(&self) -> &Span {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_SPAN) as *const Span) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn decorators(&self) -> &Vec<'a, Decorator<'a>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_CLASS_DECORATORS) as *const Vec<'a, Decorator<'a>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn id(&self) -> &Option<BindingIdentifier<'a>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_CLASS_ID) as *const Option<BindingIdentifier<'a>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn super_class(&self) -> &Option<Expression<'a>> {
|
||||
unsafe {
|
||||
|
|
@ -6409,14 +6258,6 @@ impl<'a> ClassWithoutBody<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn type_parameters(&self) -> &Option<Box<'a, TSTypeParameterDeclaration<'a>>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_CLASS_TYPE_PARAMETERS)
|
||||
as *const Option<Box<'a, TSTypeParameterDeclaration<'a>>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn super_type_parameters(&self) -> &Option<Box<'a, TSTypeParameterInstantiation<'a>>> {
|
||||
unsafe {
|
||||
|
|
@ -6433,6 +6274,11 @@ impl<'a> ClassWithoutBody<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn body(&self) -> &Box<'a, ClassBody<'a>> {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn r#abstract(&self) -> &bool {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_ABSTRACT) as *const bool) }
|
||||
|
|
@ -6487,11 +6333,82 @@ impl<'a> ClassWithoutTypeParameters<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn super_type_parameters(&self) -> &Option<Box<'a, TSTypeParameterInstantiation<'a>>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_TYPE_PARAMETERS)
|
||||
as *const Option<Box<'a, TSTypeParameterInstantiation<'a>>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn implements(&self) -> &Option<Vec<'a, TSClassImplements<'a>>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_CLASS_IMPLEMENTS)
|
||||
as *const Option<Vec<'a, TSClassImplements<'a>>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn body(&self) -> &Box<'a, ClassBody<'a>> {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn r#abstract(&self) -> &bool {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_ABSTRACT) as *const bool) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn declare(&self) -> &bool {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_DECLARE) as *const bool) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn scope_id(&self) -> &Cell<Option<ScopeId>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_CLASS_SCOPE_ID) as *const Cell<Option<ScopeId>>)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(transparent)]
|
||||
#[derive(Debug)]
|
||||
pub struct ClassWithoutSuperClass<'a>(pub(crate) *const Class<'a>);
|
||||
|
||||
impl<'a> ClassWithoutSuperClass<'a> {
|
||||
#[inline]
|
||||
pub fn r#type(&self) -> &ClassType {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE) as *const ClassType) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn span(&self) -> &Span {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_SPAN) as *const Span) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn decorators(&self) -> &Vec<'a, Decorator<'a>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_CLASS_DECORATORS) as *const Vec<'a, Decorator<'a>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn id(&self) -> &Option<BindingIdentifier<'a>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_CLASS_ID) as *const Option<BindingIdentifier<'a>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn type_parameters(&self) -> &Option<Box<'a, TSTypeParameterDeclaration<'a>>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_CLASS_TYPE_PARAMETERS)
|
||||
as *const Option<Box<'a, TSTypeParameterDeclaration<'a>>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn super_type_parameters(&self) -> &Option<Box<'a, TSTypeParameterInstantiation<'a>>> {
|
||||
unsafe {
|
||||
|
|
@ -6508,6 +6425,11 @@ impl<'a> ClassWithoutTypeParameters<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn body(&self) -> &Box<'a, ClassBody<'a>> {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn r#abstract(&self) -> &bool {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_ABSTRACT) as *const bool) }
|
||||
|
|
@ -6555,18 +6477,6 @@ impl<'a> ClassWithoutSuperTypeParameters<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn super_class(&self) -> &Option<Expression<'a>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_CLASS) as *const Option<Expression<'a>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn body(&self) -> &Box<'a, ClassBody<'a>> {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn type_parameters(&self) -> &Option<Box<'a, TSTypeParameterDeclaration<'a>>> {
|
||||
unsafe {
|
||||
|
|
@ -6575,6 +6485,13 @@ impl<'a> ClassWithoutSuperTypeParameters<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn super_class(&self) -> &Option<Expression<'a>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_CLASS) as *const Option<Expression<'a>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn implements(&self) -> &Option<Vec<'a, TSClassImplements<'a>>> {
|
||||
unsafe {
|
||||
|
|
@ -6583,6 +6500,11 @@ impl<'a> ClassWithoutSuperTypeParameters<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn body(&self) -> &Box<'a, ClassBody<'a>> {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn r#abstract(&self) -> &bool {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_ABSTRACT) as *const bool) }
|
||||
|
|
@ -6630,6 +6552,14 @@ impl<'a> ClassWithoutImplements<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn type_parameters(&self) -> &Option<Box<'a, TSTypeParameterDeclaration<'a>>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_CLASS_TYPE_PARAMETERS)
|
||||
as *const Option<Box<'a, TSTypeParameterDeclaration<'a>>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn super_class(&self) -> &Option<Expression<'a>> {
|
||||
unsafe {
|
||||
|
|
@ -6637,11 +6567,66 @@ impl<'a> ClassWithoutImplements<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn super_type_parameters(&self) -> &Option<Box<'a, TSTypeParameterInstantiation<'a>>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_TYPE_PARAMETERS)
|
||||
as *const Option<Box<'a, TSTypeParameterInstantiation<'a>>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn body(&self) -> &Box<'a, ClassBody<'a>> {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn r#abstract(&self) -> &bool {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_ABSTRACT) as *const bool) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn declare(&self) -> &bool {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_DECLARE) as *const bool) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn scope_id(&self) -> &Cell<Option<ScopeId>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_CLASS_SCOPE_ID) as *const Cell<Option<ScopeId>>)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(transparent)]
|
||||
#[derive(Debug)]
|
||||
pub struct ClassWithoutBody<'a>(pub(crate) *const Class<'a>);
|
||||
|
||||
impl<'a> ClassWithoutBody<'a> {
|
||||
#[inline]
|
||||
pub fn r#type(&self) -> &ClassType {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE) as *const ClassType) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn span(&self) -> &Span {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_SPAN) as *const Span) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn decorators(&self) -> &Vec<'a, Decorator<'a>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_CLASS_DECORATORS) as *const Vec<'a, Decorator<'a>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn id(&self) -> &Option<BindingIdentifier<'a>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_CLASS_ID) as *const Option<BindingIdentifier<'a>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn type_parameters(&self) -> &Option<Box<'a, TSTypeParameterDeclaration<'a>>> {
|
||||
unsafe {
|
||||
|
|
@ -6650,6 +6635,13 @@ impl<'a> ClassWithoutImplements<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn super_class(&self) -> &Option<Expression<'a>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_CLASS) as *const Option<Expression<'a>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn super_type_parameters(&self) -> &Option<Box<'a, TSTypeParameterInstantiation<'a>>> {
|
||||
unsafe {
|
||||
|
|
@ -6658,6 +6650,14 @@ impl<'a> ClassWithoutImplements<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn implements(&self) -> &Option<Vec<'a, TSClassImplements<'a>>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_CLASS_IMPLEMENTS)
|
||||
as *const Option<Vec<'a, TSClassImplements<'a>>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn r#abstract(&self) -> &bool {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_ABSTRACT) as *const bool) }
|
||||
|
|
|
|||
|
|
@ -2473,25 +2473,18 @@ pub(crate) unsafe fn walk_class<'a, Tr: Traverse<'a>>(
|
|||
ctx.retag_stack(AncestorType::ClassId);
|
||||
walk_binding_identifier(traverser, field as *mut _, ctx);
|
||||
}
|
||||
if let Some(field) =
|
||||
&mut *((node as *mut u8).add(ancestor::OFFSET_CLASS_SUPER_CLASS) as *mut Option<Expression>)
|
||||
{
|
||||
ctx.retag_stack(AncestorType::ClassSuperClass);
|
||||
walk_expression(traverser, field as *mut _, ctx);
|
||||
}
|
||||
ctx.retag_stack(AncestorType::ClassBody);
|
||||
walk_class_body(
|
||||
traverser,
|
||||
(&mut **((node as *mut u8).add(ancestor::OFFSET_CLASS_BODY) as *mut Box<ClassBody>))
|
||||
as *mut _,
|
||||
ctx,
|
||||
);
|
||||
if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_CLASS_TYPE_PARAMETERS)
|
||||
as *mut Option<Box<TSTypeParameterDeclaration>>)
|
||||
{
|
||||
ctx.retag_stack(AncestorType::ClassTypeParameters);
|
||||
walk_ts_type_parameter_declaration(traverser, (&mut **field) as *mut _, ctx);
|
||||
}
|
||||
if let Some(field) =
|
||||
&mut *((node as *mut u8).add(ancestor::OFFSET_CLASS_SUPER_CLASS) as *mut Option<Expression>)
|
||||
{
|
||||
ctx.retag_stack(AncestorType::ClassSuperClass);
|
||||
walk_expression(traverser, field as *mut _, ctx);
|
||||
}
|
||||
if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_CLASS_SUPER_TYPE_PARAMETERS)
|
||||
as *mut Option<Box<TSTypeParameterInstantiation>>)
|
||||
{
|
||||
|
|
@ -2506,6 +2499,13 @@ pub(crate) unsafe fn walk_class<'a, Tr: Traverse<'a>>(
|
|||
walk_ts_class_implements(traverser, item as *mut _, ctx);
|
||||
}
|
||||
}
|
||||
ctx.retag_stack(AncestorType::ClassBody);
|
||||
walk_class_body(
|
||||
traverser,
|
||||
(&mut **((node as *mut u8).add(ancestor::OFFSET_CLASS_BODY) as *mut Box<ClassBody>))
|
||||
as *mut _,
|
||||
ctx,
|
||||
);
|
||||
ctx.pop_stack();
|
||||
if let Some(previous_scope_id) = previous_scope_id {
|
||||
ctx.set_current_scope_id(previous_scope_id);
|
||||
|
|
|
|||
|
|
@ -2,12 +2,60 @@ commit: a1587416
|
|||
|
||||
parser_test262 Summary:
|
||||
AST Parsed : 45859/45859 (100.00%)
|
||||
Positive Passed: 45859/45859 (100.00%)
|
||||
Positive Passed: 45853/45859 (99.99%)
|
||||
Negative Passed: 3925/3929 (99.90%)
|
||||
Expect Syntax Error: "language/import/import-assertions/json-invalid.js"
|
||||
Expect Syntax Error: "language/import/import-assertions/json-named-bindings.js"
|
||||
Expect Syntax Error: "language/import/import-attributes/json-invalid.js"
|
||||
Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js"
|
||||
Expect to Parse: "language/expressions/class/decorator/syntax/valid/decorator-call-expr-identifier-reference-yield.js"
|
||||
|
||||
× The keyword 'yield' is reserved
|
||||
╭─[language/expressions/class/decorator/syntax/valid/decorator-call-expr-identifier-reference-yield.js:44:10]
|
||||
43 │
|
||||
44 │ var C = @yield() class {};
|
||||
· ─────
|
||||
╰────
|
||||
Expect to Parse: "language/expressions/class/decorator/syntax/valid/decorator-member-expr-identifier-reference-yield.js"
|
||||
|
||||
× The keyword 'yield' is reserved
|
||||
╭─[language/expressions/class/decorator/syntax/valid/decorator-member-expr-identifier-reference-yield.js:33:10]
|
||||
32 │
|
||||
33 │ var C = @yield class {};
|
||||
· ─────
|
||||
╰────
|
||||
Expect to Parse: "language/expressions/class/decorator/syntax/valid/decorator-parenthesized-expr-identifier-reference-yield.js"
|
||||
|
||||
× The keyword 'yield' is reserved
|
||||
╭─[language/expressions/class/decorator/syntax/valid/decorator-parenthesized-expr-identifier-reference-yield.js:51:11]
|
||||
50 │
|
||||
51 │ var C = @(yield) class {};
|
||||
· ─────
|
||||
╰────
|
||||
Expect to Parse: "language/statements/class/decorator/syntax/valid/decorator-call-expr-identifier-reference-yield.js"
|
||||
|
||||
× The keyword 'yield' is reserved
|
||||
╭─[language/statements/class/decorator/syntax/valid/decorator-call-expr-identifier-reference-yield.js:45:2]
|
||||
44 │
|
||||
45 │ @yield() class C {}
|
||||
· ─────
|
||||
╰────
|
||||
Expect to Parse: "language/statements/class/decorator/syntax/valid/decorator-member-expr-identifier-reference-yield.js"
|
||||
|
||||
× The keyword 'yield' is reserved
|
||||
╭─[language/statements/class/decorator/syntax/valid/decorator-member-expr-identifier-reference-yield.js:34:2]
|
||||
33 │
|
||||
34 │ @yield class C {}
|
||||
· ─────
|
||||
╰────
|
||||
Expect to Parse: "language/statements/class/decorator/syntax/valid/decorator-parenthesized-expr-identifier-reference-yield.js"
|
||||
|
||||
× The keyword 'yield' is reserved
|
||||
╭─[language/statements/class/decorator/syntax/valid/decorator-parenthesized-expr-identifier-reference-yield.js:52:3]
|
||||
51 │
|
||||
52 │ @(yield) class C {}
|
||||
· ─────
|
||||
╰────
|
||||
|
||||
× '0'-prefixed octal literals and octal escape sequences are deprecated
|
||||
╭─[annexB/language/expressions/template-literal/legacy-octal-escape-sequence-strict.js:18:4]
|
||||
|
|
@ -12629,6 +12677,14 @@ Expect Syntax Error: "language/import/import-attributes/json-named-bindings.js"
|
|||
× Cannot use `await` as an identifier in an async context
|
||||
╭─[language/expressions/class/static-init-await-binding.js:21:12]
|
||||
20 │ static {
|
||||
21 │ (class await {});
|
||||
· ─────
|
||||
22 │ }
|
||||
╰────
|
||||
|
||||
× Cannot use await in class static initialization block
|
||||
╭─[language/expressions/class/static-init-await-binding.js:21:12]
|
||||
20 │ static {
|
||||
21 │ (class await {});
|
||||
· ─────
|
||||
22 │ }
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ commit: d8086f14
|
|||
|
||||
parser_typescript Summary:
|
||||
AST Parsed : 5279/5283 (99.92%)
|
||||
Positive Passed: 5256/5283 (99.49%)
|
||||
Negative Passed: 1103/4875 (22.63%)
|
||||
Positive Passed: 5258/5283 (99.53%)
|
||||
Negative Passed: 1100/4875 (22.56%)
|
||||
Expect Syntax Error: "compiler/ClassDeclaration10.ts"
|
||||
Expect Syntax Error: "compiler/ClassDeclaration11.ts"
|
||||
Expect Syntax Error: "compiler/ClassDeclaration13.ts"
|
||||
|
|
@ -469,6 +469,7 @@ Expect Syntax Error: "compiler/decoratorInJsFile.ts"
|
|||
Expect Syntax Error: "compiler/decoratorInJsFile1.ts"
|
||||
Expect Syntax Error: "compiler/decoratorMetadataGenericTypeVariable.ts"
|
||||
Expect Syntax Error: "compiler/decoratorMetadataGenericTypeVariableDefault.ts"
|
||||
Expect Syntax Error: "compiler/decoratorMetadataGenericTypeVariableInScope.ts"
|
||||
Expect Syntax Error: "compiler/decoratorMetadataNoLibIsolatedModulesTypes.ts"
|
||||
Expect Syntax Error: "compiler/decoratorsOnComputedProperties.ts"
|
||||
Expect Syntax Error: "compiler/deduplicateImportsInSystem.ts"
|
||||
|
|
@ -888,6 +889,7 @@ Expect Syntax Error: "compiler/importedModuleAddToGlobal.ts"
|
|||
Expect Syntax Error: "compiler/inDoesNotOperateOnPrimitiveTypes.ts"
|
||||
Expect Syntax Error: "compiler/inKeywordAndUnknown.ts"
|
||||
Expect Syntax Error: "compiler/inOperator.ts"
|
||||
Expect Syntax Error: "compiler/incompatibleAssignmentOfIdenticallyNamedTypes.ts"
|
||||
Expect Syntax Error: "compiler/incompatibleExports1.ts"
|
||||
Expect Syntax Error: "compiler/incompatibleExports2.ts"
|
||||
Expect Syntax Error: "compiler/incompatibleGenericTypes.ts"
|
||||
|
|
@ -2625,6 +2627,7 @@ Expect Syntax Error: "conformance/expressions/contextualTyping/parenthesizedCont
|
|||
Expect Syntax Error: "conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts"
|
||||
Expect Syntax Error: "conformance/expressions/contextualTyping/superCallParameterContextualTyping2.ts"
|
||||
Expect Syntax Error: "conformance/expressions/functionCalls/callOverload.ts"
|
||||
Expect Syntax Error: "conformance/expressions/functionCalls/callWithMissingVoid.ts"
|
||||
Expect Syntax Error: "conformance/expressions/functionCalls/callWithSpread2.ts"
|
||||
Expect Syntax Error: "conformance/expressions/functionCalls/callWithSpread3.ts"
|
||||
Expect Syntax Error: "conformance/expressions/functionCalls/callWithSpread4.ts"
|
||||
|
|
@ -3799,20 +3802,6 @@ Expect to Parse: "compiler/bom-utf16be.ts"
|
|||
1 │ 瘀愀爀 砀㴀 㬀ഀ
|
||||
· ─
|
||||
╰────
|
||||
Expect to Parse: "compiler/decoratorReferences.ts"
|
||||
|
||||
× Identifier `T` has already been declared
|
||||
╭─[compiler/decoratorReferences.ts:2:6]
|
||||
1 │ declare function y(...args: any[]): any;
|
||||
2 │ type T = number;
|
||||
· ┬
|
||||
· ╰── `T` has already been declared here
|
||||
3 │ @y(1 as T, () => C) // <-- T should be resolved to the type alias, not the type parameter of the class; C should resolve to the class
|
||||
4 │ class C<T> {
|
||||
· ┬
|
||||
· ╰── It can not be redeclared here
|
||||
5 │ @y(null as T) // <-- y should resolve to the function declaration, not the parameter; T should resolve to the type parameter of the class
|
||||
╰────
|
||||
Expect to Parse: "compiler/deferredConditionalTypes.ts"
|
||||
|
||||
× Identifier `A` has already been declared
|
||||
|
|
@ -4090,21 +4079,6 @@ Expect to Parse: "compiler/unusedTypeParametersNotCheckedByNoUnusedLocals.ts"
|
|||
· ╰── It can not be redeclared here
|
||||
6 │
|
||||
╰────
|
||||
|
||||
× Identifier `T` has already been declared
|
||||
╭─[compiler/unusedTypeParametersNotCheckedByNoUnusedLocals.ts:3:6]
|
||||
2 │
|
||||
3 │ type T<T> = { };
|
||||
· ┬
|
||||
· ╰── `T` has already been declared here
|
||||
4 │
|
||||
5 │ interface I<T> { };
|
||||
6 │
|
||||
7 │ class C<T> {
|
||||
· ┬
|
||||
· ╰── It can not be redeclared here
|
||||
8 │ public m<V>() { }
|
||||
╰────
|
||||
Expect to Parse: "compiler/withStatementInternalComments.ts"
|
||||
|
||||
× 'with' statements are not allowed
|
||||
|
|
@ -4204,17 +4178,6 @@ Expect to Parse: "conformance/esDecorators/esDecorators-decoratorExpression.1.ts
|
|||
14 │
|
||||
╰────
|
||||
help: Try insert a semicolon here
|
||||
Expect to Parse: "conformance/expressions/newOperator/newOperatorConformance.ts"
|
||||
|
||||
× Identifier `T` has already been declared
|
||||
╭─[conformance/expressions/newOperator/newOperatorConformance.ts:8:7]
|
||||
7 │
|
||||
8 │ class T<T> {
|
||||
· ┬ ┬
|
||||
· │ ╰── It can not be redeclared here
|
||||
· ╰── `T` has already been declared here
|
||||
9 │ constructor(n?: T) { }
|
||||
╰────
|
||||
Expect to Parse: "conformance/externalModules/topLevelAwait.2.ts"
|
||||
|
||||
× Cannot use `await` as an identifier in an async context
|
||||
|
|
@ -6347,19 +6310,6 @@ Expect to Parse: "conformance/types/typeRelationships/typeAndMemberIdentity/obje
|
|||
╰────
|
||||
help: Remove the duplicate modifier.
|
||||
|
||||
× Identifier `TypeVariable` has already been declared
|
||||
╭─[compiler/decoratorMetadataGenericTypeVariableInScope.ts:2:7]
|
||||
1 │ // Unused, but could collide with the named type argument below.
|
||||
2 │ class TypeVariable {}
|
||||
· ──────┬─────
|
||||
· ╰── `TypeVariable` has already been declared here
|
||||
3 │
|
||||
4 │ export class C<TypeVariable> {
|
||||
· ──────┬─────
|
||||
· ╰── It can not be redeclared here
|
||||
5 │ @Decorate
|
||||
╰────
|
||||
|
||||
× Cannot assign to this expression
|
||||
╭─[compiler/decrementAndIncrementOperators.ts:4:1]
|
||||
3 │ // errors
|
||||
|
|
@ -7419,18 +7369,6 @@ Expect to Parse: "conformance/types/typeRelationships/typeAndMemberIdentity/obje
|
|||
2 │
|
||||
╰────
|
||||
|
||||
× Identifier `T` has already been declared
|
||||
╭─[compiler/incompatibleAssignmentOfIdenticallyNamedTypes.ts:1:11]
|
||||
1 │ interface T { }
|
||||
· ┬
|
||||
· ╰── `T` has already been declared here
|
||||
2 │ declare const a: T;
|
||||
3 │ class Foo<T> {
|
||||
· ┬
|
||||
· ╰── It can not be redeclared here
|
||||
4 │ x: T;
|
||||
╰────
|
||||
|
||||
× Unexpected token
|
||||
╭─[compiler/incompleteDottedExpressionAtEOF.ts:2:18]
|
||||
1 │ // used to leak __missing into error message
|
||||
|
|
@ -10298,21 +10236,6 @@ Expect to Parse: "conformance/types/typeRelationships/typeAndMemberIdentity/obje
|
|||
16 │ }
|
||||
╰────
|
||||
|
||||
× Identifier `public` has already been declared
|
||||
╭─[compiler/strictModeReservedWordInClassDeclaration.ts:1:11]
|
||||
1 │ interface public { }
|
||||
· ───┬──
|
||||
· ╰── `public` has already been declared here
|
||||
2 │
|
||||
╰────
|
||||
╭─[compiler/strictModeReservedWordInClassDeclaration.ts:21:9]
|
||||
20 │
|
||||
21 │ class D<public, private>{ }
|
||||
· ───┬──
|
||||
· ╰── It can not be redeclared here
|
||||
22 │
|
||||
╰────
|
||||
|
||||
× The keyword 'public' is reserved
|
||||
╭─[compiler/strictModeReservedWordInClassDeclaration.ts:21:9]
|
||||
20 │
|
||||
|
|
@ -10329,6 +10252,30 @@ Expect to Parse: "conformance/types/typeRelationships/typeAndMemberIdentity/obje
|
|||
22 │
|
||||
╰────
|
||||
|
||||
× The keyword 'public' is reserved
|
||||
╭─[compiler/strictModeReservedWordInClassDeclaration.ts:23:20]
|
||||
22 │
|
||||
23 │ class E implements public { }
|
||||
· ──────
|
||||
24 │
|
||||
╰────
|
||||
|
||||
× The keyword 'public' is reserved
|
||||
╭─[compiler/strictModeReservedWordInClassDeclaration.ts:25:20]
|
||||
24 │
|
||||
25 │ class F implements public.private.B { }
|
||||
· ──────
|
||||
26 │ class F1 implements public.private.implements { }
|
||||
╰────
|
||||
|
||||
× The keyword 'public' is reserved
|
||||
╭─[compiler/strictModeReservedWordInClassDeclaration.ts:26:21]
|
||||
25 │ class F implements public.private.B { }
|
||||
26 │ class F1 implements public.private.implements { }
|
||||
· ──────
|
||||
27 │ class G extends package { }
|
||||
╰────
|
||||
|
||||
× The keyword 'package' is reserved
|
||||
╭─[compiler/strictModeReservedWordInClassDeclaration.ts:27:17]
|
||||
26 │ class F1 implements public.private.implements { }
|
||||
|
|
@ -11235,21 +11182,6 @@ Expect to Parse: "conformance/types/typeRelationships/typeAndMemberIdentity/obje
|
|||
6 │
|
||||
╰────
|
||||
|
||||
× Identifier `T` has already been declared
|
||||
╭─[compiler/unusedTypeParametersCheckedByNoUnusedParameters.ts:3:6]
|
||||
2 │
|
||||
3 │ type T<T> = { };
|
||||
· ┬
|
||||
· ╰── `T` has already been declared here
|
||||
4 │
|
||||
5 │ interface I<T> { };
|
||||
6 │
|
||||
7 │ class C<T> {
|
||||
· ┬
|
||||
· ╰── It can not be redeclared here
|
||||
8 │ public m<V>() { }
|
||||
╰────
|
||||
|
||||
× Expected a semicolon or an implicit semicolon after a statement, but found none
|
||||
╭─[compiler/validRegexp.ts:1:23]
|
||||
1 │ var x = / [a - z /]$ / i;
|
||||
|
|
@ -16494,22 +16426,6 @@ Expect to Parse: "conformance/types/typeRelationships/typeAndMemberIdentity/obje
|
|||
10 │ (BOOLEAN, );
|
||||
╰────
|
||||
|
||||
× Identifier `X` has already been declared
|
||||
╭─[conformance/expressions/functionCalls/callWithMissingVoid.ts:2:7]
|
||||
1 │ // From #4260
|
||||
2 │ class X<T> {
|
||||
· ┬
|
||||
· ╰── `X` has already been declared here
|
||||
3 │ f(t: T) {
|
||||
╰────
|
||||
╭─[conformance/expressions/functionCalls/callWithMissingVoid.ts:27:17]
|
||||
26 │
|
||||
27 │ class MyPromise<X> {
|
||||
· ┬
|
||||
· ╰── It can not be redeclared here
|
||||
28 │ constructor(executor: (resolve: (value: X) => void) => void) {
|
||||
╰────
|
||||
|
||||
× 'with' statements are not allowed
|
||||
╭─[conformance/expressions/functions/arrowFunctionContexts.ts:2:1]
|
||||
1 │ // Arrow function used in with statement
|
||||
|
|
|
|||
Loading…
Reference in a new issue