@@ -8,7 +8,14 @@ namespace ts.Completions {
8
8
SuggestedClassMembers = "4" ,
9
9
GlobalsOrKeywords = "5" ,
10
10
AutoImportSuggestions = "6" ,
11
- JavascriptIdentifiers = "7"
11
+ DeprecatedLocalDeclarationPriority = "7" ,
12
+ DeprecatedLocationPriority = "8" ,
13
+ DeprecatedOptionalMember = "9" ,
14
+ DeprecatedMemberDeclaredBySpreadAssignment = "10" ,
15
+ DeprecatedSuggestedClassMembers = "11" ,
16
+ DeprecatedGlobalsOrKeywords = "12" ,
17
+ DeprecatedAutoImportSuggestions = "13" ,
18
+ JavascriptIdentifiers = "14"
12
19
}
13
20
export type Log = ( message : string ) => void ;
14
21
@@ -585,9 +592,11 @@ namespace ts.Completions {
585
592
}
586
593
587
594
const { name, needsConvertPropertyAccess } = info ;
595
+ const sortText = symbolToSortTextMap && symbolToSortTextMap [ getSymbolId ( symbol ) ]
596
+ || ( isDeprecatedSymbol ( symbol , typeChecker ) ? SortText . DeprecatedLocationPriority : SortText . LocationPriority ) ;
588
597
const entry = createCompletionEntry (
589
598
symbol ,
590
- symbolToSortTextMap && symbolToSortTextMap [ getSymbolId ( symbol ) ] || SortText . LocationPriority ,
599
+ sortText ,
591
600
contextToken ,
592
601
location ,
593
602
sourceFile ,
@@ -641,13 +650,15 @@ namespace ts.Completions {
641
650
// module imports then the global keywords will be filtered out so auto
642
651
// import suggestions will win in the completion
643
652
const symbolOrigin = skipAlias ( symbol , typeChecker ) ;
653
+ const symbolOriginSortText = symbolToSortTextMap [ getSymbolId ( symbolOrigin ) ] ;
654
+ const symbolSortText = symbolToSortTextMap [ getSymbolId ( symbol ) ] ;
644
655
// We only want to filter out the global keywords
645
656
// Auto Imports are not available for scripts so this conditional is always false
646
657
if ( ! ! sourceFile . externalModuleIndicator
647
658
&& ! compilerOptions . allowUmdGlobalAccess
648
- && symbolToSortTextMap [ getSymbolId ( symbol ) ] === SortText . GlobalsOrKeywords
649
- && ( symbolToSortTextMap [ getSymbolId ( symbolOrigin ) ] === SortText . AutoImportSuggestions
650
- || symbolToSortTextMap [ getSymbolId ( symbolOrigin ) ] === SortText . LocationPriority ) ) {
659
+ && ( symbolSortText === SortText . GlobalsOrKeywords || symbolSortText === SortText . DeprecatedGlobalsOrKeywords )
660
+ && ( ( symbolOriginSortText === SortText . AutoImportSuggestions || symbolOriginSortText === SortText . DeprecatedAutoImportSuggestions )
661
+ || ( symbolOriginSortText === SortText . LocationPriority || symbolOriginSortText === SortText . DeprecatedLocationPriority ) ) ) {
651
662
return false ;
652
663
}
653
664
// Continue with origin symbol
@@ -669,8 +680,6 @@ namespace ts.Completions {
669
680
}
670
681
}
671
682
672
-
673
-
674
683
function getLabelCompletionAtPosition ( node : BreakOrContinueStatement ) : CompletionInfo | undefined {
675
684
const entries = getLabelStatementCompletions ( node ) ;
676
685
if ( entries . length ) {
@@ -1484,7 +1493,8 @@ namespace ts.Completions {
1484
1493
1485
1494
function addSymbolSortInfo ( symbol : Symbol ) {
1486
1495
if ( isStaticProperty ( symbol ) ) {
1487
- symbolToSortTextMap [ getSymbolId ( symbol ) ] = SortText . LocalDeclarationPriority ;
1496
+ symbolToSortTextMap [ getSymbolId ( symbol ) ] =
1497
+ isDeprecatedSymbol ( symbol , typeChecker ) ? SortText . DeprecatedLocalDeclarationPriority : SortText . LocalDeclarationPriority ;
1488
1498
}
1489
1499
}
1490
1500
@@ -1599,9 +1609,9 @@ namespace ts.Completions {
1599
1609
symbols = typeChecker . getSymbolsInScope ( scopeNode , symbolMeanings ) ;
1600
1610
Debug . assertEachIsDefined ( symbols , "getSymbolsInScope() should all be defined" ) ;
1601
1611
for ( const symbol of symbols ) {
1602
- if ( ! typeChecker . isArgumentsSymbol ( symbol ) &&
1603
- ! some ( symbol . declarations , d => d . getSourceFile ( ) === sourceFile ) ) {
1604
- symbolToSortTextMap [ getSymbolId ( symbol ) ] = SortText . GlobalsOrKeywords ;
1612
+ if ( ! typeChecker . isArgumentsSymbol ( symbol ) && ! some ( symbol . declarations , d => d . getSourceFile ( ) === sourceFile ) ) {
1613
+ symbolToSortTextMap [ getSymbolId ( symbol ) ] =
1614
+ isDeprecatedSymbol ( symbol , typeChecker ) ? SortText . DeprecatedGlobalsOrKeywords : SortText . GlobalsOrKeywords ;
1605
1615
}
1606
1616
}
1607
1617
@@ -1612,7 +1622,8 @@ namespace ts.Completions {
1612
1622
for ( const symbol of getPropertiesForCompletion ( thisType , typeChecker ) ) {
1613
1623
symbolToOriginInfoMap [ symbols . length ] = { kind : SymbolOriginInfoKind . ThisType } ;
1614
1624
symbols . push ( symbol ) ;
1615
- symbolToSortTextMap [ getSymbolId ( symbol ) ] = SortText . SuggestedClassMembers ;
1625
+ symbolToSortTextMap [ getSymbolId ( symbol ) ] =
1626
+ isDeprecatedSymbol ( symbol , typeChecker ) ? SortText . DeprecatedSuggestedClassMembers : SortText . SuggestedClassMembers ;
1616
1627
}
1617
1628
}
1618
1629
}
@@ -1765,12 +1776,16 @@ namespace ts.Completions {
1765
1776
1766
1777
function pushAutoImportSymbol ( symbol : Symbol , origin : SymbolOriginInfoResolvedExport | SymbolOriginInfoExport ) {
1767
1778
const symbolId = getSymbolId ( symbol ) ;
1768
- if ( symbolToSortTextMap [ symbolId ] === SortText . GlobalsOrKeywords ) {
1779
+ if ( symbolToSortTextMap [ symbolId ] === SortText . GlobalsOrKeywords
1780
+ || symbolToSortTextMap [ symbolId ] === SortText . DeprecatedGlobalsOrKeywords ) {
1769
1781
// If an auto-importable symbol is available as a global, don't add the auto import
1770
1782
return ;
1771
1783
}
1772
1784
symbolToOriginInfoMap [ symbols . length ] = origin ;
1773
- symbolToSortTextMap [ symbolId ] = importCompletionNode ? SortText . LocationPriority : SortText . AutoImportSuggestions ;
1785
+ symbolToSortTextMap [ symbolId ] =
1786
+ isDeprecatedSymbol ( symbol , typeChecker )
1787
+ ? importCompletionNode ? SortText . DeprecatedLocationPriority : SortText . DeprecatedAutoImportSuggestions
1788
+ : importCompletionNode ? SortText . LocationPriority : SortText . AutoImportSuggestions ;
1774
1789
symbols . push ( symbol ) ;
1775
1790
}
1776
1791
@@ -2085,7 +2100,8 @@ namespace ts.Completions {
2085
2100
localsContainer . locals ?. forEach ( ( symbol , name ) => {
2086
2101
symbols . push ( symbol ) ;
2087
2102
if ( localsContainer . symbol ?. exports ?. has ( name ) ) {
2088
- symbolToSortTextMap [ getSymbolId ( symbol ) ] = SortText . OptionalMember ;
2103
+ symbolToSortTextMap [ getSymbolId ( symbol ) ] =
2104
+ isDeprecatedSymbol ( symbol , typeChecker ) ? SortText . DeprecatedOptionalMember : SortText . OptionalMember ;
2089
2105
}
2090
2106
} ) ;
2091
2107
return GlobalsSearch . Success ;
@@ -2500,7 +2516,8 @@ namespace ts.Completions {
2500
2516
function setSortTextToOptionalMember ( ) {
2501
2517
symbols . forEach ( m => {
2502
2518
if ( m . flags & SymbolFlags . Optional ) {
2503
- symbolToSortTextMap [ getSymbolId ( m ) ] = symbolToSortTextMap [ getSymbolId ( m ) ] || SortText . OptionalMember ;
2519
+ symbolToSortTextMap [ getSymbolId ( m ) ] =
2520
+ symbolToSortTextMap [ getSymbolId ( m ) ] || ( isDeprecatedSymbol ( m , typeChecker ) ? SortText . DeprecatedOptionalMember : SortText . OptionalMember ) ;
2504
2521
}
2505
2522
} ) ;
2506
2523
}
@@ -2512,7 +2529,8 @@ namespace ts.Completions {
2512
2529
}
2513
2530
for ( const contextualMemberSymbol of contextualMemberSymbols ) {
2514
2531
if ( membersDeclaredBySpreadAssignment . has ( contextualMemberSymbol . name ) ) {
2515
- symbolToSortTextMap [ getSymbolId ( contextualMemberSymbol ) ] = SortText . MemberDeclaredBySpreadAssignment ;
2532
+ symbolToSortTextMap [ getSymbolId ( contextualMemberSymbol ) ] =
2533
+ isDeprecatedSymbol ( contextualMemberSymbol , typeChecker ) ? SortText . DeprecatedMemberDeclaredBySpreadAssignment : SortText . MemberDeclaredBySpreadAssignment ;
2516
2534
}
2517
2535
}
2518
2536
}
@@ -3051,4 +3069,9 @@ namespace ts.Completions {
3051
3069
addToSeen ( seenModules , getSymbolId ( sym ) ) &&
3052
3070
checker . getExportsOfModule ( sym ) . some ( e => symbolCanBeReferencedAtTypeLocation ( e , checker , seenModules ) ) ;
3053
3071
}
3072
+
3073
+ function isDeprecatedSymbol ( symbol : Symbol , checker : TypeChecker ) {
3074
+ const declarations = skipAlias ( symbol , checker ) . declarations ;
3075
+ return ! ! length ( declarations ) && every ( declarations , isDeprecatedDeclaration ) ;
3076
+ }
3054
3077
}
0 commit comments