@@ -4552,11 +4552,45 @@ namespace FourSlashInterface {
4552
4552
] ;
4553
4553
}
4554
4554
4555
+ function getInJsKeywords ( keywords : ReadonlyArray < ExpectedCompletionEntryObject > ) : ReadonlyArray < ExpectedCompletionEntryObject > {
4556
+ return keywords . filter ( keyword => {
4557
+ switch ( keyword . name ) {
4558
+ case "enum" :
4559
+ case "interface" :
4560
+ case "private" :
4561
+ case "protected" :
4562
+ case "public" :
4563
+ case "abstract" :
4564
+ case "any" :
4565
+ case "boolean" :
4566
+ case "declare" :
4567
+ case "infer" :
4568
+ case "is" :
4569
+ case "keyof" :
4570
+ case "module" :
4571
+ case "namespace" :
4572
+ case "never" :
4573
+ case "readonly" :
4574
+ case "number" :
4575
+ case "object" :
4576
+ case "string" :
4577
+ case "symbol" :
4578
+ case "type" :
4579
+ case "unique" :
4580
+ case "unknown" :
4581
+ case "global" :
4582
+ case "bigint" :
4583
+ return false ;
4584
+ default :
4585
+ return true ;
4586
+ }
4587
+ } ) ;
4588
+ }
4589
+
4555
4590
export const classElementKeywords : ReadonlyArray < ExpectedCompletionEntryObject > =
4556
4591
[ "private" , "protected" , "public" , "static" , "abstract" , "async" , "constructor" , "get" , "readonly" , "set" ] . map ( keywordEntry ) ;
4557
4592
4558
- export const classElementInJsKeywords : ReadonlyArray < ExpectedCompletionEntryObject > =
4559
- [ "async" , "constructor" , "get" , "set" ] . map ( keywordEntry ) ;
4593
+ export const classElementInJsKeywords = getInJsKeywords ( classElementKeywords ) ;
4560
4594
4561
4595
export const constructorParameterKeywords : ReadonlyArray < ExpectedCompletionEntryObject > =
4562
4596
[ "private" , "protected" , "public" , "readonly" ] . map ( ( name ) : ExpectedCompletionEntryObject => ( { name, kind : "keyword" } ) ) ;
@@ -4695,58 +4729,7 @@ namespace FourSlashInterface {
4695
4729
}
4696
4730
} ) ;
4697
4731
4698
- export const statementInJsKeywords : ReadonlyArray < ExpectedCompletionEntryObject > = [
4699
- "break" ,
4700
- "case" ,
4701
- "catch" ,
4702
- "class" ,
4703
- "const" ,
4704
- "continue" ,
4705
- "debugger" ,
4706
- "default" ,
4707
- "delete" ,
4708
- "do" ,
4709
- "else" ,
4710
- "enum" ,
4711
- "export" ,
4712
- "extends" ,
4713
- "false" ,
4714
- "finally" ,
4715
- "for" ,
4716
- "function" ,
4717
- "if" ,
4718
- "import" ,
4719
- "in" ,
4720
- "instanceof" ,
4721
- "new" ,
4722
- "null" ,
4723
- "return" ,
4724
- "super" ,
4725
- "switch" ,
4726
- "this" ,
4727
- "throw" ,
4728
- "true" ,
4729
- "try" ,
4730
- "typeof" ,
4731
- "var" ,
4732
- "void" ,
4733
- "while" ,
4734
- "with" ,
4735
- "implements" ,
4736
- "interface" ,
4737
- "let" ,
4738
- "package" ,
4739
- "yield" ,
4740
- "as" ,
4741
- "async" ,
4742
- "await" ,
4743
- "constructor" ,
4744
- "get" ,
4745
- "require" ,
4746
- "set" ,
4747
- "from" ,
4748
- "of" ,
4749
- ] . map ( keywordEntry ) ;
4732
+ export const statementInJsKeywords = getInJsKeywords ( statementKeywords ) ;
4750
4733
4751
4734
export const globalsVars : ReadonlyArray < ExpectedCompletionEntryObject > = [
4752
4735
functionEntry ( "eval" ) ,
@@ -4849,49 +4832,7 @@ namespace FourSlashInterface {
4849
4832
...globalKeywordsInsideFunction ,
4850
4833
] ;
4851
4834
4852
- const globalInJsKeywordsInsideFunction : ReadonlyArray < ExpectedCompletionEntryObject > = [
4853
- "break" ,
4854
- "case" ,
4855
- "catch" ,
4856
- "class" ,
4857
- "const" ,
4858
- "continue" ,
4859
- "debugger" ,
4860
- "default" ,
4861
- "delete" ,
4862
- "do" ,
4863
- "else" ,
4864
- "export" ,
4865
- "extends" ,
4866
- "false" ,
4867
- "finally" ,
4868
- "for" ,
4869
- "function" ,
4870
- "if" ,
4871
- "import" ,
4872
- "in" ,
4873
- "instanceof" ,
4874
- "new" ,
4875
- "null" ,
4876
- "return" ,
4877
- "super" ,
4878
- "switch" ,
4879
- "this" ,
4880
- "throw" ,
4881
- "true" ,
4882
- "try" ,
4883
- "typeof" ,
4884
- "var" ,
4885
- "void" ,
4886
- "while" ,
4887
- "with" ,
4888
- "implements" ,
4889
- "let" ,
4890
- "package" ,
4891
- "yield" ,
4892
- "async" ,
4893
- "await" ,
4894
- ] . map ( keywordEntry ) ;
4835
+ const globalInJsKeywordsInsideFunction = getInJsKeywords ( globalKeywordsInsideFunction ) ;
4895
4836
4896
4837
// TODO: many of these are inappropriate to always provide
4897
4838
export const globalsInJsInsideFunction = ( plus : ReadonlyArray < ExpectedCompletionEntry > ) : ReadonlyArray < ExpectedCompletionEntry > => [
@@ -4981,56 +4922,7 @@ namespace FourSlashInterface {
4981
4922
"of" ,
4982
4923
] . map ( keywordEntry ) ;
4983
4924
4984
- export const globalInJsKeywords : ReadonlyArray < ExpectedCompletionEntryObject > = [
4985
- "break" ,
4986
- "case" ,
4987
- "catch" ,
4988
- "class" ,
4989
- "const" ,
4990
- "continue" ,
4991
- "debugger" ,
4992
- "default" ,
4993
- "delete" ,
4994
- "do" ,
4995
- "else" ,
4996
- "export" ,
4997
- "extends" ,
4998
- "false" ,
4999
- "finally" ,
5000
- "for" ,
5001
- "function" ,
5002
- "if" ,
5003
- "import" ,
5004
- "in" ,
5005
- "instanceof" ,
5006
- "new" ,
5007
- "null" ,
5008
- "return" ,
5009
- "super" ,
5010
- "switch" ,
5011
- "this" ,
5012
- "throw" ,
5013
- "true" ,
5014
- "try" ,
5015
- "typeof" ,
5016
- "var" ,
5017
- "void" ,
5018
- "while" ,
5019
- "with" ,
5020
- "implements" ,
5021
- "let" ,
5022
- "package" ,
5023
- "yield" ,
5024
- "as" ,
5025
- "async" ,
5026
- "await" ,
5027
- "constructor" ,
5028
- "get" ,
5029
- "require" ,
5030
- "set" ,
5031
- "from" ,
5032
- "of" ,
5033
- ] . map ( keywordEntry ) ;
4925
+ export const globalInJsKeywords = getInJsKeywords ( globalKeywords ) ;
5034
4926
5035
4927
export const insideMethodKeywords : ReadonlyArray < ExpectedCompletionEntryObject > = [
5036
4928
"break" ,
@@ -5078,49 +4970,7 @@ namespace FourSlashInterface {
5078
4970
"await" ,
5079
4971
] . map ( keywordEntry ) ;
5080
4972
5081
- export const insideMethodInJsKeywords : ReadonlyArray < ExpectedCompletionEntryObject > = [
5082
- "break" ,
5083
- "case" ,
5084
- "catch" ,
5085
- "class" ,
5086
- "const" ,
5087
- "continue" ,
5088
- "debugger" ,
5089
- "default" ,
5090
- "delete" ,
5091
- "do" ,
5092
- "else" ,
5093
- "export" ,
5094
- "extends" ,
5095
- "false" ,
5096
- "finally" ,
5097
- "for" ,
5098
- "function" ,
5099
- "if" ,
5100
- "import" ,
5101
- "in" ,
5102
- "instanceof" ,
5103
- "new" ,
5104
- "null" ,
5105
- "return" ,
5106
- "super" ,
5107
- "switch" ,
5108
- "this" ,
5109
- "throw" ,
5110
- "true" ,
5111
- "try" ,
5112
- "typeof" ,
5113
- "var" ,
5114
- "void" ,
5115
- "while" ,
5116
- "with" ,
5117
- "implements" ,
5118
- "let" ,
5119
- "package" ,
5120
- "yield" ,
5121
- "async" ,
5122
- "await" ,
5123
- ] . map ( keywordEntry ) ;
4973
+ export const insideMethodInJsKeywords = getInJsKeywords ( insideMethodKeywords ) ;
5124
4974
5125
4975
export const globalKeywordsPlusUndefined : ReadonlyArray < ExpectedCompletionEntryObject > = ( ( ) => {
5126
4976
const i = ts . findIndex ( globalKeywords , x => x . name === "unique" ) ;
0 commit comments