fix: properly migrate imports types prefixed with $ (#14007)

pull/13949/head
Paolo Ricciuti 1 week ago committed by GitHub
parent 3876b302f3
commit b6fccdb4f7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: properly migrate imports types prefixed with $

@ -220,7 +220,16 @@ export function validate_identifier_name(binding, function_depth) {
if (node.name === '$') {
e.dollar_binding_invalid(node);
} else if (node.name.startsWith('$')) {
} else if (
node.name.startsWith('$') &&
// import type { $Type } from "" - these are normally already filtered out,
// but for the migration they aren't, and throwing here is preventing the migration to complete
// TODO -> once migration script is gone we can remove this check
!(
binding.initial?.type === 'ImportDeclaration' &&
/** @type {any} */ (binding.initial).importKind === 'type'
)
) {
e.dollar_prefix_invalid(node);
}
}

@ -348,7 +348,7 @@ export function create_scopes(ast, root, allow_reactive_declarations, parent) {
is_reference(node, /** @type {Node} */ (parent)) &&
// TSTypeAnnotation, TSInterfaceDeclaration etc - these are normally already filtered out,
// but for the migration they aren't, so we need to filter them out here
// -> once migration script is gone we can remove this check
// TODO -> once migration script is gone we can remove this check
!parent.type.startsWith('TS')
) {
references.push([state.scope, { node, path: path.slice() }]);

@ -0,0 +1,5 @@
<script lang="ts">
import type { $Test } from './types';
export let data: $Test;
</script>

@ -0,0 +1,9 @@
<script lang="ts">
import type { $Test } from './types';
interface Props {
data: $Test;
}
let { data }: Props = $props();
</script>
Loading…
Cancel
Save