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

rokucommunity / brighterscript / #15220

22 Feb 2026 02:28AM UTC coverage: 87.199% (+0.006%) from 87.193%
#15220

push

web-flow
Merge f055a8d04 into 1556715dd

14750 of 17875 branches covered (82.52%)

Branch coverage included in aggregate %.

107 of 117 new or added lines in 19 files covered. (91.45%)

160 existing lines in 15 files now uncovered.

15494 of 16809 relevant lines covered (92.18%)

25606.57 hits per line

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

88.19
/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, TypeStatement } 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, InlineInterfaceMemberExpression, InlineInterfaceExpression, TypedFunctionTypeExpression } 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, ReferenceTypeWithDefault } 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 type { CallFuncableType } from '../types/CallFuncableType';
33
import { BscTypeKind } from '../types/BscTypeKind';
1✔
34
import type { NamespaceType } from '../types/NamespaceType';
35
import type { BaseFunctionType } from '../types/BaseFunctionType';
36
import type { BscFile } from '../files/BscFile';
37
import type { ComponentType } from '../types/ComponentType';
38
import type { AssociativeArrayType } from '../types/AssociativeArrayType';
39
import { TokenKind } from '../lexer/TokenKind';
1✔
40
import type { Program } from '../Program';
41
import type { Project } from '../lsp/Project';
42
import type { IntersectionType } from '../types/IntersectionType';
43
import type { TypeStatementType } from '../types/TypeStatementType';
44
import type { BscType } from '../types/BscType';
45
import type { SymbolTable } from '../SymbolTable';
46

47

48
// File reflection
49
export function isBrsFile(file: BscFile | undefined): file is BrsFile {
1✔
50
    return file?.constructor.name === 'BrsFile';
109,444✔
51
}
52

53
export function isXmlFile(file: (BscFile | XmlFile | undefined)): file is XmlFile {
1✔
54
    return file?.constructor.name === 'XmlFile';
23,832✔
55
}
56

57
export function isAssetFile(file: (BscFile | AssetFile | undefined)): file is AssetFile {
1✔
58
    return file?.constructor.name === 'AssetFile';
12!
59
}
60

61
export function isBscFile(file: (BscFile | BscFile | XmlFile | AssetFile | undefined)): file is BscFile {
1✔
62
    return isBrsFile(file) || isXmlFile(file) || isAssetFile(file);
×
63
}
64

65

66
export function isXmlScope(scope: (Scope | undefined)): scope is XmlScope {
1✔
67
    return scope?.constructor.name === 'XmlScope';
4,941!
68
}
69

70

71
export function isProgram(arg: any): arg is Program {
1✔
72
    return arg?.constructor.name === 'Program';
×
73
}
74

75
export function isProject(arg: any): arg is Project {
1✔
76
    return arg?.constructor.name === 'Project';
×
77
}
78

79

80
// Statements reflection
81

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

93
export function isBody(element: AstNode | undefined): element is Body {
1✔
94
    return element?.constructor?.name === 'Body';
118,915!
95
}
96
export function isAssignmentStatement(element: AstNode | undefined): element is AssignmentStatement {
1✔
97
    return element?.kind === AstNodeKind.AssignmentStatement;
22,411✔
98
}
99
export function isBlock(element: AstNode | undefined): element is Block {
1✔
100
    return element?.constructor?.name === 'Block';
126,157✔
101
}
102
export function isExpressionStatement(element: AstNode | undefined): element is ExpressionStatement {
1✔
103
    return element?.kind === AstNodeKind.ExpressionStatement;
336!
104
}
105
export function isExitStatement(element: AstNode | undefined): element is ExitStatement {
1✔
106
    return element?.kind === AstNodeKind.ExitStatement;
6!
107
}
108
export function isFunctionStatement(element: AstNode | undefined): element is FunctionStatement {
1✔
109
    return element?.kind === AstNodeKind.FunctionStatement;
35,259✔
110
}
111
export function isIfStatement(element: AstNode | undefined): element is IfStatement {
1✔
112
    return element?.kind === AstNodeKind.IfStatement;
4,679✔
113
}
114
export function isIncrementStatement(element: AstNode | undefined): element is IncrementStatement {
1✔
115
    return element?.kind === AstNodeKind.IncrementStatement;
8!
116
}
117
export function isPrintStatement(element: AstNode | undefined): element is PrintStatement {
1✔
118
    return element?.kind === AstNodeKind.PrintStatement;
429!
119
}
120
export function isGotoStatement(element: AstNode | undefined): element is GotoStatement {
1✔
121
    return element?.kind === AstNodeKind.GotoStatement;
2!
122
}
123
export function isLabelStatement(element: AstNode | undefined): element is LabelStatement {
1✔
124
    return element?.kind === AstNodeKind.LabelStatement;
2!
125
}
126
export function isReturnStatement(element: AstNode | undefined): element is ReturnStatement {
1✔
127
    return element?.kind === AstNodeKind.ReturnStatement;
815!
128
}
129
export function isTernaryExpression(element: AstNode | undefined): element is TernaryExpression {
1✔
130
    return element?.constructor?.name === 'TernaryExpression';
15!
131
}
132
export function isNullCoalescingExpression(element: AstNode | undefined): element is NullCoalescingExpression {
1✔
133
    return element?.constructor?.name === 'NullCoalescingExpression';
10!
134
}
135
export function isEndStatement(element: AstNode | undefined): element is EndStatement {
1✔
136
    return element?.kind === AstNodeKind.EndStatement;
2!
137
}
138
export function isStopStatement(element: AstNode | undefined): element is StopStatement {
1✔
139
    return element?.kind === AstNodeKind.StopStatement;
2!
140
}
141
export function isForStatement(element: AstNode | undefined): element is ForStatement {
1✔
142
    return element?.kind === AstNodeKind.ForStatement;
1,371✔
143
}
144
export function isForEachStatement(element: AstNode | undefined): element is ForEachStatement {
1✔
145
    return element?.kind === AstNodeKind.ForEachStatement;
644✔
146
}
147
export function isWhileStatement(element: AstNode | undefined): element is WhileStatement {
1✔
148
    return element?.kind === AstNodeKind.WhileStatement;
153✔
149
}
150
export function isDimStatement(element: AstNode | undefined): element is DimStatement {
1✔
151
    return element?.constructor?.name === 'DimStatement';
8!
152
}
153
export function isDottedSetStatement(element: AstNode | undefined): element is DottedSetStatement {
1✔
154
    return element?.kind === AstNodeKind.DottedSetStatement;
299!
155
}
156
export function isIndexedSetStatement(element: AstNode | undefined): element is IndexedSetStatement {
1✔
157
    return element?.kind === AstNodeKind.IndexedSetStatement;
293!
158
}
159
export function isLibraryStatement(element: AstNode | undefined): element is LibraryStatement {
1✔
160
    return element?.kind === AstNodeKind.LibraryStatement;
2,790!
161
}
162
export function isNamespaceStatement(element: AstNode | undefined): element is NamespaceStatement {
1✔
163
    return element?.kind === AstNodeKind.NamespaceStatement;
226,017✔
164
}
165
export function isClassStatement(element: AstNode | undefined): element is ClassStatement {
1✔
166
    return element?.kind === AstNodeKind.ClassStatement;
14,654!
167
}
168
export function isImportStatement(element: AstNode | undefined): element is ImportStatement {
1✔
169
    return element?.kind === AstNodeKind.ImportStatement;
3,189!
170
}
171
export function isMethodStatement(element: AstNode | undefined): element is MethodStatement {
1✔
172
    return element?.kind === AstNodeKind.MethodStatement;
13,759✔
173
}
174
export function isFieldStatement(element: AstNode | undefined): element is FieldStatement {
1✔
175
    return element?.kind === AstNodeKind.FieldStatement;
1,530✔
176
}
177
export function isInterfaceStatement(element: AstNode | undefined): element is InterfaceStatement {
1✔
178
    return element?.kind === AstNodeKind.InterfaceStatement;
4,718!
179
}
180
export function isInterfaceMethodStatement(element: AstNode | undefined): element is InterfaceMethodStatement {
1✔
181
    return element?.kind === AstNodeKind.InterfaceMethodStatement;
5,189✔
182
}
183
export function isInterfaceFieldStatement(element: AstNode | undefined): element is InterfaceFieldStatement {
1✔
184
    return element?.kind === AstNodeKind.InterfaceFieldStatement;
383!
185
}
186
export function isMemberField(element: AstNode | undefined): element is InterfaceFieldStatement | FieldStatement {
1✔
187
    return isFieldStatement(element) || isInterfaceFieldStatement(element);
82✔
188
}
189
export function isMemberMethod(element: AstNode | undefined): element is InterfaceMethodStatement | MethodStatement {
1✔
190
    return isMethodStatement(element) || isInterfaceMethodStatement(element);
×
191
}
192

193
export function isEnumStatement(element: AstNode | undefined): element is EnumStatement {
1✔
194
    return element?.kind === AstNodeKind.EnumStatement;
866!
195
}
196
export function isEnumMemberStatement(element: AstNode | undefined): element is EnumMemberStatement {
1✔
197
    return element?.kind === AstNodeKind.EnumMemberStatement;
875!
198
}
199
export function isConstStatement(element: AstNode | undefined): element is ConstStatement {
1✔
200
    return element?.kind === AstNodeKind.ConstStatement;
6,244✔
201
}
202
export function isContinueStatement(element: AstNode | undefined): element is ContinueStatement {
1✔
203
    return element?.kind === AstNodeKind.ContinueStatement;
27!
204
}
205
export function isTryCatchStatement(element: AstNode | undefined): element is TryCatchStatement {
1✔
206
    return element?.kind === AstNodeKind.TryCatchStatement;
139✔
207
}
208
export function isCatchStatement(element: AstNode | undefined): element is CatchStatement {
1✔
209
    return element?.kind === AstNodeKind.CatchStatement;
132✔
210
}
211
export function isThrowStatement(element: AstNode | undefined): element is ThrowStatement {
1✔
212
    return element?.kind === AstNodeKind.ThrowStatement;
6!
213
}
214
export function isConditionalCompileStatement(element: AstNode | undefined): element is ConditionalCompileStatement {
1✔
215
    return element?.kind === AstNodeKind.ConditionalCompileStatement;
5,067✔
216
}
217
export function isConditionalCompileConstStatement(element: AstNode | undefined): element is ConditionalCompileConstStatement {
1✔
218
    return element?.kind === AstNodeKind.ConditionalCompileConstStatement;
87!
219
}
220
export function isConditionalCompileErrorStatement(element: AstNode | undefined): element is ConditionalCompileErrorStatement {
1✔
221
    return element?.kind === AstNodeKind.ConditionalCompileErrorStatement;
83!
222
}
223
export function isAugmentedAssignmentStatement(element: AstNode | undefined): element is AugmentedAssignmentStatement {
1✔
224
    return element?.kind === AstNodeKind.AugmentedAssignmentStatement;
29!
225
}
226
export function isTypecastStatement(element: AstNode | undefined): element is TypecastStatement {
1✔
227
    return element?.constructor?.name === 'TypecastStatement';
6,065✔
228
}
229
export function isAliasStatement(element: AstNode | undefined): element is AliasStatement {
1✔
230
    return element?.constructor?.name === 'AliasStatement';
94,474✔
231
}
232
export function isTypeStatement(element: AstNode | undefined): element is TypeStatement {
1✔
233
    return element?.constructor?.name === 'TypeStatement';
3,860!
234
}
235

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

249
export function isBinaryExpression(element: AstNode | undefined): element is BinaryExpression {
1✔
250
    return element?.kind === AstNodeKind.BinaryExpression;
34,807!
251
}
252
export function isCallExpression(element: AstNode | undefined): element is CallExpression {
1✔
253
    return element?.kind === AstNodeKind.CallExpression;
52,630✔
254
}
255
export function isFunctionExpression(element: AstNode | undefined): element is FunctionExpression {
1✔
256
    return element?.kind === AstNodeKind.FunctionExpression;
83,131✔
257
}
258
export function isDottedGetExpression(element: AstNode | undefined): element is DottedGetExpression {
1✔
259
    return element?.kind === AstNodeKind.DottedGetExpression;
62,527✔
260
}
261
export function isXmlAttributeGetExpression(element: AstNode | undefined): element is XmlAttributeGetExpression {
1✔
262
    return element?.kind === AstNodeKind.XmlAttributeGetExpression;
13,384!
263
}
264
export function isIndexedGetExpression(element: AstNode | undefined): element is IndexedGetExpression {
1✔
265
    return element?.kind === AstNodeKind.IndexedGetExpression;
14,157!
266
}
267
export function isGroupingExpression(element: AstNode | undefined): element is GroupingExpression {
1✔
268
    return element?.kind === AstNodeKind.GroupingExpression;
2,009!
269
}
270
export function isLiteralExpression(element: AstNode | undefined): element is LiteralExpression {
1✔
271
    return element?.kind === AstNodeKind.LiteralExpression;
2,943✔
272
}
273
export function isEscapedCharCodeLiteralExpression(element: AstNode | undefined): element is EscapedCharCodeLiteralExpression {
1✔
274
    return element?.kind === AstNodeKind.EscapedCharCodeLiteralExpression;
19!
275
}
276
export function isArrayLiteralExpression(element: AstNode | undefined): element is ArrayLiteralExpression {
1✔
277
    return element?.kind === AstNodeKind.ArrayLiteralExpression;
23!
278
}
279
export function isAALiteralExpression(element: AstNode | undefined): element is AALiteralExpression {
1✔
280
    return element?.kind === AstNodeKind.AALiteralExpression;
25!
281
}
282
export function isAAMemberExpression(element: AstNode | undefined): element is AAMemberExpression {
1✔
283
    return element?.kind === AstNodeKind.AAMemberExpression;
724!
284
}
285
export function isUnaryExpression(element: AstNode | undefined): element is UnaryExpression {
1✔
286
    return element?.kind === AstNodeKind.UnaryExpression;
12,036✔
287
}
288
export function isVariableExpression(element: AstNode | undefined): element is VariableExpression {
1✔
289
    return element?.kind === AstNodeKind.VariableExpression;
37,260✔
290
}
291
export function isSourceLiteralExpression(element: AstNode | undefined): element is SourceLiteralExpression {
1✔
292
    return element?.kind === AstNodeKind.SourceLiteralExpression;
2!
293
}
294
export function isNewExpression(element: AstNode | undefined): element is NewExpression {
1✔
295
    return element?.kind === AstNodeKind.NewExpression;
20,050!
296
}
297
export function isCallfuncExpression(element: AstNode | undefined): element is CallfuncExpression {
1✔
298
    return element?.kind === AstNodeKind.CallfuncExpression;
22,903!
299
}
300
export function isTemplateStringQuasiExpression(element: AstNode | undefined): element is TemplateStringQuasiExpression {
1✔
301
    return element?.kind === AstNodeKind.TemplateStringQuasiExpression;
14!
302
}
303
export function isTemplateStringExpression(element: AstNode | undefined): element is TemplateStringExpression {
1✔
304
    return element?.kind === AstNodeKind.TemplateStringExpression;
26!
305
}
306
export function isTaggedTemplateStringExpression(element: AstNode | undefined): element is TaggedTemplateStringExpression {
1✔
307
    return element?.kind === AstNodeKind.TaggedTemplateStringExpression;
22!
308
}
309
export function isFunctionParameterExpression(element: AstNode | undefined): element is FunctionParameterExpression {
1✔
310
    return element?.kind === AstNodeKind.FunctionParameterExpression;
33,958✔
311
}
312
export function isAnnotationExpression(element: AstNode | undefined): element is AnnotationExpression {
1✔
313
    return element?.kind === AstNodeKind.AnnotationExpression;
70,214!
314
}
315
export function isTypedefProvider(element: any): element is TypedefProvider {
1✔
316
    return 'getTypedef' in element;
118✔
317
}
318
export function isTypeExpression(element: any): element is TypeExpression {
1✔
319
    return element?.kind === AstNodeKind.TypeExpression;
63,549!
320
}
321
export function isTypecastExpression(element: any): element is TypecastExpression {
1✔
322
    return element?.kind === AstNodeKind.TypecastExpression;
55!
323
}
324
export function isTypedArrayExpression(element: any): element is TypedArrayExpression {
1✔
325
    return element?.kind === AstNodeKind.TypedArrayExpression;
32,649!
326
}
327
export function isPrintSeparatorExpression(element: any): element is PrintSeparatorExpression {
1✔
328
    return element?.kind === AstNodeKind.PrintSeparatorExpression;
72!
329
}
330
export function isInlineInterfaceExpression(element: any): element is InlineInterfaceExpression {
1✔
331
    return element?.kind === AstNodeKind.InlineInterfaceExpression;
4!
332
}
333
export function isInlineInterfaceMemberExpression(element: any): element is InlineInterfaceMemberExpression {
1✔
334
    return element?.kind === AstNodeKind.InlineInterfaceMemberExpression;
×
335
}
336
export function isTypedFunctionTypeExpression(element: any): element is TypedFunctionTypeExpression {
1✔
337
    return element?.kind === AstNodeKind.TypedFunctionTypeExpression;
1,329!
338
}
339

340
// BscType reflection
341
export function isStringType(value: any): value is StringType {
1✔
342
    return value?.kind === BscTypeKind.StringType;
812,273!
343
}
344
export function isRoStringType(value: any): value is InterfaceType {
1✔
345
    return isBuiltInType(value, 'roString');
2,022✔
346
}
347
export function isStringTypeLike(value: any): value is StringType | InterfaceType {
1✔
348
    return isStringType(value) || isRoStringType(value) || isCompoundTypeOf(value, isStringTypeLike);
3,497✔
349
}
350

351
export function isTypedFunctionType(value: any): value is TypedFunctionType {
1✔
352
    return value?.kind === BscTypeKind.TypedFunctionType;
823,486✔
353
}
354

355
export function isTypedFunctionTypeLike(value: any): value is TypedFunctionType | TypeStatementType | UnionType {
1✔
356
    return isTypedFunctionType(value) || isTypeStatementTypeOf(value, isTypedFunctionTypeLike) || isUnionTypeOf(value, isTypedFunctionTypeLike);
813,623✔
357
}
358

359
export function isFunctionType(value: any): value is FunctionType {
1✔
360
    return value?.kind === BscTypeKind.FunctionType;
818,070✔
361
}
362
export function isRoFunctionType(value: any): value is InterfaceType {
1✔
363
    return value?.kind === BscTypeKind.RoFunctionType || isBuiltInType(value, 'roFunction');
818,003✔
364
}
365
export function isFunctionTypeLike(value: any): value is FunctionType | InterfaceType {
1✔
366
    return isFunctionType(value) || isRoFunctionType(value) || isCompoundTypeOf(value, isFunctionTypeLike);
818,070✔
367
}
368

369
export function isBooleanType(value: any): value is BooleanType {
1✔
370
    return value?.kind === BscTypeKind.BooleanType;
810,790!
371
}
372
export function isRoBooleanType(value: any): value is InterfaceType {
1✔
373
    return isBuiltInType(value, 'roBoolean');
2,097✔
374
}
375
export function isBooleanTypeLike(value: any): value is BooleanType | InterfaceType {
1✔
376
    return isBooleanType(value) || isRoBooleanType(value) || isCompoundTypeOf(value, isBooleanTypeLike);
2,404✔
377
}
378

379
export function isIntegerType(value: any): value is IntegerType {
1✔
380
    return value?.kind === BscTypeKind.IntegerType;
815,079!
381
}
382
export function isRoIntType(value: any): value is LongIntegerType {
1✔
383
    return isBuiltInType(value, 'roInt');
3,300✔
384
}
385
export function isIntegerTypeLike(value: any): value is IntegerType | InterfaceType {
1✔
386
    return isIntegerType(value) || isRoIntType(value) || isCompoundTypeOf(value, isIntegerTypeLike);
5,794✔
387
}
388

389
export function isLongIntegerType(value: any): value is LongIntegerType {
1✔
390
    return value?.kind === BscTypeKind.LongIntegerType;
813,086!
391
}
392
export function isRoLongIntegerType(value: any): value is InterfaceType {
1✔
393
    return isBuiltInType(value, 'roLongInteger');
4,423✔
394
}
395
export function isLongIntegerTypeLike(value: any): value is LongIntegerType | InterfaceType {
1✔
396
    return isLongIntegerType(value) || isRoLongIntegerType(value) || isCompoundTypeOf(value, isLongIntegerTypeLike);
4,607✔
397
}
398

399
export function isFloatType(value: any): value is FloatType {
1✔
400
    return value?.kind === BscTypeKind.FloatType;
813,088!
401
}
402
export function isRoFloatType(value: any): value is InterfaceType {
1✔
403
    return isBuiltInType(value, 'roFloat');
4,114✔
404
}
405
export function isFloatTypeLike(value: any): value is FloatType | InterfaceType {
1✔
406
    return isFloatType(value) || isRoFloatType(value) || isCompoundTypeOf(value, isFloatTypeLike);
4,665✔
407
}
408

409
export function isDoubleType(value: any): value is DoubleType {
1✔
410
    return value?.kind === BscTypeKind.DoubleType;
812,412!
411
}
412
export function isRoDoubleType(value: any): value is InterfaceType {
1✔
413
    return isBuiltInType(value, 'roDouble');
4,020✔
414
}
415
export function isDoubleTypeLike(value: any): value is DoubleType | InterfaceType {
1✔
416
    return isDoubleType(value) || isRoDoubleType(value) || isCompoundTypeOf(value, isDoubleTypeLike);
4,085✔
417
}
418

419
export function isInvalidType(value: any): value is InvalidType {
1✔
420
    return value?.kind === BscTypeKind.InvalidType;
817,184✔
421
}
422
export function isRoInvalidType(value: any): value is InterfaceType {
1✔
423
    return isBuiltInType(value, 'roInvalid');
1,602✔
424
}
425
export function isInvalidTypeLike(value: any): value is InvalidType | InterfaceType {
1✔
426
    return isInvalidType(value) || isRoInvalidType(value) || isCompoundTypeOf(value, isInvalidTypeLike);
1,670✔
427
}
428

429
export function isVoidType(value: any): value is VoidType {
1✔
430
    return value?.kind === BscTypeKind.VoidType;
274,029✔
431
}
432
export function isClassType(value: any): value is ClassType {
1✔
433
    return value?.kind === BscTypeKind.ClassType;
39,519✔
434
}
435
export function isComponentType(value: any): value is ComponentType {
1✔
436
    return value?.kind === BscTypeKind.ComponentType;
255,395✔
437
}
438
export function isDynamicType(value: any): value is DynamicType {
1✔
439
    return value?.kind === BscTypeKind.DynamicType;
1,082,653✔
440
}
441
export function isInterfaceType(value: any): value is InterfaceType {
1✔
442
    return value?.kind === BscTypeKind.InterfaceType;
1,644,380✔
443
}
444
export function isObjectType(value: any): value is ObjectType {
1✔
445
    return value?.kind === BscTypeKind.ObjectType;
812,889✔
446
}
447
export function isReferenceType(value: any): value is ReferenceType {
1✔
448
    return value?.__reflection?.name === 'ReferenceType';
539,595✔
449
}
450
export function isEnumType(value: any): value is EnumType {
1✔
451
    return value?.kind === BscTypeKind.EnumType;
6,299✔
452
}
453
export function isEnumMemberType(value: any): value is EnumMemberType {
1✔
454
    return value?.kind === BscTypeKind.EnumMemberType;
807,208!
455
}
456
export function isTypePropertyReferenceType(value: any): value is TypePropertyReferenceType {
1✔
457
    return value?.__reflection?.name === 'TypePropertyReferenceType';
1,754!
458
}
459
export function isBinaryOperatorReferenceType(value: any): value is BinaryOperatorReferenceType {
1✔
460
    return value?.__reflection?.name === 'BinaryOperatorReferenceType';
6!
461
}
462
export function isArrayDefaultTypeReferenceType(value: any): value is ArrayDefaultTypeReferenceType {
1✔
463
    return value?.__reflection?.name === 'ArrayDefaultTypeReferenceType';
1,727!
464
}
465
export function isParamTypeFromValueReferenceType(value: any): value is ParamTypeFromValueReferenceType {
1✔
UNCOV
466
    return value?.__reflection?.name === 'ParamTypeFromValueReferenceType';
×
467
}
468
export function isReferenceTypeWithDefault(value: any): value is ReferenceTypeWithDefault {
1✔
UNCOV
469
    return value?.__reflection?.name === 'ReferenceTypeWithDefault';
×
470
}
471
export function isNamespaceType(value: any): value is NamespaceType {
1✔
472
    return value?.kind === BscTypeKind.NamespaceType;
18,225✔
473
}
474
export function isUnionType(value: any): value is UnionType {
1✔
475
    return value?.kind === BscTypeKind.UnionType;
3,034,836✔
476
}
477
export function isIntersectionType(value: any): value is IntersectionType {
1✔
478
    return value?.kind === BscTypeKind.IntersectionType;
1,145,989✔
479
}
480
export function isUninitializedType(value: any): value is UninitializedType {
1✔
481
    return value?.kind === BscTypeKind.UninitializedType;
2,401✔
482
}
483
export function isArrayType(value: any): value is ArrayType {
1✔
484
    return value?.kind === BscTypeKind.ArrayType;
809,999✔
485
}
486
export function isAssociativeArrayType(value: any): value is AssociativeArrayType {
1✔
487
    return value?.kind === BscTypeKind.AssociativeArrayType;
802,414✔
488
}
489
export function isTypeStatementType(value: any): value is TypeStatementType {
1✔
490
    return value?.kind === BscTypeKind.TypeStatementType;
3,304,734✔
491
}
492

493
export function isInheritableType(target): target is InheritableType {
1✔
494
    return isClassType(target) || isInterfaceType(target) || isComponentType(target);
4,994✔
495
}
496

497
export function isCallFuncableType(target): target is CallFuncableType {
1✔
498
    return isInterfaceType(target) || isComponentType(target) || isCompoundTypeOf(target, isCallFuncableType);
199✔
499
}
500

501
export function isCallableType(target): target is BaseFunctionType {
1✔
502
    return isFunctionTypeLike(target) ||
817,963✔
503
        isTypedFunctionTypeLike(target) ||
504
        isTypeStatementTypeOf(target, isCallableType) ||
505
        isUnionTypeOf(target, isCallableType) ||
506
        isObjectType(target) ||
507
        (isDynamicType(target) && !isAnyReferenceType(target));
508
}
509

510
export function isAnyReferenceType(target): target is AnyReferenceType {
1✔
511
    const name = target?.__reflection?.name;
2,470,579✔
512
    return name === 'ReferenceType' || name === 'TypePropertyReferenceType' || name === 'BinaryOperatorReferenceType' || name === 'ArrayDefaultTypeReferenceType' || name === 'ParamTypeFromValueReferenceType' || name === 'ReferenceTypeWithDefault';
2,470,579✔
513
}
514

515
export function isNumberType(value: any): value is IntegerType | LongIntegerType | FloatType | DoubleType | InterfaceType {
1✔
516
    return isIntegerType(value) ||
2,104✔
517
        isLongIntegerType(value) ||
518
        isFloatType(value) ||
519
        isDoubleType(value);
520
}
521

522
export function isNumberTypeLike(value: any): value is IntegerType | LongIntegerType | FloatType | DoubleType | InterfaceType {
1✔
523
    return isIntegerTypeLike(value) ||
5,010✔
524
        isLongIntegerTypeLike(value) ||
525
        isFloatTypeLike(value) ||
526
        isDoubleTypeLike(value) ||
527
        isCompoundTypeOf(value, isNumberTypeLike);
528
}
529

530
export function isPrimitiveType(value: any = false): value is IntegerType | LongIntegerType | FloatType | DoubleType | StringType | BooleanType | InterfaceType {
1✔
531
    return isNumberType(value) ||
2,083✔
532
        isBooleanType(value) ||
533
        isStringType(value);
534
}
535

536
export function isPrimitiveTypeLike(value: any = false): value is IntegerType | LongIntegerType | FloatType | DoubleType | StringType | BooleanType | InterfaceType {
1!
UNCOV
537
    return isNumberTypeLike(value) ||
×
538
        isBooleanTypeLike(value) ||
539
        isStringTypeLike(value) ||
540
        isTypeStatementTypeOf(value, isPrimitiveTypeLike);
541
}
542

543
export function isAssociativeArrayTypeLike(value: any): value is AssociativeArrayType | InterfaceType {
1✔
544
    return value?.kind === BscTypeKind.AssociativeArrayType || isBuiltInType(value, 'roAssociativeArray') || isCompoundTypeOf(value, isAssociativeArrayTypeLike);
776!
545
}
546

547
export function isArrayTypeLike(value: any): value is ArrayType | InterfaceType {
1✔
548
    return value?.kind === BscTypeKind.ArrayType || isBuiltInType(value, 'roArray') || isCompoundTypeOf(value, isArrayTypeLike);
26!
549
}
550

551
export function isCallFuncableTypeLike(target): target is BscType & { callFuncMemberTable: SymbolTable } {
1✔
552
    return isCallFuncableType(target) || isCompoundTypeOf(target, isCallFuncableTypeLike);
147✔
553
}
554

555
export function isBuiltInType(value: any, name: string): value is InterfaceType {
1✔
556
    return (isInterfaceType(value) && value.name.toLowerCase() === name.toLowerCase() && value.isBuiltIn) ||
836,667✔
557
        (isTypeStatementType(value) && isBuiltInType(value.wrappedType, name));
558
}
559

560
const nativeTypeKinds = [
1✔
561
    BscTypeKind.DynamicType,
562
    BscTypeKind.ObjectType,
563
    BscTypeKind.VoidType,
564
    BscTypeKind.FunctionType
565
];
566
export function isNativeType(value: any): value is IntegerType | LongIntegerType | FloatType | DoubleType | StringType | BooleanType | VoidType | DynamicType | ObjectType | FunctionType | InterfaceType {
1✔
567
    return isPrimitiveType(value) || nativeTypeKinds.includes(value?.kind);
324✔
568
}
569

570
export function isTypeStatementTypeOf(value: any, typeGuard: (val: any) => boolean) {
1✔
571
    return isTypeStatementType(value) && typeGuard(value.wrappedType);
2,454,322✔
572
}
573

574
export function isUnionTypeOf(value: any, typeGuard: (val: any) => boolean) {
1✔
575
    return isUnionType(value) && value.types.every(typeGuard);
2,454,420✔
576
}
577
export function isIntersectionTypeOf(value: any, typeGuard: (val: any) => boolean) {
1✔
578
    return isIntersectionType(value) && value.types.some(typeGuard);
838,148✔
579
}
580

581
export function isCompoundTypeOf(value: any, typeGuard: (val: any) => boolean) {
1✔
582
    return isTypeStatementTypeOf(value, typeGuard) ||
838,209✔
583
        isUnionTypeOf(value, typeGuard) ||
584
        isIntersectionTypeOf(value, typeGuard);
585
}
586

587
export function isCompoundType(value: any): value is UnionType | IntersectionType {
1✔
588
    return isUnionType(value) || isIntersectionType(value);
4,544✔
589
}
590

591
export function isIterableType(value: any): boolean {
1✔
592
    if (isDynamicType(value) || isObjectType(value)) {
19!
UNCOV
593
        return true;
×
594
    }
595
    if (isArrayTypeLike(value) || isAssociativeArrayTypeLike(value)) {
19✔
596
        return true;
9✔
597
    }
598
    if (isCompoundTypeOf(value, isIterableType)) {
10✔
599
        return true;
1✔
600
    }
601
    if (isBuiltInType(value, 'roByteArray') || isBuiltInType(value, 'roList') || isBuiltInType(value, 'roXMLList') || isBuiltInType(value, 'roMessagePort')) {
9✔
602
        return true;
7✔
603
    }
604
    return false;
2✔
605
}
606

607
// Literal reflection
608

609
export function isLiteralInvalid(value: any): value is LiteralExpression & { type: InvalidType } {
1✔
610
    return isLiteralExpression(value) && value.tokens.value.kind === TokenKind.Invalid;
6✔
611
}
612
export function isLiteralBoolean(value: any): value is LiteralExpression & { type: BooleanType } {
1✔
613
    return isLiteralExpression(value) && isBooleanType(value.getType());
37✔
614
}
615
export function isLiteralString(value: any): value is LiteralExpression & { type: StringType } {
1✔
616
    return isLiteralExpression(value) && isStringType(value.getType());
240✔
617
}
618
export function isLiteralNumber(value: any): value is LiteralExpression & { type: IntegerType | LongIntegerType | FloatType | DoubleType } {
1✔
619
    return isLiteralExpression(value) && isNumberType(value.getType());
32✔
620
}
621
export function isLiteralInteger(value: any): value is LiteralExpression & { type: IntegerType } {
1✔
622
    return isLiteralExpression(value) && isIntegerType(value.getType());
5✔
623
}
624
export function isLiteralLongInteger(value: any): value is LiteralExpression & { type: LongIntegerType } {
1✔
625
    return isLiteralExpression(value) && isLongIntegerType(value.getType());
5✔
626
}
627
export function isLiteralFloat(value: any): value is LiteralExpression & { type: FloatType } {
1✔
628
    return isLiteralExpression(value) && isFloatType(value.getType());
5✔
629
}
630
export function isLiteralDouble(value: any): value is LiteralExpression & { type: DoubleType } {
1✔
631
    return isLiteralExpression(value) && isDoubleType(value.getType());
5✔
632
}
633

634
// Diagnostics
635
export function isBsDiagnostic(value: any): value is BsDiagnostic {
1✔
636
    return value.message;
1,539✔
637
}
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