File tree Expand file tree Collapse file tree 8 files changed +18
-17
lines changed
language-server/src/plugins/typescript/features
binding-this-svelte-component Expand file tree Collapse file tree 8 files changed +18
-17
lines changed Original file line number Diff line number Diff line change @@ -311,13 +311,18 @@ export class RenameProviderImpl implements RenameProvider {
311311 }
312312
313313 const content = snapshot . getText ( 0 , snapshot . getLength ( ) ) ;
314- const svelteInstanceOfFn = '__sveltets_instanceOf(' ;
315314 // When the user renames a Svelte component, ts will also want to rename
316- // `__sveltets_instanceOf(TheComponentToRename)`. Prevent that.
315+ // `__sveltets_instanceOf(TheComponentToRename)` or
316+ // `__sveltets_ensureType(TheComponentToRename,..`. Prevent that.
317317 return (
318- content . lastIndexOf ( svelteInstanceOfFn , loc . textSpan . start ) !==
319- loc . textSpan . start - svelteInstanceOfFn . length
318+ notPrecededBy ( '__sveltets_instanceOf(' ) && notPrecededBy ( '__sveltets_ensureType(' )
320319 ) ;
320+
321+ function notPrecededBy ( str : string ) {
322+ return (
323+ content . lastIndexOf ( str , loc . textSpan . start ) !== loc . textSpan . start - str . length
324+ ) ;
325+ }
321326 } ) ;
322327 }
323328
Original file line number Diff line number Diff line change @@ -214,12 +214,8 @@ export function convertHtmlxToJsx(
214214
215215 if ( thisType ) {
216216 str . remove ( attr . start , attr . expression . start ) ;
217- str . appendLeft ( attr . expression . start , '{...__sveltets_empty(' ) ;
218- str . overwrite (
219- attr . expression . end ,
220- attr . end ,
221- `=__sveltets_instanceOf(${ thisType } ))}`
222- ) ;
217+ str . appendLeft ( attr . expression . start , `{...__sveltets_ensureType(${ thisType } , ` ) ;
218+ str . overwrite ( attr . expression . end , attr . end , ')}' ) ;
223219 return ;
224220 }
225221 }
Original file line number Diff line number Diff line change 1- < > < Component type = "radio" { ...__sveltets_empty ( element = __sveltets_instanceOf ( Component ) ) } value = "Plain" /> </ >
1+ < > < Component type = "radio" { ...__sveltets_ensureType ( Component , element ) } value = "Plain" /> </ >
Original file line number Diff line number Diff line change 1- < > < sveltebody { ...__sveltets_empty ( element = __sveltets_instanceOf ( HTMLBodyElement ) ) } /> </ >
1+ < > < sveltebody { ...__sveltets_ensureType ( HTMLBodyElement , element ) } /> </ >
Original file line number Diff line number Diff line change 1- < > < sveltecomponent this = { A } { ...__sveltets_empty ( element = __sveltets_instanceOf ( __sveltets_componentType ( ) ) ) } /> </ >
1+ < > < sveltecomponent this = { A } { ...__sveltets_ensureType ( __sveltets_componentType ( ) , element ) } /> </ >
Original file line number Diff line number Diff line change 11< > { ( ) => { if ( false ) { < >
2- < svelteself { ...__sveltets_empty ( element = __sveltets_instanceOf ( __sveltets_componentType ( ) ) ) } />
2+ < svelteself { ...__sveltets_ensureType ( __sveltets_componentType ( ) , element ) } />
33</ > } } } </ >
Original file line number Diff line number Diff line change 1- < > < input type = "radio" { ...__sveltets_empty ( element = __sveltets_instanceOf ( HTMLElement ) ) } value = "Plain" /> </ >
1+ < > < input type = "radio" { ...__sveltets_ensureType ( HTMLElement , element ) } value = "Plain" /> </ >
Original file line number Diff line number Diff line change 135135 < TableOfContents sections ={sections} slug ={slug} selected ={selected}/ >
136136 </ div >
137137
138- < div class ="chapter-markup " {...__sveltets_empty(scrollable = __sveltets_instanceOf( HTMLElement) )}>
138+ < div class ="chapter-markup " {...__sveltets_ensureType( HTMLElement, scrollable )}>
139139 { chapter.html}
140140
141141 < div class ="controls ">
159159
160160 < div class ="tutorial-repl ">
161161 < Repl
162- {...__sveltets_empty(repl = __sveltets_instanceOf( Repl) )}
162+ {...__sveltets_ensureType( Repl, repl )}
163163 workersUrl ="workers "
164164 svelteUrl ={svelteUrl}
165165 rollupUrl ={rollupUrl}
You can’t perform that action at this time.
0 commit comments