@@ -162,11 +162,22 @@ namespace ts { // eslint-disable-line one-namespace-per-file
162
162
performance . measure ( "Tracing" , "beginTracing" , "endTracing" ) ;
163
163
}
164
164
165
- function indexFromOne ( lc : LineAndCharacter ) : LineAndCharacter {
166
- return {
167
- line : lc . line + 1 ,
168
- character : lc . character + 1 ,
169
- } ;
165
+ function getLocation ( node : Node | undefined ) {
166
+ const file = getSourceFileOfNode ( node ) ;
167
+ return ! file
168
+ ? undefined
169
+ : {
170
+ path : file . path ,
171
+ start : indexFromOne ( getLineAndCharacterOfPosition ( file , node ! . pos ) ) ,
172
+ end : indexFromOne ( getLineAndCharacterOfPosition ( file , node ! . end ) ) ,
173
+ } ;
174
+
175
+ function indexFromOne ( lc : LineAndCharacter ) : LineAndCharacter {
176
+ return {
177
+ line : lc . line + 1 ,
178
+ character : lc . character + 1 ,
179
+ } ;
180
+ }
170
181
}
171
182
172
183
function dumpTypes ( types : readonly Type [ ] ) {
@@ -185,8 +196,6 @@ namespace ts { // eslint-disable-line one-namespace-per-file
185
196
const type = types [ i ] ;
186
197
const objectFlags = ( type as any ) . objectFlags ;
187
198
const symbol = type . aliasSymbol ?? type . symbol ;
188
- const firstDeclaration = symbol ?. declarations ?. [ 0 ] ;
189
- const firstFile = firstDeclaration && getSourceFileOfNode ( firstDeclaration ) ;
190
199
191
200
// It's slow to compute the display text, so skip it unless it's really valuable (or cheap)
192
201
let display : string | undefined ;
@@ -214,6 +223,7 @@ namespace ts { // eslint-disable-line one-namespace-per-file
214
223
referenceProperties = {
215
224
instantiatedType : referenceType . target ?. id ,
216
225
typeArguments : referenceType . resolvedTypeArguments ?. map ( t => t . id ) ,
226
+ referenceLocation : getLocation ( referenceType . node ) ,
217
227
} ;
218
228
}
219
229
@@ -228,6 +238,34 @@ namespace ts { // eslint-disable-line one-namespace-per-file
228
238
} ;
229
239
}
230
240
241
+ let substitutionProperties : object = { } ;
242
+ if ( type . flags & TypeFlags . Substitution ) {
243
+ const substitutionType = type as SubstitutionType ;
244
+ substitutionProperties = {
245
+ substitutionBaseType : substitutionType . baseType ?. id ,
246
+ substituteType : substitutionType . substitute ?. id ,
247
+ } ;
248
+ }
249
+
250
+ let reverseMappedProperties : object = { } ;
251
+ if ( objectFlags & ObjectFlags . ReverseMapped ) {
252
+ const reverseMappedType = type as ReverseMappedType ;
253
+ reverseMappedProperties = {
254
+ reverseMappedSourceType : reverseMappedType . source ?. id ,
255
+ reverseMappedMappedType : reverseMappedType . mappedType ?. id ,
256
+ reverseMappedConstraintType : reverseMappedType . constraintType ?. id ,
257
+ } ;
258
+ }
259
+
260
+ let evolvingArrayProperties : object = { } ;
261
+ if ( objectFlags & ObjectFlags . EvolvingArray ) {
262
+ const evolvingArrayType = type as EvolvingArrayType ;
263
+ evolvingArrayProperties = {
264
+ evolvingArrayElementType : evolvingArrayType . elementType . id ,
265
+ evolvingArrayFinalType : evolvingArrayType . finalArrayType ?. id ,
266
+ } ;
267
+ }
268
+
231
269
// We can't print out an arbitrary object, so just assign each one a unique number.
232
270
// Don't call it an "id" so people don't treat it as a type id.
233
271
let recursionToken : number | undefined ;
@@ -245,18 +283,19 @@ namespace ts { // eslint-disable-line one-namespace-per-file
245
283
intrinsicName : ( type as any ) . intrinsicName ,
246
284
symbolName : symbol ?. escapedName && unescapeLeadingUnderscores ( symbol . escapedName ) ,
247
285
recursionId : recursionToken ,
286
+ isTuple : objectFlags & ObjectFlags . Tuple ? true : undefined ,
248
287
unionTypes : ( type . flags & TypeFlags . Union ) ? ( type as UnionType ) . types ?. map ( t => t . id ) : undefined ,
249
288
intersectionTypes : ( type . flags & TypeFlags . Intersection ) ? ( type as IntersectionType ) . types . map ( t => t . id ) : undefined ,
250
289
aliasTypeArguments : type . aliasTypeArguments ?. map ( t => t . id ) ,
251
290
keyofType : ( type . flags & TypeFlags . Index ) ? ( type as IndexType ) . type ?. id : undefined ,
252
291
...indexedAccessProperties ,
253
292
...referenceProperties ,
254
293
...conditionalProperties ,
255
- firstDeclaration : firstDeclaration && {
256
- path : firstFile . path ,
257
- start : indexFromOne ( getLineAndCharacterOfPosition ( firstFile , firstDeclaration . pos ) ) ,
258
- end : indexFromOne ( getLineAndCharacterOfPosition ( getSourceFileOfNode ( firstDeclaration ) , firstDeclaration . end ) ) ,
259
- } ,
294
+ ... substitutionProperties ,
295
+ ... reverseMappedProperties ,
296
+ ... evolvingArrayProperties ,
297
+ destructuringPattern : getLocation ( type . pattern ) ,
298
+ firstDeclaration : getLocation ( symbol ?. declarations ?. [ 0 ] ) ,
260
299
flags : Debug . formatTypeFlags ( type . flags ) . split ( "|" ) ,
261
300
display,
262
301
} ;
0 commit comments