1
1
/** @import { VariableDeclarator, Node, Identifier, AssignmentExpression, LabeledStatement, ExpressionStatement } from 'estree' */
2
- /** @import { Visitors, Context } from 'zimmerframe' */
2
+ /** @import { Visitors } from 'zimmerframe' */
3
3
/** @import { ComponentAnalysis } from '../phases/types.js' */
4
4
/** @import { Scope, ScopeRoot } from '../phases/scope.js' */
5
5
/** @import { AST, Binding, SvelteNode, ValidatedCompileOptions } from '#compiler' */
@@ -398,8 +398,6 @@ export function migrate(source, { filename, use_ts } = {}) {
398
398
}
399
399
}
400
400
401
- /** @typedef {SvelteNode | { type: "TSTypeReference", typeName: Identifier, start: number, end: number } } ASTNode */
402
-
403
401
/**
404
402
* @typedef {{
405
403
* scope: Scope;
@@ -418,12 +416,11 @@ export function migrate(source, { filename, use_ts } = {}) {
418
416
* derived_components: Map<string, string>;
419
417
* derived_labeled_statements: Set<LabeledStatement>;
420
418
* has_svelte_self: boolean;
421
- * migrate_prop_component_type?: boolean;
422
419
* uses_ts: boolean;
423
420
* }} State
424
421
*/
425
422
426
- /** @type {Visitors<ASTNode , State> } */
423
+ /** @type {Visitors<SvelteNode , State> } */
427
424
const instance_script = {
428
425
_ ( node , { state, next } ) {
429
426
// @ts -expect-error
@@ -440,27 +437,8 @@ const instance_script = {
440
437
}
441
438
next ( ) ;
442
439
} ,
443
- TSTypeReference ( node , { state, path } ) {
444
- if ( state . analysis . runes ) return ;
445
- if ( node . typeName . type === 'Identifier' ) {
446
- const binding = state . scope . get ( node . typeName . name ) ;
447
- if (
448
- binding &&
449
- binding . declaration_kind === 'import' &&
450
- binding . initial ?. type === 'ImportDeclaration' &&
451
- binding . initial . source . value ?. toString ( ) . endsWith ( '.svelte' )
452
- ) {
453
- state . str . overwrite (
454
- node . start ,
455
- node . end ,
456
- `import('svelte').ComponentExports<typeof ${ state . str . original . substring ( node . start , node . end ) } >`
457
- ) ;
458
- }
459
- }
460
- } ,
461
- Identifier ( node , { state, path, next } ) {
440
+ Identifier ( node , { state, path } ) {
462
441
handle_identifier ( node , state , path ) ;
463
- next ( ) ;
464
442
} ,
465
443
ImportDeclaration ( node , { state } ) {
466
444
state . props_insertion_point = node . end ?? state . props_insertion_point ;
@@ -525,8 +503,6 @@ const instance_script = {
525
503
return ;
526
504
}
527
505
528
- next ( ) ;
529
-
530
506
let nr_of_props = 0 ;
531
507
532
508
for ( const declarator of node . declarations ) {
@@ -1433,7 +1409,7 @@ function migrate_slot_usage(node, path, state) {
1433
1409
/**
1434
1410
* @param {VariableDeclarator } declarator
1435
1411
* @param {State } state
1436
- * @param {ASTNode [] } path
1412
+ * @param {SvelteNode [] } path
1437
1413
*/
1438
1414
function extract_type_and_comment ( declarator , state , path ) {
1439
1415
const str = state . str ;
@@ -1456,10 +1432,7 @@ function extract_type_and_comment(declarator, state, path) {
1456
1432
while ( str . original [ start ] === ' ' ) {
1457
1433
start ++ ;
1458
1434
}
1459
- return {
1460
- type : str . snip ( start , declarator . id . typeAnnotation . end ) . toString ( ) ,
1461
- comment
1462
- } ;
1435
+ return { type : str . original . substring ( start , declarator . id . typeAnnotation . end ) , comment } ;
1463
1436
}
1464
1437
1465
1438
let cleaned_comment_arr = comment
0 commit comments