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

rokucommunity / brighterscript / #15092

13 Jan 2026 11:32PM UTC coverage: 87.154% (-0.006%) from 87.16%
#15092

push

web-flow
Merge 5e648aa9b into 3a7dcf6e8

14582 of 17684 branches covered (82.46%)

Branch coverage included in aggregate %.

288 of 337 new or added lines in 16 files covered. (85.46%)

207 existing lines in 10 files now uncovered.

15339 of 16647 relevant lines covered (92.14%)

24482.33 hits per line

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

88.02
/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 } 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, IntersectionWithDefaultDynamicReferenceType } 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';
107,182✔
51
}
52

53
export function isXmlFile(file: (BscFile | XmlFile | undefined)): file is XmlFile {
1✔
54
    return file?.constructor.name === 'XmlFile';
23,313✔
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✔
UNCOV
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,791!
68
}
69

70

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

75
export function isProject(arg: any): arg is Project {
1✔
UNCOV
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);
37,516✔
91
}
92

93
export function isBody(element: AstNode | undefined): element is Body {
1✔
94
    return element?.constructor?.name === 'Body';
115,483!
95
}
96
export function isAssignmentStatement(element: AstNode | undefined): element is AssignmentStatement {
1✔
97
    return element?.kind === AstNodeKind.AssignmentStatement;
20,631✔
98
}
99
export function isBlock(element: AstNode | undefined): element is Block {
1✔
100
    return element?.constructor?.name === 'Block';
122,934✔
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;
32,834✔
110
}
111
export function isIfStatement(element: AstNode | undefined): element is IfStatement {
1✔
112
    return element?.kind === AstNodeKind.IfStatement;
4,674✔
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;
394!
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;
776!
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;
163✔
143
}
144
export function isForEachStatement(element: AstNode | undefined): element is ForEachStatement {
1✔
145
    return element?.kind === AstNodeKind.ForEachStatement;
272✔
146
}
147
export function isWhileStatement(element: AstNode | undefined): element is WhileStatement {
1✔
148
    return element?.kind === AstNodeKind.WhileStatement;
151✔
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;
297!
155
}
156
export function isIndexedSetStatement(element: AstNode | undefined): element is IndexedSetStatement {
1✔
157
    return element?.kind === AstNodeKind.IndexedSetStatement;
291!
158
}
159
export function isLibraryStatement(element: AstNode | undefined): element is LibraryStatement {
1✔
160
    return element?.kind === AstNodeKind.LibraryStatement;
4,921!
161
}
162
export function isNamespaceStatement(element: AstNode | undefined): element is NamespaceStatement {
1✔
163
    return element?.kind === AstNodeKind.NamespaceStatement;
221,893✔
164
}
165
export function isClassStatement(element: AstNode | undefined): element is ClassStatement {
1✔
166
    return element?.kind === AstNodeKind.ClassStatement;
14,437!
167
}
168
export function isImportStatement(element: AstNode | undefined): element is ImportStatement {
1✔
169
    return element?.kind === AstNodeKind.ImportStatement;
5,315!
170
}
171
export function isMethodStatement(element: AstNode | undefined): element is MethodStatement {
1✔
172
    return element?.kind === AstNodeKind.MethodStatement;
13,405✔
173
}
174
export function isFieldStatement(element: AstNode | undefined): element is FieldStatement {
1✔
175
    return element?.kind === AstNodeKind.FieldStatement;
1,521✔
176
}
177
export function isInterfaceStatement(element: AstNode | undefined): element is InterfaceStatement {
1✔
178
    return element?.kind === AstNodeKind.InterfaceStatement;
4,601!
179
}
180
export function isInterfaceMethodStatement(element: AstNode | undefined): element is InterfaceMethodStatement {
1✔
181
    return element?.kind === AstNodeKind.InterfaceMethodStatement;
5,010✔
182
}
183
export function isInterfaceFieldStatement(element: AstNode | undefined): element is InterfaceFieldStatement {
1✔
184
    return element?.kind === AstNodeKind.InterfaceFieldStatement;
372!
185
}
186
export function isMemberField(element: AstNode | undefined): element is InterfaceFieldStatement | FieldStatement {
1✔
187
    return isFieldStatement(element) || isInterfaceFieldStatement(element);
73✔
188
}
189
export function isMemberMethod(element: AstNode | undefined): element is InterfaceMethodStatement | MethodStatement {
1✔
UNCOV
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;
844!
195
}
196
export function isEnumMemberStatement(element: AstNode | undefined): element is EnumMemberStatement {
1✔
197
    return element?.kind === AstNodeKind.EnumMemberStatement;
866!
198
}
199
export function isConstStatement(element: AstNode | undefined): element is ConstStatement {
1✔
200
    return element?.kind === AstNodeKind.ConstStatement;
6,210✔
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;
137✔
207
}
208
export function isCatchStatement(element: AstNode | undefined): element is CatchStatement {
1✔
209
    return element?.kind === AstNodeKind.CatchStatement;
130✔
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;
4,920✔
216
}
217
export function isConditionalCompileConstStatement(element: AstNode | undefined): element is ConditionalCompileConstStatement {
1✔
218
    return element?.kind === AstNodeKind.ConditionalCompileConstStatement;
71!
219
}
220
export function isConditionalCompileErrorStatement(element: AstNode | undefined): element is ConditionalCompileErrorStatement {
1✔
221
    return element?.kind === AstNodeKind.ConditionalCompileErrorStatement;
67!
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';
8,127✔
228
}
229
export function isAliasStatement(element: AstNode | undefined): element is AliasStatement {
1✔
230
    return element?.constructor?.name === 'AliasStatement';
96,390✔
231
}
232
export function isTypeStatement(element: AstNode | undefined): element is TypeStatement {
1✔
233
    return element?.constructor?.name === 'TypeStatement';
3,749!
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,091!
251
}
252
export function isCallExpression(element: AstNode | undefined): element is CallExpression {
1✔
253
    return element?.kind === AstNodeKind.CallExpression;
51,831✔
254
}
255
export function isFunctionExpression(element: AstNode | undefined): element is FunctionExpression {
1✔
256
    return element?.kind === AstNodeKind.FunctionExpression;
81,894✔
257
}
258
export function isDottedGetExpression(element: AstNode | undefined): element is DottedGetExpression {
1✔
259
    return element?.kind === AstNodeKind.DottedGetExpression;
61,406✔
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,154!
266
}
267
export function isGroupingExpression(element: AstNode | undefined): element is GroupingExpression {
1✔
268
    return element?.kind === AstNodeKind.GroupingExpression;
2,003!
269
}
270
export function isLiteralExpression(element: AstNode | undefined): element is LiteralExpression {
1✔
271
    return element?.kind === AstNodeKind.LiteralExpression;
2,931✔
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;
706!
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;
36,399✔
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;
19,368!
296
}
297
export function isCallfuncExpression(element: AstNode | undefined): element is CallfuncExpression {
1✔
298
    return element?.kind === AstNodeKind.CallfuncExpression;
22,891!
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;
32,783✔
311
}
312
export function isAnnotationExpression(element: AstNode | undefined): element is AnnotationExpression {
1✔
313
    return element?.kind === AstNodeKind.AnnotationExpression;
69,923!
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;
61,548!
320
}
321
export function isTypecastExpression(element: any): element is TypecastExpression {
1✔
322
    return element?.kind === AstNodeKind.TypecastExpression;
49!
323
}
324
export function isTypedArrayExpression(element: any): element is TypedArrayExpression {
1✔
325
    return element?.kind === AstNodeKind.TypedArrayExpression;
31,754!
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✔
UNCOV
334
    return element?.kind === AstNodeKind.InlineInterfaceMemberExpression;
×
335
}
336

337
// BscType reflection
338
export function isStringType(value: any): value is StringType {
1✔
339
    return value?.kind === BscTypeKind.StringType;
776,492!
340
}
341
export function isRoStringType(value: any): value is InterfaceType {
1✔
342
    return isBuiltInType(value, 'roString');
1,921✔
343
}
344
export function isStringTypeLike(value: any): value is StringType | InterfaceType {
1✔
345
    return isStringType(value) || isRoStringType(value) || isCompoundTypeOf(value, isStringTypeLike);
3,978✔
346
}
347

348
export function isTypedFunctionType(value: any): value is TypedFunctionType {
1✔
349
    return value?.kind === BscTypeKind.TypedFunctionType;
786,691✔
350
}
351

352
export function isFunctionType(value: any): value is FunctionType {
1✔
353
    return value?.kind === BscTypeKind.FunctionType;
781,569✔
354
}
355
export function isRoFunctionType(value: any): value is InterfaceType {
1✔
356
    return value?.kind === BscTypeKind.RoFunctionType || isBuiltInType(value, 'roFunction');
781,502✔
357
}
358
export function isFunctionTypeLike(value: any): value is FunctionType | InterfaceType {
1✔
359
    return isFunctionType(value) || isRoFunctionType(value) || isCompoundTypeOf(value, isFunctionTypeLike);
781,569✔
360
}
361

362
export function isBooleanType(value: any): value is BooleanType {
1✔
363
    return value?.kind === BscTypeKind.BooleanType;
775,232!
364
}
365
export function isRoBooleanType(value: any): value is InterfaceType {
1✔
366
    return isBuiltInType(value, 'roBoolean');
2,023✔
367
}
368
export function isBooleanTypeLike(value: any): value is BooleanType | InterfaceType {
1✔
369
    return isBooleanType(value) || isRoBooleanType(value) || isCompoundTypeOf(value, isBooleanTypeLike);
2,172✔
370
}
371

372
export function isIntegerType(value: any): value is IntegerType {
1✔
373
    return value?.kind === BscTypeKind.IntegerType;
778,765!
374
}
375
export function isRoIntType(value: any): value is LongIntegerType {
1✔
376
    return isBuiltInType(value, 'roInt');
3,154✔
377
}
378
export function isIntegerTypeLike(value: any): value is IntegerType | InterfaceType {
1✔
379
    return isIntegerType(value) || isRoIntType(value) || isCompoundTypeOf(value, isIntegerTypeLike);
5,757✔
380
}
381

382
export function isLongIntegerType(value: any): value is LongIntegerType {
1✔
383
    return value?.kind === BscTypeKind.LongIntegerType;
776,693!
384
}
385
export function isRoLongIntegerType(value: any): value is InterfaceType {
1✔
386
    return isBuiltInType(value, 'roLongInteger');
4,286✔
387
}
388
export function isLongIntegerTypeLike(value: any): value is LongIntegerType | InterfaceType {
1✔
389
    return isLongIntegerType(value) || isRoLongIntegerType(value) || isCompoundTypeOf(value, isLongIntegerTypeLike);
4,476✔
390
}
391

392
export function isFloatType(value: any): value is FloatType {
1✔
393
    return value?.kind === BscTypeKind.FloatType;
776,677!
394
}
395
export function isRoFloatType(value: any): value is InterfaceType {
1✔
396
    return isBuiltInType(value, 'roFloat');
3,971✔
397
}
398
export function isFloatTypeLike(value: any): value is FloatType | InterfaceType {
1✔
399
    return isFloatType(value) || isRoFloatType(value) || isCompoundTypeOf(value, isFloatTypeLike);
4,516✔
400
}
401

402
export function isDoubleType(value: any): value is DoubleType {
1✔
403
    return value?.kind === BscTypeKind.DoubleType;
776,013!
404
}
405
export function isRoDoubleType(value: any): value is InterfaceType {
1✔
406
    return isBuiltInType(value, 'roDouble');
3,883✔
407
}
408
export function isDoubleTypeLike(value: any): value is DoubleType | InterfaceType {
1✔
409
    return isDoubleType(value) || isRoDoubleType(value) || isCompoundTypeOf(value, isDoubleTypeLike);
3,948✔
410
}
411

412
export function isInvalidType(value: any): value is InvalidType {
1✔
413
    return value?.kind === BscTypeKind.InvalidType;
780,376✔
414
}
415
export function isRoInvalidType(value: any): value is InterfaceType {
1✔
416
    return isBuiltInType(value, 'roInvalid');
1,570✔
417
}
418
export function isInvalidTypeLike(value: any): value is InvalidType | InterfaceType {
1✔
419
    return isInvalidType(value) || isRoInvalidType(value) || isCompoundTypeOf(value, isInvalidTypeLike);
1,632✔
420
}
421

422
export function isVoidType(value: any): value is VoidType {
1✔
423
    return value?.kind === BscTypeKind.VoidType;
261,799✔
424
}
425
export function isClassType(value: any): value is ClassType {
1✔
426
    return value?.kind === BscTypeKind.ClassType;
38,299✔
427
}
428
export function isComponentType(value: any): value is ComponentType {
1✔
429
    return value?.kind === BscTypeKind.ComponentType;
247,287✔
430
}
431
export function isDynamicType(value: any): value is DynamicType {
1✔
432
    return value?.kind === BscTypeKind.DynamicType;
1,034,282✔
433
}
434
export function isInterfaceType(value: any): value is InterfaceType {
1✔
435
    return value?.kind === BscTypeKind.InterfaceType;
1,569,404✔
436
}
437
export function isObjectType(value: any): value is ObjectType {
1✔
438
    return value?.kind === BscTypeKind.ObjectType;
776,791✔
439
}
440
export function isReferenceType(value: any): value is ReferenceType {
1✔
441
    return value?.__reflection?.name === 'ReferenceType';
520,612✔
442
}
443
export function isEnumType(value: any): value is EnumType {
1✔
444
    return value?.kind === BscTypeKind.EnumType;
6,078✔
445
}
446
export function isEnumMemberType(value: any): value is EnumMemberType {
1✔
447
    return value?.kind === BscTypeKind.EnumMemberType;
771,005!
448
}
449
export function isTypePropertyReferenceType(value: any): value is TypePropertyReferenceType {
1✔
450
    return value?.__reflection?.name === 'TypePropertyReferenceType';
1,571!
451
}
452
export function isBinaryOperatorReferenceType(value: any): value is BinaryOperatorReferenceType {
1✔
453
    return value?.__reflection?.name === 'BinaryOperatorReferenceType';
6!
454
}
455
export function isArrayDefaultTypeReferenceType(value: any): value is ArrayDefaultTypeReferenceType {
1✔
456
    return value?.__reflection?.name === 'ArrayDefaultTypeReferenceType';
1,544!
457
}
458
export function isParamTypeFromValueReferenceType(value: any): value is ParamTypeFromValueReferenceType {
1✔
UNCOV
459
    return value?.__reflection?.name === 'ParamTypeFromValueReferenceType';
×
460
}
461
export function isIntersectionWithDefaultDynamicReferenceType(value: any): value is IntersectionWithDefaultDynamicReferenceType {
1✔
NEW
462
    return value?.__reflection?.name === 'IntersectionWithDefaultDynamicReferenceType';
×
463
}
464
export function isNamespaceType(value: any): value is NamespaceType {
1✔
465
    return value?.kind === BscTypeKind.NamespaceType;
17,958✔
466
}
467
export function isUnionType(value: any): value is UnionType {
1✔
468
    return value?.kind === BscTypeKind.UnionType;
1,358,121✔
469
}
470
export function isIntersectionType(value: any): value is IntersectionType {
1✔
471
    return value?.kind === BscTypeKind.IntersectionType;
1,098,163✔
472
}
473
export function isUninitializedType(value: any): value is UninitializedType {
1✔
474
    return value?.kind === BscTypeKind.UninitializedType;
2,619✔
475
}
476
export function isArrayType(value: any): value is ArrayType {
1✔
477
    return value?.kind === BscTypeKind.ArrayType;
772,810✔
478
}
479
export function isAssociativeArrayType(value: any): value is AssociativeArrayType {
1✔
480
    return value?.kind === BscTypeKind.AssociativeArrayType;
766,381✔
481
}
482
export function isTypeStatementType(value: any): value is TypeStatementType {
1✔
483
    return value?.kind === BscTypeKind.TypeStatementType;
1,604,284✔
484
}
485

486
export function isInheritableType(target): target is InheritableType {
1✔
487
    return isClassType(target) || isInterfaceType(target) || isComponentType(target);
4,359✔
488
}
489

490
export function isCallFuncableType(target): target is CallFuncableType {
1✔
491
    return isInterfaceType(target) || isComponentType(target) || isCompoundTypeOf(target, isCallFuncableType);
192✔
492
}
493

494
export function isCallableType(target): target is BaseFunctionType {
1✔
495
    return isFunctionTypeLike(target) || isTypedFunctionType(target) || isObjectType(target) || (isDynamicType(target) && !isAnyReferenceType(target));
781,500✔
496
}
497

498
export function isAnyReferenceType(target): target is AnyReferenceType {
1✔
499
    const name = target?.__reflection?.name;
2,372,331✔
500
    return name === 'ReferenceType' || name === 'TypePropertyReferenceType' || name === 'BinaryOperatorReferenceType' || name === 'ArrayDefaultTypeReferenceType' || name === 'ParamTypeFromValueReferenceType' || name === 'IntersectionWithDefaultDynamicReferenceType';
2,372,331✔
501
}
502

503
export function isNumberType(value: any): value is IntegerType | LongIntegerType | FloatType | DoubleType | InterfaceType {
1✔
504
    return isIntegerType(value) ||
2,066✔
505
        isLongIntegerType(value) ||
506
        isFloatType(value) ||
507
        isDoubleType(value);
508
}
509

510
export function isNumberTypeLike(value: any): value is IntegerType | LongIntegerType | FloatType | DoubleType | InterfaceType {
1✔
511
    return isIntegerTypeLike(value) ||
5,094✔
512
        isLongIntegerTypeLike(value) ||
513
        isFloatTypeLike(value) ||
514
        isDoubleTypeLike(value) ||
515
        isCompoundTypeOf(value, isNumberTypeLike);
516
}
517

518
export function isPrimitiveType(value: any = false): value is IntegerType | LongIntegerType | FloatType | DoubleType | StringType | BooleanType | InterfaceType {
1✔
519
    return isNumberType(value) ||
2,045✔
520
        isBooleanType(value) ||
521
        isStringType(value);
522
}
523

524
export function isPrimitiveTypeLike(value: any = false): value is IntegerType | LongIntegerType | FloatType | DoubleType | StringType | BooleanType | InterfaceType {
1!
UNCOV
525
    return isNumberTypeLike(value) ||
×
526
        isBooleanTypeLike(value) ||
527
        isStringTypeLike(value) ||
528
        isTypeStatementTypeOf(value, isPrimitiveTypeLike);
529
}
530

531
export function isAssociativeArrayTypeLike(value: any): value is AssociativeArrayType | InterfaceType {
1✔
532
    return value?.kind === BscTypeKind.AssociativeArrayType || isBuiltInType(value, 'roAssociativeArray') || isCompoundTypeOf(value, isAssociativeArrayTypeLike);
191!
533
}
534

535
export function isCallFuncableTypeLike(target): target is BscType & { callFuncMemberTable: SymbolTable } {
1✔
536
    return isCallFuncableType(target) || isCompoundTypeOf(target, isCallFuncableTypeLike);
141✔
537
}
538

539
export function isBuiltInType(value: any, name: string): value is InterfaceType {
1✔
540
    return (isInterfaceType(value) && value.name.toLowerCase() === name.toLowerCase() && value.isBuiltIn) ||
798,378✔
541
        (isTypeStatementType(value) && isBuiltInType(value.wrappedType, name));
542
}
543

544
const nativeTypeKinds = [
1✔
545
    BscTypeKind.DynamicType,
546
    BscTypeKind.ObjectType,
547
    BscTypeKind.VoidType,
548
    BscTypeKind.FunctionType
549
];
550
export function isNativeType(value: any): value is IntegerType | LongIntegerType | FloatType | DoubleType | StringType | BooleanType | VoidType | DynamicType | ObjectType | FunctionType | InterfaceType {
1✔
551
    return isPrimitiveType(value) || nativeTypeKinds.includes(value?.kind);
324✔
552
}
553

554
export function isTypeStatementTypeOf(value: any, typeGuard: (val: any) => boolean) {
1✔
555
    return isTypeStatementType(value) && typeGuard(value.wrappedType);
800,377✔
556
}
557

558
export function isUnionTypeOf(value: any, typeGuard: (val: any) => boolean) {
1✔
559
    return isUnionType(value) && value.types.every(typeGuard);
800,507✔
560
}
561
export function isIntersectionTypeOf(value: any, typeGuard: (val: any) => boolean) {
1✔
562
    return isIntersectionType(value) && value.types.some(typeGuard);
800,319✔
563
}
564

565
export function isCompoundTypeOf(value: any, typeGuard: (val: any) => boolean) {
1✔
566
    return isTypeStatementTypeOf(value, typeGuard) ||
800,377✔
567
        isUnionTypeOf(value, typeGuard) ||
568
        isIntersectionTypeOf(value, typeGuard);
569
}
570

571
export function isCompoundType(value: any): value is UnionType | IntersectionType {
1✔
572
    return isUnionType(value) || isIntersectionType(value);
3,519✔
573
}
574

575
// Literal reflection
576

577
export function isLiteralInvalid(value: any): value is LiteralExpression & { type: InvalidType } {
1✔
578
    return isLiteralExpression(value) && value.tokens.value.kind === TokenKind.Invalid;
6✔
579
}
580
export function isLiteralBoolean(value: any): value is LiteralExpression & { type: BooleanType } {
1✔
581
    return isLiteralExpression(value) && isBooleanType(value.getType());
37✔
582
}
583
export function isLiteralString(value: any): value is LiteralExpression & { type: StringType } {
1✔
584
    return isLiteralExpression(value) && isStringType(value.getType());
236✔
585
}
586
export function isLiteralNumber(value: any): value is LiteralExpression & { type: IntegerType | LongIntegerType | FloatType | DoubleType } {
1✔
587
    return isLiteralExpression(value) && isNumberType(value.getType());
32✔
588
}
589
export function isLiteralInteger(value: any): value is LiteralExpression & { type: IntegerType } {
1✔
590
    return isLiteralExpression(value) && isIntegerType(value.getType());
5✔
591
}
592
export function isLiteralLongInteger(value: any): value is LiteralExpression & { type: LongIntegerType } {
1✔
593
    return isLiteralExpression(value) && isLongIntegerType(value.getType());
5✔
594
}
595
export function isLiteralFloat(value: any): value is LiteralExpression & { type: FloatType } {
1✔
596
    return isLiteralExpression(value) && isFloatType(value.getType());
5✔
597
}
598
export function isLiteralDouble(value: any): value is LiteralExpression & { type: DoubleType } {
1✔
599
    return isLiteralExpression(value) && isDoubleType(value.getType());
5✔
600
}
601

602
// Diagnostics
603
export function isBsDiagnostic(value: any): value is BsDiagnostic {
1✔
604
    return value.message;
1,515✔
605
}
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