11/** @import { VariableDeclarator, Node, Identifier, AssignmentExpression, LabeledStatement, ExpressionStatement } from 'estree' */
2- /** @import { Visitors, Context } from 'zimmerframe' */
2+ /** @import { Visitors } from 'zimmerframe' */
33/** @import { ComponentAnalysis } from '../phases/types.js' */
44/** @import { Scope, ScopeRoot } from '../phases/scope.js' */
55/** @import { AST, Binding, SvelteNode, ValidatedCompileOptions } from '#compiler' */
@@ -398,8 +398,6 @@ export function migrate(source, { filename, use_ts } = {}) {
398398 }
399399}
400400
401- /** @typedef {SvelteNode | { type: "TSTypeReference", typeName: Identifier, start: number, end: number } } ASTNode */
402-
403401/**
404402 * @typedef {{
405403 * scope: Scope;
@@ -418,12 +416,11 @@ export function migrate(source, { filename, use_ts } = {}) {
418416 * derived_components: Map<string, string>;
419417 * derived_labeled_statements: Set<LabeledStatement>;
420418 * has_svelte_self: boolean;
421- * migrate_prop_component_type?: boolean;
422419 * uses_ts: boolean;
423420 * }} State
424421 */
425422
426- /** @type {Visitors<ASTNode , State> } */
423+ /** @type {Visitors<SvelteNode , State> } */
427424const instance_script = {
428425 _ ( node , { state, next } ) {
429426 // @ts -expect-error
@@ -440,27 +437,8 @@ const instance_script = {
440437 }
441438 next ( ) ;
442439 } ,
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 } ) {
462441 handle_identifier ( node , state , path ) ;
463- next ( ) ;
464442 } ,
465443 ImportDeclaration ( node , { state } ) {
466444 state . props_insertion_point = node . end ?? state . props_insertion_point ;
@@ -525,8 +503,6 @@ const instance_script = {
525503 return ;
526504 }
527505
528- next ( ) ;
529-
530506 let nr_of_props = 0 ;
531507
532508 for ( const declarator of node . declarations ) {
@@ -1433,7 +1409,7 @@ function migrate_slot_usage(node, path, state) {
14331409/**
14341410 * @param {VariableDeclarator } declarator
14351411 * @param {State } state
1436- * @param {ASTNode [] } path
1412+ * @param {SvelteNode [] } path
14371413 */
14381414function extract_type_and_comment ( declarator , state , path ) {
14391415 const str = state . str ;
@@ -1456,10 +1432,7 @@ function extract_type_and_comment(declarator, state, path) {
14561432 while ( str . original [ start ] === ' ' ) {
14571433 start ++ ;
14581434 }
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 } ;
14631436 }
14641437
14651438 let cleaned_comment_arr = comment
0 commit comments