File tree Expand file tree Collapse file tree 4 files changed +438
-1
lines changed
test/decorator_after_interface Expand file tree Collapse file tree 4 files changed +438
-1
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @sveltejs/acorn-typescript ' : patch
3+ ---
4+
5+ fix: handle decorators after type declarations
Original file line number Diff line number Diff line change @@ -2459,11 +2459,25 @@ export function tsPlugin(options?: {
24592459 node . extends = this . tsParseHeritageClause ( 'extends' ) ;
24602460 }
24612461 const body = this . startNode ( ) ;
2462- body . body = this . tsInType ( this . tsParseObjectTypeMembers . bind ( this ) ) ;
2462+ body . body = this . tsParseInterfaceBody ( ) ;
24632463 node . body = this . finishNode ( body , 'TSInterfaceBody' ) ;
24642464 return this . finishNode ( node , 'TSInterfaceDeclaration' ) ;
24652465 }
24662466
2467+ /**
2468+ * Parse interface body, ensuring the closing brace is read outside of type context
2469+ * so that decorators following the interface are properly tokenized.
2470+ */
2471+ tsParseInterfaceBody ( ) : Array < Node > {
2472+ this . expect ( tt . braceL ) ;
2473+ const oldInType = this . inType ;
2474+ this . inType = true ;
2475+ let members = this . tsParseList ( 'TypeMembers' , this . tsParseTypeMember . bind ( this ) ) ;
2476+ this . inType = oldInType ;
2477+ this . expect ( tt . braceR ) ;
2478+ return members ;
2479+ }
2480+
24672481 tsParseAbstractDeclaration ( node : any ) : any | undefined | null {
24682482 if ( this . match ( tt . _class ) ) {
24692483 node . abstract = true ;
You can’t perform that action at this time.
0 commit comments