@@ -1862,35 +1862,33 @@ function createCompletionEntry(
1862
1862
) {
1863
1863
// Check if we should use quotes for string-like types
1864
1864
let shouldUseQuotes = false ;
1865
-
1865
+
1866
1866
if ( type . flags & TypeFlags . StringLike ) {
1867
1867
// Direct string-like type
1868
1868
shouldUseQuotes = true ;
1869
- } else if ( type . flags & TypeFlags . Union ) {
1869
+ }
1870
+ else if ( type . flags & TypeFlags . Union ) {
1870
1871
const unionType = type as UnionType ;
1871
1872
// Check if all types are string-like or undefined (original logic)
1872
- const allTypesAreStringLikeOrUndefined = every ( unionType . types , type =>
1873
- ! ! ( type . flags & ( TypeFlags . StringLike | TypeFlags . Undefined ) || isStringAndEmptyAnonymousObjectIntersection ( type ) )
1874
- ) ;
1875
-
1873
+ const allTypesAreStringLikeOrUndefined = every ( unionType . types , type => ! ! ( type . flags & ( TypeFlags . StringLike | TypeFlags . Undefined ) || isStringAndEmptyAnonymousObjectIntersection ( type ) ) ) ;
1874
+
1876
1875
if ( allTypesAreStringLikeOrUndefined ) {
1877
1876
shouldUseQuotes = true ;
1878
- } else {
1877
+ }
1878
+ else {
1879
1879
// Check if the union contains string-like types that users would typically provide as strings
1880
1880
// This handles cases like Preact's Signalish<string | undefined> = string | undefined | SignalLike<string | undefined>
1881
1881
const hasStringLikeTypes = some ( unionType . types , type => ! ! ( type . flags & TypeFlags . StringLike ) ) ;
1882
- const hasNonObjectTypes = some ( unionType . types , type =>
1883
- ! ! ( type . flags & ( TypeFlags . StringLike | TypeFlags . Undefined | TypeFlags . Null ) )
1884
- ) ;
1885
-
1882
+ const hasNonObjectTypes = some ( unionType . types , type => ! ! ( type . flags & ( TypeFlags . StringLike | TypeFlags . Undefined | TypeFlags . Null ) ) ) ;
1883
+
1886
1884
// If the union has string-like types and at least some primitive types (not just objects),
1887
1885
// prefer quotes since users commonly want to provide string values
1888
1886
if ( hasStringLikeTypes && hasNonObjectTypes ) {
1889
1887
shouldUseQuotes = true ;
1890
1888
}
1891
1889
}
1892
1890
}
1893
-
1891
+
1894
1892
if ( shouldUseQuotes ) {
1895
1893
// If is string like or undefined use quotes
1896
1894
insertText = `${ escapeSnippetText ( name ) } =${ quote ( sourceFile , preferences , "$1" ) } ` ;
0 commit comments