File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
packages/svelte2tsx/src/svelte2tsx/nodes Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -187,18 +187,21 @@ export class ExportedNames {
187
187
const text = node . getSourceFile ( ) . getFullText ( ) ;
188
188
let start = - 1 ;
189
189
let comment : string ;
190
- for ( const c of ts . getLeadingCommentRanges ( text , node . pos ) || [ ] ) {
190
+ // reverse because we want to look at the last comment before the node first
191
+ for ( const c of [ ...( ts . getLeadingCommentRanges ( text , node . pos ) || [ ] ) ] . reverse ( ) ) {
191
192
const potential_match = text . substring ( c . pos , c . end ) ;
192
- if ( potential_match . includes ( ' @type' ) ) {
193
+ if ( / @ t y p e \b / . test ( potential_match ) ) {
193
194
comment = potential_match ;
194
195
start = c . pos + this . astOffset ;
195
196
break ;
196
197
}
197
198
}
198
199
if ( ! comment ) {
199
- for ( const c of ts . getLeadingCommentRanges ( text , node . parent . pos ) || [ ] ) {
200
+ for ( const c of [
201
+ ...( ts . getLeadingCommentRanges ( text , node . parent . pos ) || [ ] ) . reverse ( )
202
+ ] ) {
200
203
const potential_match = text . substring ( c . pos , c . end ) ;
201
- if ( potential_match . includes ( ' @type' ) ) {
204
+ if ( / @ t y p e \b / . test ( potential_match ) ) {
202
205
comment = potential_match ;
203
206
start = c . pos + this . astOffset ;
204
207
break ;
You can’t perform that action at this time.
0 commit comments