Question: decorator before export has different location with `babel`
See original GitHub issuerequire("meriyah").parse('@decorator export class Bar {}', {loc: true, module: true, next: true}).body[0]
{
type: 'ExportNamedDeclaration',
declaration: {
type: 'ClassDeclaration',
id: { type: 'Identifier', name: 'Bar', loc: [Object] },
superClass: null,
decorators: [ [Object] ],
body: { type: 'ClassBody', body: [], loc: [Object] },
loc: { start: [Object], end: [Object] }
},
specifiers: [],
source: null,
loc: { start: { line: 1, column: 0 }, end: { line: 1, column: 30 } }
}
We have column 0 ~ 30
While @babel/parser
has column 11 ~ 30
require("@babel/parser").parse('@decorator export class Bar {}', {sourceType:'module', plugins:[['decorators', {decoratorsBeforeExport: true}]]}).program.body[0].loc
SourceLocation {
start: Position { line: 1, column: 11 },
end: Position { line: 1, column: 30 },
filename: undefined,
identifierName: undefined
}
Should we align with them?
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
babel 7 Using the export keyword between a decorator and a ...
Technically, you just move export to the bottom of the class. If you have a lot of classes, that solution is not the...
Read more >TC39 Standards Track Decorators in Babel
The decorator proposal has gone back and forth on this question: should decorators come before or after the export keyword?
Read more >Understanding JavaScript decorators - LogRocket Blog
Learn about JavaScript's function decorators and class decorators as well as how you can create clean and reusable decorators.
Read more >@babel/plugin-proposal-decorators | Yarn - Package Manager
Changelog. Tags: :boom: [Breaking Change]; :eyeglasses: [Spec Compliance]; :rocket: [New Feature] ...
Read more >Updating the Decorators Proposal for the Holidays - SitePen
Photo by Annie Spratt on Unsplash The Ecma TC39 committee, which standardizes the JavaScript language (officially known as ECMAScript), has ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Interesting! And I worked in Hong Kong for 7 years and I only head mandaring all the time, so I guess different dialects, and I starting to be rusty. Better in speaking it rather than writing it 😃
Few other parsers are same as babel, I guess I need to fix ours.