• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rokucommunity / brighterscript / #14385

09 May 2025 11:44AM UTC coverage: 87.032% (-2.0%) from 89.017%
#14385

push

web-flow
Merge a194c3925 into 489231ac7

13732 of 16677 branches covered (82.34%)

Branch coverage included in aggregate %.

8175 of 8874 new or added lines in 103 files covered. (92.12%)

84 existing lines in 22 files now uncovered.

14604 of 15881 relevant lines covered (91.96%)

20324.31 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.65
/src/astUtils/reflection.ts
1
import type { Body, AssignmentStatement, Block, ExpressionStatement, FunctionStatement, IfStatement, IncrementStatement, PrintStatement, GotoStatement, LabelStatement, ReturnStatement, EndStatement, StopStatement, ForStatement, ForEachStatement, WhileStatement, DottedSetStatement, IndexedSetStatement, LibraryStatement, NamespaceStatement, ImportStatement, ClassStatement, InterfaceFieldStatement, InterfaceMethodStatement, InterfaceStatement, EnumStatement, EnumMemberStatement, TryCatchStatement, CatchStatement, ThrowStatement, MethodStatement, FieldStatement, ConstStatement, ContinueStatement, DimStatement, TypecastStatement, AliasStatement, AugmentedAssignmentStatement, ConditionalCompileConstStatement, ConditionalCompileErrorStatement, ConditionalCompileStatement, ExitStatement } from '../parser/Statement';
2
import type { LiteralExpression, BinaryExpression, CallExpression, FunctionExpression, DottedGetExpression, XmlAttributeGetExpression, IndexedGetExpression, GroupingExpression, EscapedCharCodeLiteralExpression, ArrayLiteralExpression, AALiteralExpression, UnaryExpression, VariableExpression, SourceLiteralExpression, NewExpression, CallfuncExpression, TemplateStringQuasiExpression, TemplateStringExpression, TaggedTemplateStringExpression, AnnotationExpression, FunctionParameterExpression, AAMemberExpression, TernaryExpression, NullCoalescingExpression, PrintSeparatorExpression, TypecastExpression, TypedArrayExpression, TypeExpression } from '../parser/Expression';
3
import type { BrsFile } from '../files/BrsFile';
4
import type { XmlFile } from '../files/XmlFile';
5
import type { BsDiagnostic, TypedefProvider } from '../interfaces';
6
import type { InvalidType } from '../types/InvalidType';
7
import type { VoidType } from '../types/VoidType';
8
import { InternalWalkMode } from './visitors';
1✔
9
import type { TypedFunctionType } from '../types/TypedFunctionType';
10
import type { FunctionType } from '../types/FunctionType';
11
import type { StringType } from '../types/StringType';
12
import type { BooleanType } from '../types/BooleanType';
13
import type { IntegerType } from '../types/IntegerType';
14
import type { LongIntegerType } from '../types/LongIntegerType';
15
import type { FloatType } from '../types/FloatType';
16
import type { DoubleType } from '../types/DoubleType';
17
import type { ClassType } from '../types/ClassType';
18
import type { Scope } from '../Scope';
19
import type { XmlScope } from '../XmlScope';
20
import type { DynamicType } from '../types/DynamicType';
21
import type { InterfaceType } from '../types/InterfaceType';
22
import type { ObjectType } from '../types/ObjectType';
23
import type { AstNode, Expression, Statement } from '../parser/AstNode';
24
import type { AssetFile } from '../files/AssetFile';
25
import { AstNodeKind } from '../parser/AstNode';
1✔
26
import type { TypePropertyReferenceType, ReferenceType, BinaryOperatorReferenceType, ArrayDefaultTypeReferenceType, AnyReferenceType, ParamTypeFromValueReferenceType } from '../types/ReferenceType';
27
import type { EnumMemberType, EnumType } from '../types/EnumType';
28
import type { UnionType } from '../types/UnionType';
29
import type { UninitializedType } from '../types/UninitializedType';
30
import type { ArrayType } from '../types/ArrayType';
31
import type { InheritableType } from '../types/InheritableType';
32
import { BscTypeKind } from '../types/BscTypeKind';
1✔
33
import type { NamespaceType } from '../types/NamespaceType';
34
import type { BaseFunctionType } from '../types/BaseFunctionType';
35
import type { BscFile } from '../files/BscFile';
36
import type { ComponentType } from '../types/ComponentType';
37
import type { AssociativeArrayType } from '../types/AssociativeArrayType';
38
import { TokenKind } from '../lexer/TokenKind';
1✔
39
import type { Program } from '../Program';
40
import type { Project } from '../lsp/Project';
41

42
// File reflection
43
export function isBrsFile(file: BscFile | undefined): file is BrsFile {
1✔
44
    return file?.constructor.name === 'BrsFile';
101,120✔
45
}
46

47
export function isXmlFile(file: (BscFile | XmlFile | undefined)): file is XmlFile {
1✔
48
    return file?.constructor.name === 'XmlFile';
21,917✔
49
}
50

51
export function isAssetFile(file: (BscFile | AssetFile | undefined)): file is AssetFile {
1✔
52
    return file?.constructor.name === 'AssetFile';
11!
53
}
54

55
export function isBscFile(file: (BscFile | BscFile | XmlFile | AssetFile | undefined)): file is BscFile {
1✔
NEW
56
    return isBrsFile(file) || isXmlFile(file) || isAssetFile(file);
×
57
}
58

59

60
export function isXmlScope(scope: (Scope | undefined)): scope is XmlScope {
1✔
61
    return scope?.constructor.name === 'XmlScope';
4,650!
62
}
63

64

65
export function isProgram(arg: any): arg is Program {
1✔
NEW
66
    return arg?.constructor.name === 'Program';
×
67
}
68

69
export function isProject(arg: any): arg is Project {
1✔
NEW
70
    return arg?.constructor.name === 'Project';
×
71
}
72

73

74
// Statements reflection
75

76
/**
77
 * Determine if the variablvalue is a descendent of the Statement base class.
78
 * Due to performance restrictions, this expects all statements to
79
 * directly extend Statement or FunctionStatement,
80
 * so it only checks the immediate parent's class name.
81
 */
82
export function isStatement(element: AstNode | undefined): element is Statement {
1✔
83
    // eslint-disable-next-line no-bitwise
84
    return !!(element && element.visitMode & InternalWalkMode.visitStatements);
33,959✔
85
}
86

87
export function isBody(element: AstNode | undefined): element is Body {
1✔
88
    return element?.constructor?.name === 'Body';
7,985!
89
}
90
export function isAssignmentStatement(element: AstNode | undefined): element is AssignmentStatement {
1✔
91
    return element?.kind === AstNodeKind.AssignmentStatement;
17,413✔
92
}
93
export function isBlock(element: AstNode | undefined): element is Block {
1✔
94
    return element?.constructor?.name === 'Block';
4,049!
95
}
96
export function isExpressionStatement(element: AstNode | undefined): element is ExpressionStatement {
1✔
97
    return element?.kind === AstNodeKind.ExpressionStatement;
321!
98
}
99
export function isExitStatement(element: AstNode | undefined): element is ExitStatement {
1✔
100
    return element?.kind === AstNodeKind.ExitStatement;
6!
101
}
102
export function isFunctionStatement(element: AstNode | undefined): element is FunctionStatement {
1✔
103
    return element?.kind === AstNodeKind.FunctionStatement;
29,920✔
104
}
105
export function isIfStatement(element: AstNode | undefined): element is IfStatement {
1✔
106
    return element?.kind === AstNodeKind.IfStatement;
4,336✔
107
}
108
export function isIncrementStatement(element: AstNode | undefined): element is IncrementStatement {
1✔
109
    return element?.kind === AstNodeKind.IncrementStatement;
8!
110
}
111
export function isPrintStatement(element: AstNode | undefined): element is PrintStatement {
1✔
112
    return element?.kind === AstNodeKind.PrintStatement;
116!
113
}
114
export function isGotoStatement(element: AstNode | undefined): element is GotoStatement {
1✔
115
    return element?.kind === AstNodeKind.GotoStatement;
2!
116
}
117
export function isLabelStatement(element: AstNode | undefined): element is LabelStatement {
1✔
118
    return element?.kind === AstNodeKind.LabelStatement;
2!
119
}
120
export function isReturnStatement(element: AstNode | undefined): element is ReturnStatement {
1✔
121
    return element?.kind === AstNodeKind.ReturnStatement;
649!
122
}
123
export function isTernaryExpression(element: AstNode | undefined): element is TernaryExpression {
1✔
124
    return element?.constructor?.name === 'TernaryExpression';
15!
125
}
126
export function isNullCoalescingExpression(element: AstNode | undefined): element is NullCoalescingExpression {
1✔
127
    return element?.constructor?.name === 'NullCoalescingExpression';
10!
128
}
129
export function isEndStatement(element: AstNode | undefined): element is EndStatement {
1✔
130
    return element?.kind === AstNodeKind.EndStatement;
2!
131
}
132
export function isStopStatement(element: AstNode | undefined): element is StopStatement {
1✔
133
    return element?.kind === AstNodeKind.StopStatement;
2!
134
}
135
export function isForStatement(element: AstNode | undefined): element is ForStatement {
1✔
136
    return element?.kind === AstNodeKind.ForStatement;
154✔
137
}
138
export function isForEachStatement(element: AstNode | undefined): element is ForEachStatement {
1✔
139
    return element?.kind === AstNodeKind.ForEachStatement;
265✔
140
}
141
export function isWhileStatement(element: AstNode | undefined): element is WhileStatement {
1✔
142
    return element?.kind === AstNodeKind.WhileStatement;
145✔
143
}
144
export function isDimStatement(element: AstNode | undefined): element is DimStatement {
1✔
145
    return element?.constructor?.name === 'DimStatement';
8!
146
}
147
export function isDottedSetStatement(element: AstNode | undefined): element is DottedSetStatement {
1✔
148
    return element?.kind === AstNodeKind.DottedSetStatement;
293!
149
}
150
export function isIndexedSetStatement(element: AstNode | undefined): element is IndexedSetStatement {
1✔
151
    return element?.kind === AstNodeKind.IndexedSetStatement;
287!
152
}
153
export function isLibraryStatement(element: AstNode | undefined): element is LibraryStatement {
1✔
154
    return element?.kind === AstNodeKind.LibraryStatement;
4,563!
155
}
156
export function isNamespaceStatement(element: AstNode | undefined): element is NamespaceStatement {
1✔
157
    return element?.kind === AstNodeKind.NamespaceStatement;
207,210✔
158
}
159
export function isClassStatement(element: AstNode | undefined): element is ClassStatement {
1✔
160
    return element?.kind === AstNodeKind.ClassStatement;
13,489!
161
}
162
export function isImportStatement(element: AstNode | undefined): element is ImportStatement {
1✔
163
    return element?.kind === AstNodeKind.ImportStatement;
4,949!
164
}
165
export function isMethodStatement(element: AstNode | undefined): element is MethodStatement {
1✔
166
    return element?.kind === AstNodeKind.MethodStatement;
12,477✔
167
}
168
export function isFieldStatement(element: AstNode | undefined): element is FieldStatement {
1✔
169
    return element?.kind === AstNodeKind.FieldStatement;
1,449✔
170
}
171
export function isInterfaceStatement(element: AstNode | undefined): element is InterfaceStatement {
1✔
172
    return element?.kind === AstNodeKind.InterfaceStatement;
4,156!
173
}
174
export function isInterfaceMethodStatement(element: AstNode | undefined): element is InterfaceMethodStatement {
1✔
175
    return element?.kind === AstNodeKind.InterfaceMethodStatement;
4,567✔
176
}
177
export function isInterfaceFieldStatement(element: AstNode | undefined): element is InterfaceFieldStatement {
1✔
178
    return element?.kind === AstNodeKind.InterfaceFieldStatement;
309!
179
}
180
export function isMemberField(element: AstNode | undefined): element is InterfaceFieldStatement | FieldStatement {
1✔
181
    return isFieldStatement(element) || isInterfaceFieldStatement(element);
59✔
182
}
183
export function isMemberMethod(element: AstNode | undefined): element is InterfaceMethodStatement | MethodStatement {
1✔
NEW
184
    return isMethodStatement(element) || isInterfaceMethodStatement(element);
×
185
}
186

187
export function isEnumStatement(element: AstNode | undefined): element is EnumStatement {
1✔
188
    return element?.kind === AstNodeKind.EnumStatement;
739!
189
}
190
export function isEnumMemberStatement(element: AstNode | undefined): element is EnumMemberStatement {
1✔
191
    return element?.kind === AstNodeKind.EnumMemberStatement;
818!
192
}
193
export function isConstStatement(element: AstNode | undefined): element is ConstStatement {
1✔
194
    return element?.kind === AstNodeKind.ConstStatement;
6,107✔
195
}
196
export function isContinueStatement(element: AstNode | undefined): element is ContinueStatement {
1✔
197
    return element?.kind === AstNodeKind.ContinueStatement;
27!
198
}
199
export function isTryCatchStatement(element: AstNode | undefined): element is TryCatchStatement {
1✔
200
    return element?.kind === AstNodeKind.TryCatchStatement;
126✔
201
}
202
export function isCatchStatement(element: AstNode | undefined): element is CatchStatement {
1✔
203
    return element?.kind === AstNodeKind.CatchStatement;
124✔
204
}
205
export function isThrowStatement(element: AstNode | undefined): element is ThrowStatement {
1✔
206
    return element?.kind === AstNodeKind.ThrowStatement;
6!
207
}
208
export function isConditionalCompileStatement(element: AstNode | undefined): element is ConditionalCompileStatement {
1✔
209
    return element?.kind === AstNodeKind.ConditionalCompileStatement;
4,232✔
210
}
211
export function isConditionalCompileConstStatement(element: AstNode | undefined): element is ConditionalCompileConstStatement {
1✔
212
    return element?.kind === AstNodeKind.ConditionalCompileConstStatement;
48!
213
}
214
export function isConditionalCompileErrorStatement(element: AstNode | undefined): element is ConditionalCompileErrorStatement {
1✔
215
    return element?.kind === AstNodeKind.ConditionalCompileErrorStatement;
44!
216
}
217
export function isAugmentedAssignmentStatement(element: AstNode | undefined): element is AugmentedAssignmentStatement {
1✔
218
    return element?.kind === AstNodeKind.AugmentedAssignmentStatement;
29!
219
}
220
export function isTypecastStatement(element: AstNode | undefined): element is TypecastStatement {
1✔
221
    return element?.constructor?.name === 'TypecastStatement';
7,500✔
222
}
223
export function isAliasStatement(element: AstNode | undefined): element is AliasStatement {
1✔
224
    return element?.constructor?.name === 'AliasStatement';
92,267✔
225
}
226

227
// Expressions reflection
228
/**
229
 * Determine if the variablvalue is a descendent of the Expression base class.
230
 * Due to performance restrictions, this expects all statements to directly extend Expression,
231
 * so it only checks the immediate parent's class name. For example:
232
 * this will work for StringLiteralExpression -> Expression,
233
 * but will not work CustomStringLiteralExpression -> StringLiteralExpression -> Expression
234
 */
235
export function isExpression(element: AstNode | undefined): element is Expression {
1✔
236
    // eslint-disable-next-line no-bitwise
237
    return !!(element && element.visitMode & InternalWalkMode.visitExpressions);
223✔
238
}
239

240
export function isBinaryExpression(element: AstNode | undefined): element is BinaryExpression {
1✔
241
    return element?.kind === AstNodeKind.BinaryExpression;
29,965!
242
}
243
export function isCallExpression(element: AstNode | undefined): element is CallExpression {
1✔
244
    return element?.kind === AstNodeKind.CallExpression;
48,499!
245
}
246
export function isFunctionExpression(element: AstNode | undefined): element is FunctionExpression {
1✔
247
    return element?.kind === AstNodeKind.FunctionExpression;
74,124✔
248
}
249
export function isDottedGetExpression(element: AstNode | undefined): element is DottedGetExpression {
1✔
250
    return element?.kind === AstNodeKind.DottedGetExpression;
56,905!
251
}
252
export function isXmlAttributeGetExpression(element: AstNode | undefined): element is XmlAttributeGetExpression {
1✔
253
    return element?.kind === AstNodeKind.XmlAttributeGetExpression;
12,790!
254
}
255
export function isIndexedGetExpression(element: AstNode | undefined): element is IndexedGetExpression {
1✔
256
    return element?.kind === AstNodeKind.IndexedGetExpression;
13,554!
257
}
258
export function isGroupingExpression(element: AstNode | undefined): element is GroupingExpression {
1✔
259
    return element?.kind === AstNodeKind.GroupingExpression;
1,919!
260
}
261
export function isLiteralExpression(element: AstNode | undefined): element is LiteralExpression {
1✔
262
    return element?.kind === AstNodeKind.LiteralExpression;
2,726✔
263
}
264
export function isEscapedCharCodeLiteralExpression(element: AstNode | undefined): element is EscapedCharCodeLiteralExpression {
1✔
265
    return element?.kind === AstNodeKind.EscapedCharCodeLiteralExpression;
19!
266
}
267
export function isArrayLiteralExpression(element: AstNode | undefined): element is ArrayLiteralExpression {
1✔
268
    return element?.kind === AstNodeKind.ArrayLiteralExpression;
23!
269
}
270
export function isAALiteralExpression(element: AstNode | undefined): element is AALiteralExpression {
1✔
271
    return element?.kind === AstNodeKind.AALiteralExpression;
25!
272
}
273
export function isAAMemberExpression(element: AstNode | undefined): element is AAMemberExpression {
1✔
274
    return element?.kind === AstNodeKind.AAMemberExpression;
556!
275
}
276
export function isUnaryExpression(element: AstNode | undefined): element is UnaryExpression {
1✔
277
    return element?.kind === AstNodeKind.UnaryExpression;
11,493✔
278
}
279
export function isVariableExpression(element: AstNode | undefined): element is VariableExpression {
1✔
280
    return element?.kind === AstNodeKind.VariableExpression;
33,494✔
281
}
282
export function isSourceLiteralExpression(element: AstNode | undefined): element is SourceLiteralExpression {
1✔
283
    return element?.kind === AstNodeKind.SourceLiteralExpression;
2!
284
}
285
export function isNewExpression(element: AstNode | undefined): element is NewExpression {
1✔
286
    return element?.kind === AstNodeKind.NewExpression;
17,622!
287
}
288
export function isCallfuncExpression(element: AstNode | undefined): element is CallfuncExpression {
1✔
289
    return element?.kind === AstNodeKind.CallfuncExpression;
21,878!
290
}
291
export function isTemplateStringQuasiExpression(element: AstNode | undefined): element is TemplateStringQuasiExpression {
1✔
292
    return element?.kind === AstNodeKind.TemplateStringQuasiExpression;
14!
293
}
294
export function isTemplateStringExpression(element: AstNode | undefined): element is TemplateStringExpression {
1✔
295
    return element?.kind === AstNodeKind.TemplateStringExpression;
26!
296
}
297
export function isTaggedTemplateStringExpression(element: AstNode | undefined): element is TaggedTemplateStringExpression {
1✔
298
    return element?.kind === AstNodeKind.TaggedTemplateStringExpression;
22!
299
}
300
export function isFunctionParameterExpression(element: AstNode | undefined): element is FunctionParameterExpression {
1✔
301
    return element?.kind === AstNodeKind.FunctionParameterExpression;
2,741✔
302
}
303
export function isAnnotationExpression(element: AstNode | undefined): element is AnnotationExpression {
1✔
304
    return element?.kind === AstNodeKind.AnnotationExpression;
69,379!
305
}
306
export function isTypedefProvider(element: any): element is TypedefProvider {
1✔
307
    return 'getTypedef' in element;
111✔
308
}
309
export function isTypeExpression(element: any): element is TypeExpression {
1✔
310
    return element?.kind === AstNodeKind.TypeExpression;
54,306!
311
}
312
export function isTypecastExpression(element: any): element is TypecastExpression {
1✔
313
    return element?.kind === AstNodeKind.TypecastExpression;
49!
314
}
315
export function isTypedArrayExpression(element: any): element is TypedArrayExpression {
1✔
316
    return element?.kind === AstNodeKind.TypedArrayExpression;
28,037!
317
}
318
export function isPrintSeparatorExpression(element: any): element is PrintSeparatorExpression {
1✔
319
    return element?.kind === AstNodeKind.PrintSeparatorExpression;
72!
320
}
321

322

323
// BscType reflection
324
export function isStringType(value: any): value is StringType {
1✔
325
    return value?.kind === BscTypeKind.StringType;
727,859!
326
}
327
export function isRoStringType(value: any): value is InterfaceType {
1✔
328
    return isBuiltInType(value, 'roString');
2,261✔
329
}
330
export function isStringTypeLike(value: any): value is StringType | InterfaceType {
1✔
331
    return isStringType(value) || isRoStringType(value);
13,365✔
332
}
333

334
export function isTypedFunctionType(value: any): value is TypedFunctionType {
1✔
335
    return value?.kind === BscTypeKind.TypedFunctionType;
751,404✔
336
}
337

338
export function isFunctionType(value: any): value is FunctionType {
1✔
339
    return value?.kind === BscTypeKind.FunctionType;
724,365✔
340
}
341
export function isRoFunctionType(value: any): value is InterfaceType {
1✔
342
    return isBuiltInType(value, 'roFunction');
724,303✔
343
}
344
export function isFunctionTypeLike(value: any): value is FunctionType | InterfaceType {
1✔
345
    return isFunctionType(value) || isRoFunctionType(value);
724,365✔
346
}
347

348
export function isBooleanType(value: any): value is BooleanType {
1✔
349
    return value?.kind === BscTypeKind.BooleanType;
729,478!
350
}
351
export function isRoBooleanType(value: any): value is InterfaceType {
1✔
352
    return isBuiltInType(value, 'roBoolean');
2,626✔
353
}
354
export function isBooleanTypeLike(value: any): value is BooleanType | InterfaceType {
1✔
355
    return isBooleanType(value) || isRoBooleanType(value);
2,871✔
356
}
357

358
export function isIntegerType(value: any): value is IntegerType {
1✔
359
    return value?.kind === BscTypeKind.IntegerType;
725,267!
360
}
361
export function isRoIntType(value: any): value is LongIntegerType {
1✔
362
    return isBuiltInType(value, 'roInt');
4,577✔
363
}
364
export function isIntegerTypeLike(value: any): value is IntegerType | InterfaceType {
1✔
365
    return isIntegerType(value) || isRoIntType(value);
11,183✔
366
}
367

368
export function isLongIntegerType(value: any): value is LongIntegerType {
1✔
369
    return value?.kind === BscTypeKind.LongIntegerType;
719,614!
370
}
371
export function isRoLongIntegerType(value: any): value is InterfaceType {
1✔
372
    return isBuiltInType(value, 'roLongInteger');
5,518✔
373
}
374
export function isLongIntegerTypeLike(value: any): value is LongIntegerType | InterfaceType {
1✔
375
    return isLongIntegerType(value) || isRoLongIntegerType(value);
5,690✔
376
}
377

378
export function isFloatType(value: any): value is FloatType {
1✔
379
    return value?.kind === BscTypeKind.FloatType;
720,576!
380
}
381
export function isRoFloatType(value: any): value is InterfaceType {
1✔
382
    return isBuiltInType(value, 'roFloat');
4,576✔
383
}
384
export function isFloatTypeLike(value: any): value is FloatType | InterfaceType {
1✔
385
    return isFloatType(value) || isRoFloatType(value);
6,634✔
386
}
387

388

389
export function isDoubleType(value: any): value is DoubleType {
1✔
390
    return value?.kind === BscTypeKind.DoubleType;
718,474!
391
}
392
export function isRoDoubleType(value: any): value is InterfaceType {
1✔
393
    return isBuiltInType(value, 'roDouble');
4,454✔
394
}
395
export function isDoubleTypeLike(value: any): value is DoubleType | InterfaceType {
1✔
396
    return isDoubleType(value) || isRoDoubleType(value);
4,544✔
397
}
398

399
export function isInvalidType(value: any): value is InvalidType {
1✔
400
    return value?.kind === BscTypeKind.InvalidType;
722,506✔
401
}
402
export function isRoInvalidType(value: any): value is InterfaceType {
1✔
403
    return isBuiltInType(value, 'roInvalid');
1,402✔
404
}
405
export function isInvalidTypeLike(value: any): value is InvalidType | InterfaceType {
1✔
406
    return isInvalidType(value) || isRoInvalidType(value);
1,464✔
407
}
408

409
export function isVoidType(value: any): value is VoidType {
1✔
410
    return value?.kind === BscTypeKind.VoidType;
247,506✔
411
}
412
export function isClassType(value: any): value is ClassType {
1✔
413
    return value?.kind === BscTypeKind.ClassType;
63,124✔
414
}
415
export function isComponentType(value: any): value is ComponentType {
1✔
416
    return value?.kind === BscTypeKind.ComponentType;
254,030✔
417
}
418
export function isDynamicType(value: any): value is DynamicType {
1✔
419
    return value?.kind === BscTypeKind.DynamicType;
989,708✔
420
}
421
export function isInterfaceType(value: any): value is InterfaceType {
1✔
422
    return value?.kind === BscTypeKind.InterfaceType;
1,495,337✔
423
}
424
export function isObjectType(value: any): value is ObjectType {
1✔
425
    return value?.kind === BscTypeKind.ObjectType;
29,003✔
426
}
427
export function isReferenceType(value: any): value is ReferenceType {
1✔
428
    return value?.__reflection?.name === 'ReferenceType';
535,498✔
429
}
430
export function isEnumType(value: any): value is EnumType {
1✔
431
    return value?.kind === BscTypeKind.EnumType;
5,533✔
432
}
433
export function isEnumMemberType(value: any): value is EnumMemberType {
1✔
434
    return value?.kind === BscTypeKind.EnumMemberType;
718,204!
435
}
436
export function isTypePropertyReferenceType(value: any): value is TypePropertyReferenceType {
1✔
437
    return value?.__reflection?.name === 'TypePropertyReferenceType';
597!
438
}
439
export function isBinaryOperatorReferenceType(value: any): value is BinaryOperatorReferenceType {
1✔
440
    return value?.__reflection?.name === 'BinaryOperatorReferenceType';
6!
441
}
442
export function isArrayDefaultTypeReferenceType(value: any): value is ArrayDefaultTypeReferenceType {
1✔
443
    return value?.__reflection?.name === 'ArrayDefaultTypeReferenceType';
566!
444
}
445
export function isParamTypeFromValueReferenceType(value: any): value is ParamTypeFromValueReferenceType {
1✔
NEW
446
    return value?.__reflection?.name === 'ParamTypeFromValueReferenceType';
×
447
}
448
export function isNamespaceType(value: any): value is NamespaceType {
1✔
449
    return value?.kind === BscTypeKind.NamespaceType;
17,722✔
450
}
451
export function isUnionType(value: any): value is UnionType {
1✔
452
    return value?.kind === BscTypeKind.UnionType;
262,673✔
453
}
454
export function isUninitializedType(value: any): value is UninitializedType {
1✔
455
    return value?.kind === BscTypeKind.UninitializedType;
5,834✔
456
}
457
export function isArrayType(value: any): value is ArrayType {
1✔
458
    return value?.kind === BscTypeKind.ArrayType;
742,460!
459
}
460
export function isAssociativeArrayType(value: any): value is AssociativeArrayType {
1✔
461
    return value?.kind === BscTypeKind.AssociativeArrayType;
714,107✔
462
}
463
export function isInheritableType(target): target is InheritableType {
1✔
464
    return isClassType(target) || isInterfaceType(target) || isComponentType(target);
31,593✔
465
}
466

467
export function isCallableType(target): target is BaseFunctionType {
1✔
468
    return isFunctionTypeLike(target) || isTypedFunctionType(target) || (isDynamicType(target) && !isAnyReferenceType(target));
724,363✔
469
}
470

471
export function isAnyReferenceType(target): target is AnyReferenceType {
1✔
472
    const name = target?.__reflection?.name;
2,201,464✔
473
    return name === 'ReferenceType' || name === 'TypePropertyReferenceType' || name === 'BinaryOperatorReferenceType' || name === 'ArrayDefaultTypeReferenceType' || name === 'ParamTypeFromValueReferenceType';
2,201,464✔
474
}
475

476
export function isNumberType(value: any): value is IntegerType | LongIntegerType | FloatType | DoubleType | InterfaceType {
1✔
477
    return isIntegerTypeLike(value) ||
10,818✔
478
        isLongIntegerTypeLike(value) ||
479
        isFloatTypeLike(value) ||
480
        isDoubleTypeLike(value);
481
}
482

483
export function isPrimitiveType(value: any = false): value is IntegerType | LongIntegerType | FloatType | DoubleType | StringType | BooleanType | InterfaceType {
1✔
484
    return isNumberType(value) ||
1,862✔
485
        isBooleanTypeLike(value) ||
486
        isStringTypeLike(value);
487
}
488

489
export function isBuiltInType(value: any, name: string): value is InterfaceType {
1✔
490
    return isInterfaceType(value) && value.name.toLowerCase() === name.toLowerCase() && value.isBuiltIn;
749,717✔
491
}
492

493
const nativeTypeKinds = [
1✔
494
    BscTypeKind.DynamicType,
495
    BscTypeKind.ObjectType,
496
    BscTypeKind.VoidType,
497
    BscTypeKind.FunctionType
498
];
499
export function isNativeType(value: any): value is IntegerType | LongIntegerType | FloatType | DoubleType | StringType | BooleanType | VoidType | DynamicType | ObjectType | FunctionType | InterfaceType {
1✔
500
    return isPrimitiveType(value) || nativeTypeKinds.includes(value?.kind);
320✔
501
}
502

503

504
// Literal reflection
505

506
export function isLiteralInvalid(value: any): value is LiteralExpression & { type: InvalidType } {
1✔
507
    return isLiteralExpression(value) && value.tokens.value.kind === TokenKind.Invalid;
6✔
508
}
509
export function isLiteralBoolean(value: any): value is LiteralExpression & { type: BooleanType } {
1✔
510
    return isLiteralExpression(value) && isBooleanType(value.getType());
37✔
511
}
512
export function isLiteralString(value: any): value is LiteralExpression & { type: StringType } {
1✔
513
    return isLiteralExpression(value) && isStringType(value.getType());
230✔
514
}
515
export function isLiteralNumber(value: any): value is LiteralExpression & { type: IntegerType | LongIntegerType | FloatType | DoubleType } {
1✔
516
    return isLiteralExpression(value) && isNumberType(value.getType());
32✔
517
}
518
export function isLiteralInteger(value: any): value is LiteralExpression & { type: IntegerType } {
1✔
519
    return isLiteralExpression(value) && isIntegerType(value.getType());
5✔
520
}
521
export function isLiteralLongInteger(value: any): value is LiteralExpression & { type: LongIntegerType } {
1✔
522
    return isLiteralExpression(value) && isLongIntegerType(value.getType());
5✔
523
}
524
export function isLiteralFloat(value: any): value is LiteralExpression & { type: FloatType } {
1✔
525
    return isLiteralExpression(value) && isFloatType(value.getType());
5✔
526
}
527
export function isLiteralDouble(value: any): value is LiteralExpression & { type: DoubleType } {
1✔
528
    return isLiteralExpression(value) && isDoubleType(value.getType());
5✔
529
}
530

531
// Diagnostics
532
export function isBsDiagnostic(value: any): value is BsDiagnostic {
1✔
533
    return value.message;
1,467✔
534
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc