Skip to content

Commit 10820f9

Browse files
committed
fix: ensure organize imports doesn't mess with generated $$Component type
#2594
1 parent cda5c86 commit 10820f9

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

packages/svelte2tsx/src/svelte2tsx/nodes/HoistableInterfaces.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,16 +337,20 @@ export class HoistableInterfaces {
337337
for (const [name, node] of hoistable) {
338338
let pos = node.pos + astOffset;
339339

340-
// node.pos includes preceeding whitespace, which could mean we accidentally also move stuff appended to a previous node
341-
if (name !== '$$ComponentProps') {
340+
if (name === '$$ComponentProps') {
341+
// So that organize imports doesn't mess with the types
342+
str.prependRight(pos, '\n');
343+
} else {
344+
// node.pos includes preceeding whitespace, which could mean we accidentally also move stuff appended to a previous node
342345
if (str.original[pos] === '\r') {
343346
pos++;
344347
}
345348
if (/\s/.test(str.original[pos])) {
346349
pos++;
347350
}
348351

349-
// jsdoc comments would be ignored if they are on the same line as the ;, so we add a newline, too
352+
// jsdoc comments would be ignored if they are on the same line as the ;, so we add a newline, too.
353+
// Also helps with organize imports not messing with the types
350354
str.prependRight(pos, ';\n');
351355
str.appendLeft(node.end + astOffset, ';');
352356
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy