@@ -52,6 +52,7 @@ import {
5252} from './utils' ;
5353import { isInTag as svelteIsInTag } from '../svelte-ast-utils' ;
5454import { LanguageServiceContainer } from '../service' ;
55+ import { internalHelpers } from 'svelte2tsx' ;
5556
5657export interface CompletionResolveInfo
5758 extends Pick < ts . CompletionEntry , 'data' | 'name' | 'source' > ,
@@ -364,8 +365,9 @@ export class CompletionsProviderImpl implements CompletionsProvider<CompletionRe
364365 // import completions and then filter them down to likely matches.
365366 if ( wordInfo . word . charAt ( 0 ) === '$' ) {
366367 const storeName = wordInfo . word . substring ( 1 ) ;
368+ const typeChecker = lang . getProgram ( ) ?. getTypeChecker ( ) ;
367369 const text = '__sveltets_2_store_get(' + storeName ;
368- if ( ! tsDoc . getFullText ( ) . includes ( text ) ) {
370+ if ( ! tsDoc . getFullText ( ) . includes ( text ) && typeChecker ) {
369371 const pos = ( tsDoc . scriptInfo || tsDoc . moduleScriptInfo ) ?. endPos ?? {
370372 line : 0 ,
371373 character : 0
@@ -376,13 +378,26 @@ export class CompletionsProviderImpl implements CompletionsProvider<CompletionRe
376378 virtualOffset ,
377379 {
378380 ...userPreferences ,
381+ includeSymbol : true ,
379382 triggerCharacter : validTriggerCharacter
380383 } ,
381384 formatSettings
382385 ) ;
383386 for ( const entry of storeCompletions ?. entries || [ ] ) {
384- if ( entry . name . startsWith ( storeName ) ) {
385- addCompletion ( entry , true ) ;
387+ if (
388+ entry . symbol &&
389+ entry . source &&
390+ entry . name . startsWith ( storeName ) &&
391+ ! entry . name . startsWith ( '$' ) &&
392+ ! isGeneratedSvelteComponentName ( entry . name )
393+ ) {
394+ const aliasedSymbol =
395+ entry . symbol . flags & ts . SymbolFlags . Alias
396+ ? typeChecker . getAliasedSymbol ( entry . symbol )
397+ : entry . symbol ;
398+ if ( aliasedSymbol . flags & ts . SymbolFlags . Variable ) {
399+ addCompletion ( entry , true ) ;
400+ }
386401 }
387402 }
388403 }
@@ -1290,7 +1305,7 @@ function createIsValidCompletion(
12901305 return ! value . name . startsWith ( '__sveltets_' ) && ! svelte2tsxTypes . has ( value . name ) ;
12911306 }
12921307
1293- return ! value . name . startsWith ( '$$_' ) ;
1308+ return value . name !== internalHelpers . renderName && ! value . name . startsWith ( '$$_' ) ;
12941309 } ;
12951310 const isCompletionInHTMLStartTag = ! ! getNodeIfIsInHTMLStartTag (
12961311 document . html ,
0 commit comments