File tree 3 files changed +23
-1
lines changed
src/compiler/phases/1-parse
tests/runtime-runes/samples/typescript
3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " svelte " : patch
3
+ ---
4
+
5
+ fix: handle ` this ` parameter in TypeScript-annotated functions
Original file line number Diff line number Diff line change 1
1
import { walk } from 'zimmerframe' ;
2
2
import * as b from '../../utils/builders.js' ;
3
3
4
+ /**
5
+ * @param {import('estree').FunctionExpression | import('estree').FunctionDeclaration } node
6
+ * @param {import('zimmerframe').Context<any, any> } context
7
+ */
8
+ function remove_this_param ( node , context ) {
9
+ if ( node . params [ 0 ] ?. type === 'Identifier' && node . params [ 0 ] . name === 'this' ) {
10
+ node . params . shift ( ) ;
11
+ }
12
+ return context . next ( ) ;
13
+ }
14
+
4
15
/** @type {import('zimmerframe').Visitors<any, null> } */
5
16
const visitors = {
6
17
ImportDeclaration ( node ) {
@@ -71,7 +82,9 @@ const visitors = {
71
82
} ;
72
83
}
73
84
return node ;
74
- }
85
+ } ,
86
+ FunctionExpression : remove_this_param ,
87
+ FunctionDeclaration : remove_this_param
75
88
} ;
76
89
77
90
/**
Original file line number Diff line number Diff line change 2
2
interface Hello { message: ' hello' }
3
3
type Goodbye = { message: ' goodbye' };
4
4
5
+ function this_fn(this : any ) {
6
+ console .log (this );
7
+ }
8
+
5
9
export type { Hello };
6
10
</script >
7
11
You can’t perform that action at this time.
0 commit comments