@@ -2174,7 +2174,7 @@ namespace FourSlash {
21742174 }
21752175
21762176 ts . zipWith ( expected , actual , ( expectedClassification , actualClassification ) => {
2177- const expectedType : string = ( < any > ts . ClassificationTypeNames ) [ expectedClassification . classificationType ] ;
2177+ const expectedType = expectedClassification . classificationType ;
21782178 if ( expectedType !== actualClassification . classificationType ) {
21792179 this . raiseError ( "verifyClassifications failed - expected classifications type to be " +
21802180 expectedType + ", but was " +
@@ -3876,7 +3876,7 @@ namespace FourSlashInterface {
38763876 /**
38773877 * This method *requires* an ordered stream of classifications for a file, and spans are highly recommended.
38783878 */
3879- public semanticClassificationsAre ( ...classifications : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } [ ] ) {
3879+ public semanticClassificationsAre ( ...classifications : Classification [ ] ) {
38803880 this . state . verifySemanticClassifications ( classifications ) ;
38813881 }
38823882
@@ -4071,102 +4071,107 @@ namespace FourSlashInterface {
40714071 }
40724072 }
40734073
4074+ interface Classification {
4075+ classificationType : ts . ClassificationTypeNames ;
4076+ text : string ;
4077+ textSpan ?: FourSlash . TextSpan ;
4078+ }
40744079 export namespace Classification {
4075- export function comment ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4076- return getClassification ( " comment" , text , position ) ;
4080+ export function comment ( text : string , position ?: number ) : Classification {
4081+ return getClassification ( ts . ClassificationTypeNames . comment , text , position ) ;
40774082 }
40784083
4079- export function identifier ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4080- return getClassification ( " identifier" , text , position ) ;
4084+ export function identifier ( text : string , position ?: number ) : Classification {
4085+ return getClassification ( ts . ClassificationTypeNames . identifier , text , position ) ;
40814086 }
40824087
4083- export function keyword ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4084- return getClassification ( " keyword" , text , position ) ;
4088+ export function keyword ( text : string , position ?: number ) : Classification {
4089+ return getClassification ( ts . ClassificationTypeNames . keyword , text , position ) ;
40854090 }
40864091
4087- export function numericLiteral ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4088- return getClassification ( " numericLiteral" , text , position ) ;
4092+ export function numericLiteral ( text : string , position ?: number ) : Classification {
4093+ return getClassification ( ts . ClassificationTypeNames . numericLiteral , text , position ) ;
40894094 }
40904095
4091- export function operator ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4092- return getClassification ( " operator" , text , position ) ;
4096+ export function operator ( text : string , position ?: number ) : Classification {
4097+ return getClassification ( ts . ClassificationTypeNames . operator , text , position ) ;
40934098 }
40944099
4095- export function stringLiteral ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4096- return getClassification ( " stringLiteral" , text , position ) ;
4100+ export function stringLiteral ( text : string , position ?: number ) : Classification {
4101+ return getClassification ( ts . ClassificationTypeNames . stringLiteral , text , position ) ;
40974102 }
40984103
4099- export function whiteSpace ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4100- return getClassification ( " whiteSpace" , text , position ) ;
4104+ export function whiteSpace ( text : string , position ?: number ) : Classification {
4105+ return getClassification ( ts . ClassificationTypeNames . whiteSpace , text , position ) ;
41014106 }
41024107
4103- export function text ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4104- return getClassification ( " text" , text , position ) ;
4108+ export function text ( text : string , position ?: number ) : Classification {
4109+ return getClassification ( ts . ClassificationTypeNames . text , text , position ) ;
41054110 }
41064111
4107- export function punctuation ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4108- return getClassification ( " punctuation" , text , position ) ;
4112+ export function punctuation ( text : string , position ?: number ) : Classification {
4113+ return getClassification ( ts . ClassificationTypeNames . punctuation , text , position ) ;
41094114 }
41104115
4111- export function docCommentTagName ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4112- return getClassification ( " docCommentTagName" , text , position ) ;
4116+ export function docCommentTagName ( text : string , position ?: number ) : Classification {
4117+ return getClassification ( ts . ClassificationTypeNames . docCommentTagName , text , position ) ;
41134118 }
41144119
4115- export function className ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4116- return getClassification ( " className" , text , position ) ;
4120+ export function className ( text : string , position ?: number ) : Classification {
4121+ return getClassification ( ts . ClassificationTypeNames . className , text , position ) ;
41174122 }
41184123
4119- export function enumName ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4120- return getClassification ( " enumName" , text , position ) ;
4124+ export function enumName ( text : string , position ?: number ) : Classification {
4125+ return getClassification ( ts . ClassificationTypeNames . enumName , text , position ) ;
41214126 }
41224127
4123- export function interfaceName ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4124- return getClassification ( " interfaceName" , text , position ) ;
4128+ export function interfaceName ( text : string , position ?: number ) : Classification {
4129+ return getClassification ( ts . ClassificationTypeNames . interfaceName , text , position ) ;
41254130 }
41264131
4127- export function moduleName ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4128- return getClassification ( " moduleName" , text , position ) ;
4132+ export function moduleName ( text : string , position ?: number ) : Classification {
4133+ return getClassification ( ts . ClassificationTypeNames . moduleName , text , position ) ;
41294134 }
41304135
4131- export function typeParameterName ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4132- return getClassification ( " typeParameterName" , text , position ) ;
4136+ export function typeParameterName ( text : string , position ?: number ) : Classification {
4137+ return getClassification ( ts . ClassificationTypeNames . typeParameterName , text , position ) ;
41334138 }
41344139
4135- export function parameterName ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4136- return getClassification ( " parameterName" , text , position ) ;
4140+ export function parameterName ( text : string , position ?: number ) : Classification {
4141+ return getClassification ( ts . ClassificationTypeNames . parameterName , text , position ) ;
41374142 }
41384143
4139- export function typeAliasName ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4140- return getClassification ( " typeAliasName" , text , position ) ;
4144+ export function typeAliasName ( text : string , position ?: number ) : Classification {
4145+ return getClassification ( ts . ClassificationTypeNames . typeAliasName , text , position ) ;
41414146 }
41424147
4143- export function jsxOpenTagName ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4144- return getClassification ( " jsxOpenTagName" , text , position ) ;
4148+ export function jsxOpenTagName ( text : string , position ?: number ) : Classification {
4149+ return getClassification ( ts . ClassificationTypeNames . jsxOpenTagName , text , position ) ;
41454150 }
41464151
4147- export function jsxCloseTagName ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4148- return getClassification ( " jsxCloseTagName" , text , position ) ;
4152+ export function jsxCloseTagName ( text : string , position ?: number ) : Classification {
4153+ return getClassification ( ts . ClassificationTypeNames . jsxCloseTagName , text , position ) ;
41494154 }
41504155
4151- export function jsxSelfClosingTagName ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4152- return getClassification ( " jsxSelfClosingTagName" , text , position ) ;
4156+ export function jsxSelfClosingTagName ( text : string , position ?: number ) : Classification {
4157+ return getClassification ( ts . ClassificationTypeNames . jsxSelfClosingTagName , text , position ) ;
41534158 }
41544159
4155- export function jsxAttribute ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4156- return getClassification ( " jsxAttribute" , text , position ) ;
4160+ export function jsxAttribute ( text : string , position ?: number ) : Classification {
4161+ return getClassification ( ts . ClassificationTypeNames . jsxAttribute , text , position ) ;
41574162 }
41584163
4159- export function jsxText ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4160- return getClassification ( " jsxText" , text , position ) ;
4164+ export function jsxText ( text : string , position ?: number ) : Classification {
4165+ return getClassification ( ts . ClassificationTypeNames . jsxText , text , position ) ;
41614166 }
41624167
4163- export function jsxAttributeStringLiteralValue ( text : string , position ?: number ) : { classificationType : string ; text : string ; textSpan ?: FourSlash . TextSpan } {
4164- return getClassification ( " jsxAttributeStringLiteralValue" , text , position ) ;
4168+ export function jsxAttributeStringLiteralValue ( text : string , position ?: number ) : Classification {
4169+ return getClassification ( ts . ClassificationTypeNames . jsxAttributeStringLiteralValue , text , position ) ;
41654170 }
41664171
4167- function getClassification ( type : string , text : string , position ?: number ) {
4172+ function getClassification ( classificationType : ts . ClassificationTypeNames , text : string , position ?: number ) : Classification {
41684173 return {
4169- classificationType : type ,
4174+ classificationType,
41704175 text : text ,
41714176 textSpan : position === undefined ? undefined : { start : position , end : position + text . length }
41724177 } ;
0 commit comments