File tree Expand file tree Collapse file tree 4 files changed +29
-0
lines changed
tests/compiler-errors/samples/runes-before-after-update Expand file tree Collapse file tree 4 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -200,6 +200,8 @@ const runes = {
200
200
`${ rune } can only be called with ${ list ( args , 'or' ) } ${
201
201
args . length === 1 && args [ 0 ] === 1 ? 'argument' : 'arguments'
202
202
} `,
203
+ /** @param {string } name */
204
+ 'invalid-runes-mode-import' : ( name ) => `${ name } cannot be used in runes mode` ,
203
205
'duplicate-props-rune' : ( ) => `Cannot use $props() more than once`
204
206
} ;
205
207
Original file line number Diff line number Diff line change @@ -492,6 +492,20 @@ const validation = {
492
492
error ( node , 'invalid-const-placement' ) ;
493
493
}
494
494
} ,
495
+ ImportDeclaration ( node , context ) {
496
+ if ( context . state . analysis . runes ) {
497
+ for ( const specifier of node . specifiers ) {
498
+ if ( specifier . type === 'ImportSpecifier' ) {
499
+ if (
500
+ specifier . imported . name === 'beforeUpdate' ||
501
+ specifier . imported . name === 'afterUpdate'
502
+ ) {
503
+ error ( specifier , 'invalid-runes-mode-import' , specifier . imported . name ) ;
504
+ }
505
+ }
506
+ }
507
+ }
508
+ } ,
495
509
LetDirective ( node , context ) {
496
510
const parent = context . path . at ( - 1 ) ;
497
511
if (
Original file line number Diff line number Diff line change
1
+ import { test } from '../../test' ;
2
+
3
+ export default test ( {
4
+ error : {
5
+ code : 'invalid-runes-mode-import' ,
6
+ message : 'beforeUpdate cannot be used in runes mode'
7
+ }
8
+ } ) ;
Original file line number Diff line number Diff line change
1
+ <svelte:options runes />
2
+
3
+ <script >
4
+ import { beforeUpdate , afterUpdate } from ' svelte' ;
5
+ </script >
You can’t perform that action at this time.
0 commit comments