Skip to content

Commit ddb1a66

Browse files
authored
fix import statment completion hack sourcemap (#1131)
1 parent d552d7c commit ddb1a66

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

packages/svelte2tsx/src/svelte2tsx/processInstanceScriptContent.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { handleTypeAssertion } from './nodes/handleTypeAssertion';
1414
import { ImplicitStoreValues } from './nodes/ImplicitStoreValues';
1515
import { Generics } from './nodes/Generics';
1616
import { is$$SlotsDeclaration } from './nodes/slot';
17+
import { preprendStr } from '../utils/magic-string';
1718

1819
export interface InstanceScriptProcessResult {
1920
exportedNames: ExportedNames;
@@ -291,7 +292,7 @@ export function processInstanceScriptContent(
291292
const end = node.getEnd() + astOffset;
292293

293294
if (str.original[end - 1] !== ';') {
294-
str.appendLeft(end, ';');
295+
preprendStr(str, end, ';');
295296
}
296297
}
297298

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<script>
2+
import A
3+
import C = require('');
4+
</script>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
///<reference types="svelte" />
2+
//----------------------------------------------------------------------------------------------------------------------------------------------------
3+
<></>;function render() { {/**
4+
=# Originless mappings
5+
<></>;function•render()•{↲ [generated] line 2
6+
< s
7+
<s
8+
<script>↲ [original] line 1 (rest generated at line 3)
9+
------------------------------------------------------------------------------------------------------------------------------------------------------ */}
10+
{/**
11+
↲ [generated] line 3
12+
13+
<script>↲ [original] line 1 (rest generated at line 2)
14+
------------------------------------------------------------------------------------------------------------------------------------------------------ */}
15+
import A; {/**
16+
••••import•A;↲ [generated] line 4
17+
••••import•A↲ [original] line 2
18+
------------------------------------------------------------------------------------------------------------------------------------------------------ */}
19+
import C = require(''); {/**
20+
------------------------------------------------------------------------------------------------------------------------------------------------------ */}
21+
; {/**
22+
;↲ [generated] line 6
23+
<
24+
</script> [original] line 4
25+
------------------------------------------------------------------------------------------------------------------------------------------------------ */}
26+
() => (<></>);
27+
return { props: {}, slots: {}, getters: {}, events: {} }}
28+
29+
export default class Input__SvelteComponent_ extends __sveltets_1_createSvelte2TsxComponent(__sveltets_1_partial(__sveltets_1_with_any_event(render()))) {
30+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/** tested-ranges: [] */
2+
/** origin-hash: 2qcima */

0 commit comments

Comments
 (0)