Skip to content

Commit

Permalink
fix: better bind:group transformation (#2349)
Browse files Browse the repository at this point in the history
reuse the one way binding transformation to get autocompletion, error diagnostics etc
#2337
  • Loading branch information
dummdidumm committed Apr 25, 2024
1 parent 6aa40f7 commit fcc148d
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 13 deletions.
8 changes: 1 addition & 7 deletions packages/svelte2tsx/src/htmlxtojsx_v2/nodes/Binding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,7 @@ export function handleBinding(
// bind group on input
if (element instanceof Element && attr.name == 'group' && parent.name == 'input') {
// add reassignment to force TS to widen the type of the declaration (in case it's never reassigned anywhere else)
const expressionStr = str.original.substring(
attr.expression.start,
getEnd(attr.expression)
);
element.appendToStartEnd([
surroundWithIgnoreComments(`() => ${expressionStr} = __sveltets_2_any(null);`)
]);
appendOneWayBinding(attr, ' = __sveltets_2_any(null)', element);
return;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{ svelteHTML.createElement("input", { "type":`radio`,"value":`Plain`,});/*Ωignore_startΩ*/() => group = __sveltets_2_any(null);/*Ωignore_endΩ*/}
{ svelteHTML.createElement("input", { "type":`radio`,"value":`Plain`,});/*Ωignore_startΩ*/() => group = __sveltets_2_any(null);/*Ωignore_endΩ*/}
{ svelteHTML.createElement("input", { "type":`radio`,"value":`Plain`,});group = __sveltets_2_any(null);}
{ svelteHTML.createElement("input", { "type":`radio`,"value":`Plain`,});group = __sveltets_2_any(null);}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///<reference types="svelte" />
;function render() {
async () => { { svelteHTML.createElement("input", { "id":`dom-input`,"type":`radio`,"value":`dom`,});/*Ωignore_startΩ*/() => $compile_options.generate = __sveltets_2_any(null);/*Ωignore_endΩ*/}};
async () => { { svelteHTML.createElement("input", { "id":`dom-input`,"type":`radio`,"value":`dom`,});$compile_options.generate = __sveltets_2_any(null);}};
return { props: /** @type {Record<string, never>} */ ({}), slots: {}, events: {} }}

export default class Input__SvelteComponent_ extends __sveltets_2_createSvelte2TsxComponent(__sveltets_2_partial(__sveltets_2_with_any_event(render()))) {
Expand Down

0 comments on commit fcc148d

Please sign in to comment.