Skip to content

Commit

Permalink
fix: follow latest decorator proposal
Browse files Browse the repository at this point in the history
closes #105
  • Loading branch information
3cp committed Oct 16, 2020
1 parent bd00159 commit e27b9d6
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 100 deletions.
2 changes: 0 additions & 2 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,6 @@ export function parseModuleItem(
return parseExportDeclaration(parser, context, scope, start, line, column);
case Token.ImportKeyword:
return parseImportDeclaration(parser, context, scope, start, line, column);
case Token.Decorator:
return parseDecorators(parser, context) as ESTree.Decorator[];
default:
return parseStatementListItem(parser, context, scope, Origin.TopLevel, {}, start, line, column);
}
Expand Down
194 changes: 96 additions & 98 deletions test/parser/next/decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,27 +391,26 @@ describe('Next - Decorators', () => {
}
],
[
`@bar export default
`export default @bar
class Foo { }`,
Context.OptionsNext | Context.Module | Context.Strict,
{
body: [
[
{
expression: {
name: 'bar',
type: 'Identifier'
},
type: 'Decorator'
}
],
{
declaration: {
body: {
body: [],
type: 'ClassBody'
},
decorators: [],
decorators: [
{
expression: {
name: 'bar',
type: 'Identifier'
},
type: 'Decorator'
}
],
id: {
name: 'Foo',
type: 'Identifier'
Expand Down Expand Up @@ -439,98 +438,97 @@ describe('Next - Decorators', () => {
Context.OptionsNext | Context.Module | Context.Strict,
{
body: [
[
{
expression: {
arguments: [
{
properties: [
{
computed: false,
key: {
name: 'kind',
type: 'Identifier'
},
kind: 'init',
method: false,
shorthand: false,
type: 'Property',
value: {
type: 'Literal',
value: 'initializer'
}
},
{
computed: false,
key: {
name: 'placement',
type: 'Identifier'
},
kind: 'init',
method: false,
shorthand: false,
type: 'Property',
value: {
type: 'Literal',
value: 'own'
}
},
{
computed: false,
key: {
name: 'initializer',
type: 'Identifier'
},
kind: 'init',
method: true,
shorthand: false,
type: 'Property',
value: {
async: false,
body: {
body: [
{
expression: {
left: {
name: 'self',
type: 'Identifier'
},
operator: '=',
right: {
type: 'ThisExpression'
},
type: 'AssignmentExpression'
},
type: 'ExpressionStatement'
}
],
type: 'BlockStatement'
},
generator: false,
id: null,
params: [],
type: 'FunctionExpression'
}
}
],
type: 'ObjectExpression'
}
],
callee: {
name: 'pushElement',
type: 'Identifier'
},
type: 'CallExpression'
},
type: 'Decorator'
}
],
{
body: {
body: [],
type: 'ClassBody'
},
decorators: [],
decorators: [
{
expression: {
arguments: [
{
properties: [
{
computed: false,
key: {
name: 'kind',
type: 'Identifier'
},
kind: 'init',
method: false,
shorthand: false,
type: 'Property',
value: {
type: 'Literal',
value: 'initializer'
}
},
{
computed: false,
key: {
name: 'placement',
type: 'Identifier'
},
kind: 'init',
method: false,
shorthand: false,
type: 'Property',
value: {
type: 'Literal',
value: 'own'
}
},
{
computed: false,
key: {
name: 'initializer',
type: 'Identifier'
},
kind: 'init',
method: true,
shorthand: false,
type: 'Property',
value: {
async: false,
body: {
body: [
{
expression: {
left: {
name: 'self',
type: 'Identifier'
},
operator: '=',
right: {
type: 'ThisExpression'
},
type: 'AssignmentExpression'
},
type: 'ExpressionStatement'
}
],
type: 'BlockStatement'
},
generator: false,
id: null,
params: [],
type: 'FunctionExpression'
}
}
],
type: 'ObjectExpression'
}
],
callee: {
name: 'pushElement',
type: 'Identifier'
},
type: 'CallExpression'
},
type: 'Decorator'
}
],
id: {
name: 'A',
type: 'Identifier'
Expand Down

0 comments on commit e27b9d6

Please sign in to comment.