Skip to content

Commit 81019d9

Browse files
authored
fix: revert additional two-way-binding checks (#2508)
This reverts commit 8c080cf. This reverts #2477. Sadly, the idea didn't work out, as shown by two opened bug reports: - #2506: A type union can be narrowed on the input, but not on the way back out - #2494: A generic nested within a bound value is not properly resolved and not falling back to `any` (in #2477 we thought of the generic case, but only for when the generic is the whole value type, not when it's nested) For these reasons I don't see a way to properly implement #1392 at the moment.
1 parent e74f1d7 commit 81019d9

File tree

14 files changed

+14
-134
lines changed

14 files changed

+14
-134
lines changed

packages/language-server/src/plugins/typescript/features/RenameProvider.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -463,16 +463,8 @@ export class RenameProviderImpl implements RenameProvider {
463463
const mappedLocations = await Promise.all(
464464
renameLocations.map(async (loc) => {
465465
const snapshot = await snapshots.retrieve(loc.fileName);
466-
const text = snapshot.getFullText();
467-
const end = loc.textSpan.start + loc.textSpan.length;
468466

469-
if (
470-
!(snapshot instanceof SvelteDocumentSnapshot) ||
471-
(!isTextSpanInGeneratedCode(text, loc.textSpan) &&
472-
// prevent generated code for bindings from being renamed
473-
// (it's not inside a generate comment because diagnostics should show up)
474-
text.slice(end + 3, end + 27) !== '__sveltets_binding_value')
475-
) {
467+
if (!isTextSpanInGeneratedCode(snapshot.getFullText(), loc.textSpan)) {
476468
return {
477469
...loc,
478470
range: this.mapRangeToOriginal(snapshot, loc.textSpan),

packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/bindings-two-way-check/Legacy.svelte

Lines changed: 0 additions & 7 deletions
This file was deleted.

packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/bindings-two-way-check/Runes.svelte

Lines changed: 0 additions & 6 deletions
This file was deleted.

packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/bindings-two-way-check/RunesGeneric.svelte

Lines changed: 0 additions & 6 deletions
This file was deleted.

packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/bindings-two-way-check/expected_svelte_5.json

Lines changed: 0 additions & 36 deletions
This file was deleted.

packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/bindings-two-way-check/expectedv2.json

Lines changed: 0 additions & 18 deletions
This file was deleted.

packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/bindings-two-way-check/input.svelte

Lines changed: 0 additions & 19 deletions
This file was deleted.

packages/svelte2tsx/repl/index.svelte

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<script lang="ts">
2-
import MyComponent from './ComponentB.svelte'
3-
let value: Date
4-
$: console.log('value:', value)
1+
<script>
2+
export let value;
53
</script>
6-
7-
<MyComponent bind:value />
4+
5+
{#if value}
6+
<input bind:value on:change />
7+
{/if}

packages/svelte2tsx/src/htmlxtojsx_v2/nodes/Binding.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,6 @@ export function handleBinding(
131131
if (isSvelte5Plus && element instanceof InlineComponent) {
132132
// To check if property is actually bindable
133133
element.appendToStartEnd([`${element.name}.$$bindings = '${attr.name}';`]);
134-
// To check if the binding is also assigned to the variable (only works when there's no assertion, we can't transform that)
135-
if (!isTypescriptNode(attr.expression)) {
136-
element.appendToStartEnd([
137-
`${expressionStr} = __sveltets_binding_value(${element.originalName}, '${attr.name}');`
138-
]);
139-
}
140134
}
141135

142136
if (element instanceof Element) {

packages/svelte2tsx/src/htmlxtojsx_v2/nodes/InlineComponent.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export class InlineComponent {
3939
private startTagEnd: number;
4040
private isSelfclosing: boolean;
4141
public child?: any;
42-
public originalName = this.node.name;
4342

4443
// Add const $$xxx = ... only if the variable name is actually used
4544
// in order to prevent "$$xxx is defined but never used" TS hints

0 commit comments

Comments
 (0)