brighterscript 1.0.0-alpha.40 → 1.0.0-alpha.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/CHANGELOG.md +67 -1
  2. package/dist/AstValidationSegmenter.d.ts +3 -0
  3. package/dist/AstValidationSegmenter.js +62 -2
  4. package/dist/AstValidationSegmenter.js.map +1 -1
  5. package/dist/BsConfig.d.ts +7 -7
  6. package/dist/CrossScopeValidator.js +3 -3
  7. package/dist/CrossScopeValidator.js.map +1 -1
  8. package/dist/DiagnosticFilterer.d.ts +5 -1
  9. package/dist/DiagnosticFilterer.js +92 -33
  10. package/dist/DiagnosticFilterer.js.map +1 -1
  11. package/dist/DiagnosticManager.js +12 -9
  12. package/dist/DiagnosticManager.js.map +1 -1
  13. package/dist/DiagnosticMessages.d.ts +374 -225
  14. package/dist/DiagnosticMessages.js +641 -424
  15. package/dist/DiagnosticMessages.js.map +1 -1
  16. package/dist/DiagnosticSeverityAdjuster.js +4 -0
  17. package/dist/DiagnosticSeverityAdjuster.js.map +1 -1
  18. package/dist/LanguageServer.js +0 -7
  19. package/dist/LanguageServer.js.map +1 -1
  20. package/dist/PluginInterface.js +2 -0
  21. package/dist/PluginInterface.js.map +1 -1
  22. package/dist/Program.d.ts +22 -1
  23. package/dist/Program.js +206 -49
  24. package/dist/Program.js.map +1 -1
  25. package/dist/SymbolTable.d.ts +3 -0
  26. package/dist/SymbolTable.js +19 -1
  27. package/dist/SymbolTable.js.map +1 -1
  28. package/dist/XmlScope.js +3 -6
  29. package/dist/XmlScope.js.map +1 -1
  30. package/dist/astUtils/creators.d.ts +35 -3
  31. package/dist/astUtils/creators.js +52 -1
  32. package/dist/astUtils/creators.js.map +1 -1
  33. package/dist/astUtils/reflection.d.ts +4 -2
  34. package/dist/astUtils/reflection.js +12 -3
  35. package/dist/astUtils/reflection.js.map +1 -1
  36. package/dist/astUtils/visitors.d.ts +3 -2
  37. package/dist/astUtils/visitors.js +37 -14
  38. package/dist/astUtils/visitors.js.map +1 -1
  39. package/dist/astUtils/visitors.spec.js +172 -6
  40. package/dist/astUtils/visitors.spec.js.map +1 -1
  41. package/dist/bscPlugin/codeActions/CodeActionsProcessor.d.ts +0 -1
  42. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js +0 -13
  43. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js.map +1 -1
  44. package/dist/bscPlugin/completions/CompletionsProcessor.d.ts +2 -1
  45. package/dist/bscPlugin/completions/CompletionsProcessor.js +5 -5
  46. package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -1
  47. package/dist/bscPlugin/completions/CompletionsProcessor.spec.js +106 -2
  48. package/dist/bscPlugin/completions/CompletionsProcessor.spec.js.map +1 -1
  49. package/dist/bscPlugin/hover/HoverProcessor.spec.js +51 -3
  50. package/dist/bscPlugin/hover/HoverProcessor.spec.js.map +1 -1
  51. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.d.ts +1 -0
  52. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js +149 -0
  53. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js.map +1 -1
  54. package/dist/bscPlugin/validation/BrsFileValidator.js +15 -8
  55. package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
  56. package/dist/bscPlugin/validation/BrsFileValidator.spec.js +80 -9
  57. package/dist/bscPlugin/validation/BrsFileValidator.spec.js.map +1 -1
  58. package/dist/bscPlugin/validation/ScopeValidator.d.ts +9 -0
  59. package/dist/bscPlugin/validation/ScopeValidator.js +155 -79
  60. package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -1
  61. package/dist/bscPlugin/validation/ScopeValidator.spec.js +1269 -35
  62. package/dist/bscPlugin/validation/ScopeValidator.spec.js.map +1 -1
  63. package/dist/bscPlugin/validation/XmlFileValidator.js +0 -8
  64. package/dist/bscPlugin/validation/XmlFileValidator.js.map +1 -1
  65. package/dist/diagnosticUtils.js +6 -5
  66. package/dist/diagnosticUtils.js.map +1 -1
  67. package/dist/files/BrsFile.Class.spec.js +87 -28
  68. package/dist/files/BrsFile.Class.spec.js.map +1 -1
  69. package/dist/files/BrsFile.d.ts +1 -0
  70. package/dist/files/BrsFile.js +20 -8
  71. package/dist/files/BrsFile.js.map +1 -1
  72. package/dist/files/BrsFile.spec.js +133 -34
  73. package/dist/files/BrsFile.spec.js.map +1 -1
  74. package/dist/files/XmlFile.js +2 -2
  75. package/dist/files/XmlFile.js.map +1 -1
  76. package/dist/files/XmlFile.spec.js +3 -20
  77. package/dist/files/XmlFile.spec.js.map +1 -1
  78. package/dist/globalCallables.js +1 -1
  79. package/dist/index.d.ts +8 -3
  80. package/dist/index.js +24 -16
  81. package/dist/index.js.map +1 -1
  82. package/dist/interfaces.d.ts +18 -0
  83. package/dist/interfaces.js.map +1 -1
  84. package/dist/lexer/Lexer.js +17 -11
  85. package/dist/lexer/Lexer.js.map +1 -1
  86. package/dist/lexer/Lexer.spec.js +21 -3
  87. package/dist/lexer/Lexer.spec.js.map +1 -1
  88. package/dist/lexer/TokenKind.d.ts +9 -0
  89. package/dist/lexer/TokenKind.js +11 -1
  90. package/dist/lexer/TokenKind.js.map +1 -1
  91. package/dist/parser/AstNode.d.ts +2 -1
  92. package/dist/parser/AstNode.js +3 -2
  93. package/dist/parser/AstNode.js.map +1 -1
  94. package/dist/parser/Expression.d.ts +22 -2
  95. package/dist/parser/Expression.js +76 -48
  96. package/dist/parser/Expression.js.map +1 -1
  97. package/dist/parser/Parser.Class.spec.js +3 -3
  98. package/dist/parser/Parser.Class.spec.js.map +1 -1
  99. package/dist/parser/Parser.js +73 -61
  100. package/dist/parser/Parser.js.map +1 -1
  101. package/dist/parser/Parser.spec.js +198 -15
  102. package/dist/parser/Parser.spec.js.map +1 -1
  103. package/dist/parser/SGParser.js +9 -9
  104. package/dist/parser/SGParser.js.map +1 -1
  105. package/dist/parser/SGParser.spec.js +3 -2
  106. package/dist/parser/SGParser.spec.js.map +1 -1
  107. package/dist/parser/Statement.d.ts +16 -18
  108. package/dist/parser/Statement.js +136 -82
  109. package/dist/parser/Statement.js.map +1 -1
  110. package/dist/parser/tests/controlFlow/If.spec.js +1 -1
  111. package/dist/parser/tests/controlFlow/If.spec.js.map +1 -1
  112. package/dist/parser/tests/expression/ArrayLiterals.spec.js +3 -3
  113. package/dist/parser/tests/expression/ArrayLiterals.spec.js.map +1 -1
  114. package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js +3 -3
  115. package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js.map +1 -1
  116. package/dist/parser/tests/expression/Call.spec.js +9 -9
  117. package/dist/parser/tests/expression/Call.spec.js.map +1 -1
  118. package/dist/parser/tests/expression/Indexing.spec.js +3 -3
  119. package/dist/parser/tests/expression/Indexing.spec.js.map +1 -1
  120. package/dist/parser/tests/expression/TemplateStringExpression.spec.js +1 -1
  121. package/dist/parser/tests/expression/TemplateStringExpression.spec.js.map +1 -1
  122. package/dist/parser/tests/expression/TernaryExpression.spec.js +353 -71
  123. package/dist/parser/tests/expression/TernaryExpression.spec.js.map +1 -1
  124. package/dist/parser/tests/statement/Dim.spec.js +10 -3
  125. package/dist/parser/tests/statement/Dim.spec.js.map +1 -1
  126. package/dist/parser/tests/statement/Enum.spec.js +2 -2
  127. package/dist/parser/tests/statement/Enum.spec.js.map +1 -1
  128. package/dist/parser/tests/statement/Increment.spec.js +3 -5
  129. package/dist/parser/tests/statement/Increment.spec.js.map +1 -1
  130. package/dist/parser/tests/statement/PrintStatement.spec.js +3 -3
  131. package/dist/parser/tests/statement/TryCatch.spec.js +1 -1
  132. package/dist/parser/tests/statement/TryCatch.spec.js.map +1 -1
  133. package/dist/roku-types/data.json +430 -235
  134. package/dist/roku-types/index.d.ts +30 -37
  135. package/dist/types/ArrayType.d.ts +2 -0
  136. package/dist/types/ArrayType.js +14 -4
  137. package/dist/types/ArrayType.js.map +1 -1
  138. package/dist/types/AssociativeArrayType.d.ts +1 -0
  139. package/dist/types/AssociativeArrayType.js +1 -0
  140. package/dist/types/AssociativeArrayType.js.map +1 -1
  141. package/dist/types/BaseFunctionType.d.ts +1 -0
  142. package/dist/types/BaseFunctionType.js +1 -0
  143. package/dist/types/BaseFunctionType.js.map +1 -1
  144. package/dist/types/BooleanType.d.ts +1 -0
  145. package/dist/types/BooleanType.js +1 -0
  146. package/dist/types/BooleanType.js.map +1 -1
  147. package/dist/types/BscType.d.ts +8 -1
  148. package/dist/types/BscType.js +12 -3
  149. package/dist/types/BscType.js.map +1 -1
  150. package/dist/types/BuiltInInterfaceAdder.js +10 -6
  151. package/dist/types/BuiltInInterfaceAdder.js.map +1 -1
  152. package/dist/types/ClassType.d.ts +1 -0
  153. package/dist/types/ClassType.js +5 -2
  154. package/dist/types/ClassType.js.map +1 -1
  155. package/dist/types/ComponentType.d.ts +11 -4
  156. package/dist/types/ComponentType.js +100 -8
  157. package/dist/types/ComponentType.js.map +1 -1
  158. package/dist/types/DoubleType.d.ts +2 -0
  159. package/dist/types/DoubleType.js +2 -0
  160. package/dist/types/DoubleType.js.map +1 -1
  161. package/dist/types/DynamicType.d.ts +1 -0
  162. package/dist/types/DynamicType.js +4 -0
  163. package/dist/types/DynamicType.js.map +1 -1
  164. package/dist/types/EnumType.d.ts +2 -0
  165. package/dist/types/EnumType.js +20 -2
  166. package/dist/types/EnumType.js.map +1 -1
  167. package/dist/types/FloatType.d.ts +2 -0
  168. package/dist/types/FloatType.js +2 -0
  169. package/dist/types/FloatType.js.map +1 -1
  170. package/dist/types/InheritableType.d.ts +1 -0
  171. package/dist/types/InheritableType.js +14 -1
  172. package/dist/types/InheritableType.js.map +1 -1
  173. package/dist/types/IntegerType.d.ts +2 -0
  174. package/dist/types/IntegerType.js +2 -0
  175. package/dist/types/IntegerType.js.map +1 -1
  176. package/dist/types/InterfaceType.js +4 -1
  177. package/dist/types/InterfaceType.js.map +1 -1
  178. package/dist/types/InvalidType.d.ts +2 -1
  179. package/dist/types/InvalidType.js +1 -0
  180. package/dist/types/InvalidType.js.map +1 -1
  181. package/dist/types/LongIntegerType.d.ts +2 -0
  182. package/dist/types/LongIntegerType.js +2 -0
  183. package/dist/types/LongIntegerType.js.map +1 -1
  184. package/dist/types/ObjectType.d.ts +1 -0
  185. package/dist/types/ObjectType.js +1 -0
  186. package/dist/types/ObjectType.js.map +1 -1
  187. package/dist/types/ReferenceType.d.ts +20 -2
  188. package/dist/types/ReferenceType.js +106 -5
  189. package/dist/types/ReferenceType.js.map +1 -1
  190. package/dist/types/StringType.d.ts +1 -0
  191. package/dist/types/StringType.js +1 -0
  192. package/dist/types/StringType.js.map +1 -1
  193. package/dist/types/TypedFunctionType.d.ts +1 -1
  194. package/dist/types/TypedFunctionType.js +8 -2
  195. package/dist/types/TypedFunctionType.js.map +1 -1
  196. package/dist/types/UninitializedType.d.ts +2 -0
  197. package/dist/types/UninitializedType.js +5 -6
  198. package/dist/types/UninitializedType.js.map +1 -1
  199. package/dist/types/UnionType.js +8 -2
  200. package/dist/types/UnionType.js.map +1 -1
  201. package/dist/types/VoidType.d.ts +4 -1
  202. package/dist/types/VoidType.js +5 -0
  203. package/dist/types/VoidType.js.map +1 -1
  204. package/dist/types/helpers.js +8 -1
  205. package/dist/types/helpers.js.map +1 -1
  206. package/dist/util.d.ts +15 -5
  207. package/dist/util.js +281 -14
  208. package/dist/util.js.map +1 -1
  209. package/dist/validators/ClassValidator.js +13 -5
  210. package/dist/validators/ClassValidator.js.map +1 -1
  211. package/package.json +2 -2
package/dist/util.d.ts CHANGED
@@ -2,7 +2,8 @@ import type { Diagnostic, Position } from 'vscode-languageserver';
2
2
  import { Location } from 'vscode-languageserver';
3
3
  import { Range } from 'vscode-languageserver';
4
4
  import type { BsConfig, FinalizedBsConfig } from './BsConfig';
5
- import type { CallableContainer, BsDiagnostic, FileReference, CallableContainerMap, CompilerPlugin, ExpressionInfo, TranspileResult, TypeChainEntry, TypeChainProcessResult, GetTypeOptions } from './interfaces';
5
+ import type { CallableContainer, BsDiagnostic, FileReference, CallableContainerMap, CompilerPlugin, ExpressionInfo, TranspileResult, TypeChainProcessResult, GetTypeOptions } from './interfaces';
6
+ import { TypeChainEntry } from './interfaces';
6
7
  import { BooleanType } from './types/BooleanType';
7
8
  import { DoubleType } from './types/DoubleType';
8
9
  import { DynamicType } from './types/DynamicType';
@@ -13,19 +14,20 @@ import { ObjectType } from './types/ObjectType';
13
14
  import { StringType } from './types/StringType';
14
15
  import { VoidType } from './types/VoidType';
15
16
  import { ParseMode } from './parser/Parser';
16
- import type { CallExpression, DottedGetExpression, VariableExpression } from './parser/Expression';
17
+ import type { CallExpression, CallfuncExpression, DottedGetExpression, VariableExpression } from './parser/Expression';
17
18
  import { type Identifier, type Locatable, type Token } from './lexer/Token';
18
19
  import { SourceNode } from 'source-map';
19
20
  import type { BrsFile } from './files/BrsFile';
20
21
  import type { XmlFile } from './files/XmlFile';
21
22
  import type { AstNode, Expression, Statement } from './parser/AstNode';
22
23
  import type { UnresolvedSymbol } from './AstValidationSegmenter';
23
- import type { SymbolTable } from './SymbolTable';
24
+ import type { BscSymbol, GetSymbolTypeOptions, SymbolTable } from './SymbolTable';
24
25
  import { SymbolTypeFlag } from './SymbolTypeFlag';
25
26
  import type { BscType } from './types/BscType';
26
27
  import { FunctionType } from './types/FunctionType';
27
28
  import type { NamespaceStatement } from './parser/Statement';
28
29
  import type { BscFile } from './files/BscFile';
30
+ import { InvalidType } from './types/InvalidType';
29
31
  export declare class Util {
30
32
  clearConsole(): void;
31
33
  /**
@@ -347,7 +349,7 @@ export declare class Util {
347
349
  /**
348
350
  * Convert a token into a BscType
349
351
  */
350
- tokenToBscType(token: Token): DynamicType | ObjectType | BooleanType | DoubleType | FloatType | FunctionType | IntegerType | LongIntegerType | StringType | VoidType;
352
+ tokenToBscType(token: Token): DynamicType | ObjectType | VoidType | InvalidType | BooleanType | DoubleType | FloatType | FunctionType | IntegerType | LongIntegerType | StringType;
351
353
  /**
352
354
  * Deciphers the correct types for fields based on docs
353
355
  * https://developer.roku.com/en-ca/docs/references/scenegraph/xml-elements/interface.md
@@ -360,6 +362,7 @@ export declare class Util {
360
362
  * Note: compound assignments (eg. +=) internally use a binary expression, so that's why TokenKind.PlusEqual, etc. are here too
361
363
  */
362
364
  binaryOperatorResultType(leftType: BscType, operator: Token, rightType: BscType): BscType;
365
+ getHighestPriorityType(types: BscType[], depth?: number): BscType;
363
366
  /**
364
367
  * Return the type of the result of a binary operator
365
368
  */
@@ -458,8 +461,10 @@ export declare class Util {
458
461
  findLastIndex<T>(array: T[], matcher: (T: any) => boolean): number;
459
462
  processTypeChain(typeChain: TypeChainEntry[]): TypeChainProcessResult;
460
463
  isInTypeExpression(expression: AstNode): boolean;
464
+ isGenericNodeType(type: BscType): boolean;
461
465
  hasAnyRequiredSymbolChanged(requiredSymbols: UnresolvedSymbol[], changedSymbols: Map<SymbolTypeFlag, Set<string>>): boolean;
462
466
  setContainsUnresolvedSymbol(symbolLowerNameSet: Set<string>, symbol: UnresolvedSymbol): boolean;
467
+ getCustomTypesInSymbolTree(setToFill: Set<BscType>, type: BscType, filter?: (t: BscSymbol) => boolean): void;
463
468
  truncate<T>(options: {
464
469
  leadingText: string;
465
470
  items: T[];
@@ -473,12 +478,17 @@ export declare class Util {
473
478
  getLeadingComments(input: Token | AstNode): Token[];
474
479
  isLeadingCommentOnSameLine(line: RangeLike, input: Token | AstNode): boolean;
475
480
  isClassUsedAsFunction(potentialClassType: BscType, expression: Expression, options: GetTypeOptions): boolean;
476
- getSpecialCaseCallExpressionReturnType(callExpr: CallExpression): BscType;
481
+ getSpecialCaseCallExpressionReturnType(callExpr: CallExpression, options: GetSymbolTypeOptions): BscType;
482
+ getCallFuncType(callExpr: CallExpression | CallfuncExpression, methodNameToken: Token | Identifier, options: GetSymbolTypeOptions): BscType;
477
483
  symbolComesFromSameNode(symbolName: string, definingNode: AstNode, symbolTable: SymbolTable): boolean;
478
484
  isCalleeMemberOfNamespace(symbolName: string, nodeWhereUsed: AstNode, namespace?: NamespaceStatement): boolean;
479
485
  isVariableMemberOfNamespace(symbolName: string, nodeWhereUsed: AstNode, namespace?: NamespaceStatement): boolean;
480
486
  isVariableShadowingSomething(symbolName: string, nodeWhereUsed: AstNode): boolean;
481
487
  chooseTypeFromCodeOrDocComment(codeType: BscType, docType: BscType, options: GetTypeOptions): BscType;
488
+ /**
489
+ * Gets the type for a default value (eg. as a function param, class member or typed array)
490
+ */
491
+ getDefaultTypeFromValueType(valueType: (BscType | BscType[])): BscType;
482
492
  }
483
493
  /**
484
494
  * A tagged template literal function for standardizing the path. This has to be defined as standalone function since it's a tagged template literal function,
package/dist/util.js CHANGED
@@ -11,6 +11,7 @@ const vscode_languageserver_2 = require("vscode-languageserver");
11
11
  const vscode_uri_1 = require("vscode-uri");
12
12
  const xml2js = require("xml2js");
13
13
  const DiagnosticMessages_1 = require("./DiagnosticMessages");
14
+ const interfaces_1 = require("./interfaces");
14
15
  const BooleanType_1 = require("./types/BooleanType");
15
16
  const DoubleType_1 = require("./types/DoubleType");
16
17
  const DynamicType_1 = require("./types/DynamicType");
@@ -37,6 +38,8 @@ const ReferenceType_1 = require("./types/ReferenceType");
37
38
  const AssociativeArrayType_1 = require("./types/AssociativeArrayType");
38
39
  const ComponentType_1 = require("./types/ComponentType");
39
40
  const FunctionType_1 = require("./types/FunctionType");
41
+ const helpers_1 = require("./types/helpers");
42
+ const InvalidType_1 = require("./types/InvalidType");
40
43
  class Util {
41
44
  clearConsole() {
42
45
  // process.stdout.write('\x1Bc');
@@ -186,7 +189,7 @@ class Util {
186
189
  })) !== null && _a !== void 0 ? _a : {};
187
190
  if (parseErrors.length > 0) {
188
191
  let err = parseErrors[0];
189
- let diagnostic = Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.bsConfigJsonHasSyntaxErrors((0, jsonc_parser_1.printParseErrorCode)(parseErrors[0].error))), { location: {
192
+ let diagnostic = Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.syntaxError(`Syntax errors in bsconfig.json: ${(0, jsonc_parser_1.printParseErrorCode)(parseErrors[0].error)}`)), { location: {
190
193
  uri: this.pathToUri(configFilePath),
191
194
  range: this.getRangeFromOffsetLength(projectFileContents, err.offset, err.length)
192
195
  } });
@@ -1270,7 +1273,7 @@ class Util {
1270
1273
  case TokenKind_1.TokenKind.IntegerLiteral:
1271
1274
  return IntegerType_1.IntegerType.instance;
1272
1275
  case TokenKind_1.TokenKind.Invalid:
1273
- return DynamicType_1.DynamicType.instance; // TODO: use InvalidType better new InvalidType(token.text);
1276
+ return new InvalidType_1.InvalidType(token.text);
1274
1277
  case TokenKind_1.TokenKind.LongInteger:
1275
1278
  return new LongIntegerType_1.LongIntegerType(token.text);
1276
1279
  case TokenKind_1.TokenKind.LongIntegerLiteral:
@@ -1301,7 +1304,7 @@ class Util {
1301
1304
  case 'integer':
1302
1305
  return new IntegerType_1.IntegerType(token.text);
1303
1306
  case 'invalid':
1304
- return DynamicType_1.DynamicType.instance; // TODO: use InvalidType better new InvalidType(token.text);
1307
+ return new InvalidType_1.InvalidType(token.text);
1305
1308
  case 'longinteger':
1306
1309
  return new LongIntegerType_1.LongIntegerType(token.text);
1307
1310
  case 'object':
@@ -1473,20 +1476,50 @@ class Util {
1473
1476
  return this.binaryOperatorResultType(lhs, op, rhs);
1474
1477
  });
1475
1478
  }
1479
+ // Try to find a common value of union type
1480
+ leftType = (0, helpers_1.getUniqueType)([leftType], UnionType_1.unionTypeFactory);
1481
+ rightType = (0, helpers_1.getUniqueType)([rightType], UnionType_1.unionTypeFactory);
1482
+ if ((0, reflection_1.isUnionType)(leftType)) {
1483
+ leftType = this.getHighestPriorityType(leftType.types);
1484
+ }
1485
+ if ((0, reflection_1.isUnionType)(rightType)) {
1486
+ rightType = this.getHighestPriorityType(rightType.types);
1487
+ }
1488
+ if ((0, reflection_1.isVoidType)(leftType) || (0, reflection_1.isVoidType)(rightType) || (0, reflection_1.isUninitializedType)(leftType) || (0, reflection_1.isUninitializedType)(rightType)) {
1489
+ return undefined;
1490
+ }
1476
1491
  if ((0, reflection_1.isEnumMemberType)(leftType)) {
1477
1492
  leftType = leftType.underlyingType;
1478
1493
  }
1479
1494
  if ((0, reflection_1.isEnumMemberType)(rightType)) {
1480
1495
  rightType = rightType.underlyingType;
1481
1496
  }
1497
+ // treat object type like dynamic
1498
+ if ((0, reflection_1.isObjectType)(leftType)) {
1499
+ leftType = DynamicType_1.DynamicType.instance;
1500
+ }
1501
+ if ((0, reflection_1.isObjectType)(rightType)) {
1502
+ rightType = DynamicType_1.DynamicType.instance;
1503
+ }
1482
1504
  let hasDouble = (0, reflection_1.isDoubleType)(leftType) || (0, reflection_1.isDoubleType)(rightType);
1483
1505
  let hasFloat = (0, reflection_1.isFloatType)(leftType) || (0, reflection_1.isFloatType)(rightType);
1484
1506
  let hasLongInteger = (0, reflection_1.isLongIntegerType)(leftType) || (0, reflection_1.isLongIntegerType)(rightType);
1485
1507
  let hasInvalid = (0, reflection_1.isInvalidType)(leftType) || (0, reflection_1.isInvalidType)(rightType);
1486
1508
  let hasDynamic = (0, reflection_1.isDynamicType)(leftType) || (0, reflection_1.isDynamicType)(rightType);
1509
+ let bothDynamic = (0, reflection_1.isDynamicType)(leftType) && (0, reflection_1.isDynamicType)(rightType);
1487
1510
  let bothNumbers = (0, reflection_1.isNumberType)(leftType) && (0, reflection_1.isNumberType)(rightType);
1511
+ let hasNumber = (0, reflection_1.isNumberType)(leftType) || (0, reflection_1.isNumberType)(rightType);
1488
1512
  let bothStrings = (0, reflection_1.isStringType)(leftType) && (0, reflection_1.isStringType)(rightType);
1513
+ let hasString = (0, reflection_1.isStringType)(leftType) || (0, reflection_1.isStringType)(rightType);
1514
+ let hasBoolean = (0, reflection_1.isBooleanType)(leftType) || (0, reflection_1.isBooleanType)(rightType);
1489
1515
  let eitherBooleanOrNum = ((0, reflection_1.isNumberType)(leftType) || (0, reflection_1.isBooleanType)(leftType)) && ((0, reflection_1.isNumberType)(rightType) || (0, reflection_1.isBooleanType)(rightType));
1516
+ let leftIsPrimitive = (0, reflection_1.isPrimitiveType)(leftType);
1517
+ let rightIsPrimitive = (0, reflection_1.isPrimitiveType)(rightType);
1518
+ let hasPrimitive = leftIsPrimitive || rightIsPrimitive;
1519
+ let nonDynamicType;
1520
+ if (hasPrimitive) {
1521
+ nonDynamicType = leftIsPrimitive ? leftType : rightType;
1522
+ }
1490
1523
  // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
1491
1524
  switch (operator.kind) {
1492
1525
  // Math operators
@@ -1496,6 +1529,10 @@ class Util {
1496
1529
  // "string" + "string" is the only binary expression allowed with strings
1497
1530
  return StringType_1.StringType.instance;
1498
1531
  }
1532
+ else if (hasString && hasDynamic) {
1533
+ // assume dynamicValue is a string
1534
+ return StringType_1.StringType.instance;
1535
+ }
1499
1536
  // eslint-disable-next-line no-fallthrough
1500
1537
  case TokenKind_1.TokenKind.Minus:
1501
1538
  case TokenKind_1.TokenKind.MinusEqual:
@@ -1514,6 +1551,10 @@ class Util {
1514
1551
  }
1515
1552
  return IntegerType_1.IntegerType.instance;
1516
1553
  }
1554
+ else if (hasNumber && hasDynamic) {
1555
+ // assume dynamic is a number
1556
+ return nonDynamicType;
1557
+ }
1517
1558
  break;
1518
1559
  case TokenKind_1.TokenKind.Forwardslash:
1519
1560
  case TokenKind_1.TokenKind.ForwardslashEqual:
@@ -1529,6 +1570,10 @@ class Util {
1529
1570
  }
1530
1571
  return FloatType_1.FloatType.instance;
1531
1572
  }
1573
+ else if (hasNumber && hasDynamic) {
1574
+ // assume dynamic is a number
1575
+ return nonDynamicType;
1576
+ }
1532
1577
  break;
1533
1578
  case TokenKind_1.TokenKind.Backslash:
1534
1579
  case TokenKind_1.TokenKind.BackslashEqual:
@@ -1538,6 +1583,10 @@ class Util {
1538
1583
  }
1539
1584
  return IntegerType_1.IntegerType.instance;
1540
1585
  }
1586
+ else if (hasNumber && hasDynamic) {
1587
+ // assume dynamic is a number
1588
+ return IntegerType_1.IntegerType.instance;
1589
+ }
1541
1590
  break;
1542
1591
  case TokenKind_1.TokenKind.Caret:
1543
1592
  if (bothNumbers) {
@@ -1549,6 +1598,10 @@ class Util {
1549
1598
  }
1550
1599
  return IntegerType_1.IntegerType.instance;
1551
1600
  }
1601
+ else if (hasNumber && hasDynamic) {
1602
+ // assume dynamic is a number
1603
+ return IntegerType_1.IntegerType.instance;
1604
+ }
1552
1605
  break;
1553
1606
  // Bitshift operators
1554
1607
  case TokenKind_1.TokenKind.LeftShift:
@@ -1563,6 +1616,10 @@ class Util {
1563
1616
  // but will always truncate to ints
1564
1617
  return IntegerType_1.IntegerType.instance;
1565
1618
  }
1619
+ else if (hasNumber && hasDynamic) {
1620
+ // assume dynamic is a number
1621
+ return IntegerType_1.IntegerType.instance;
1622
+ }
1566
1623
  break;
1567
1624
  // Comparison operators
1568
1625
  // All comparison operators result in boolean
@@ -1580,6 +1637,10 @@ class Util {
1580
1637
  if (bothStrings || bothNumbers) {
1581
1638
  return BooleanType_1.BooleanType.instance;
1582
1639
  }
1640
+ else if ((hasNumber || hasString) && hasDynamic) {
1641
+ // assume dynamic is a valid type
1642
+ return BooleanType_1.BooleanType.instance;
1643
+ }
1583
1644
  break;
1584
1645
  // Logical or bitwise operators
1585
1646
  case TokenKind_1.TokenKind.Or:
@@ -1596,17 +1657,81 @@ class Util {
1596
1657
  // "and"/"or" represent logical operators
1597
1658
  return BooleanType_1.BooleanType.instance;
1598
1659
  }
1660
+ else if (hasNumber && hasDynamic) {
1661
+ // assume dynamic is a valid type
1662
+ return IntegerType_1.IntegerType.instance;
1663
+ }
1664
+ else if (hasBoolean && hasDynamic) {
1665
+ // assume dynamic is a valid type
1666
+ return BooleanType_1.BooleanType.instance;
1667
+ }
1599
1668
  break;
1600
1669
  }
1601
- return DynamicType_1.DynamicType.instance;
1670
+ if (bothDynamic) {
1671
+ return DynamicType_1.DynamicType.instance;
1672
+ }
1673
+ return undefined;
1674
+ }
1675
+ getHighestPriorityType(types, depth = 0) {
1676
+ let result;
1677
+ if (depth > 4) {
1678
+ // shortcut for very complicated types, or self-referencing union types
1679
+ return DynamicType_1.DynamicType.instance;
1680
+ }
1681
+ for (let type of types) {
1682
+ if ((0, reflection_1.isUnionType)(type)) {
1683
+ type = (0, helpers_1.getUniqueType)([type], UnionType_1.unionTypeFactory);
1684
+ if ((0, reflection_1.isUnionType)(type)) {
1685
+ type = this.getHighestPriorityType(type.types, depth + 1);
1686
+ }
1687
+ }
1688
+ if (!result) {
1689
+ result = type;
1690
+ }
1691
+ else {
1692
+ if (type.binaryOpPriorityLevel < result.binaryOpPriorityLevel) {
1693
+ result = type;
1694
+ }
1695
+ else if (type.binaryOpPriorityLevel === result.binaryOpPriorityLevel && !result.isEqual(type)) {
1696
+ // equal priority types, but not equal types, like Boolean and String... just be dynamic at this point
1697
+ result = DynamicType_1.DynamicType.instance;
1698
+ }
1699
+ }
1700
+ if ((0, reflection_1.isUninitializedType)(type)) {
1701
+ return type;
1702
+ }
1703
+ if ((0, reflection_1.isVoidType)(type)) {
1704
+ return type;
1705
+ }
1706
+ if ((0, reflection_1.isInvalidType)(type)) {
1707
+ return type;
1708
+ }
1709
+ if ((0, reflection_1.isObjectType)(type) && !(0, reflection_1.isDynamicType)(type)) {
1710
+ result = type;
1711
+ }
1712
+ if ((0, reflection_1.isDynamicType)(type)) {
1713
+ result = type;
1714
+ }
1715
+ }
1716
+ return result !== null && result !== void 0 ? result : DynamicType_1.DynamicType.instance;
1602
1717
  }
1603
1718
  /**
1604
1719
  * Return the type of the result of a binary operator
1605
1720
  */
1606
1721
  unaryOperatorResultType(operator, exprType) {
1722
+ if ((0, reflection_1.isUnionType)(exprType)) {
1723
+ exprType = this.getHighestPriorityType(exprType.types);
1724
+ }
1725
+ if ((0, reflection_1.isVoidType)(exprType) || (0, reflection_1.isInvalidType)(exprType) || (0, reflection_1.isUninitializedType)(exprType)) {
1726
+ return undefined;
1727
+ }
1728
+ if ((0, reflection_1.isDynamicType)(exprType) || (0, reflection_1.isObjectType)(exprType)) {
1729
+ return exprType;
1730
+ }
1607
1731
  // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
1608
1732
  switch (operator.kind) {
1609
1733
  // Math operators
1734
+ case TokenKind_1.TokenKind.Plus: // (`num = +num` is valid syntax)
1610
1735
  case TokenKind_1.TokenKind.Minus:
1611
1736
  if ((0, reflection_1.isNumberType)(exprType)) {
1612
1737
  // a negative number will be the same type, eg, double->double, int->int, etc.
@@ -1627,7 +1752,7 @@ class Util {
1627
1752
  }
1628
1753
  break;
1629
1754
  }
1630
- return DynamicType_1.DynamicType.instance;
1755
+ return undefined;
1631
1756
  }
1632
1757
  /**
1633
1758
  * Get the extension for the given file path. Basically the part after the final dot, except for
@@ -1781,7 +1906,7 @@ class Util {
1781
1906
  return clone;
1782
1907
  //filter out null relatedInformation items
1783
1908
  }).filter((x) => Boolean(x)),
1784
- code: diagnostic.code,
1909
+ code: diagnostic.code ? diagnostic.code : diagnostic.legacyCode,
1785
1910
  source: 'brs'
1786
1911
  };
1787
1912
  if (((_d = diagnostic === null || diagnostic === void 0 ? void 0 : diagnostic.tags) === null || _d === void 0 ? void 0 : _d.length) > 0) {
@@ -2058,7 +2183,7 @@ class Util {
2058
2183
  }
2059
2184
  }
2060
2185
  processTypeChain(typeChain) {
2061
- var _a, _b, _c, _d;
2186
+ var _a, _b, _c, _d, _e;
2062
2187
  let fullChainName = '';
2063
2188
  let fullErrorName = '';
2064
2189
  let itemName = '';
@@ -2070,6 +2195,7 @@ class Util {
2070
2195
  let errorLocation;
2071
2196
  let containsDynamic = false;
2072
2197
  let continueResolvingAllItems = true;
2198
+ let crossedCallFunc = false;
2073
2199
  for (let i = 0; i < typeChain.length; i++) {
2074
2200
  const chainItem = typeChain[i];
2075
2201
  const dotSep = (_b = (_a = chainItem.separatorToken) === null || _a === void 0 ? void 0 : _a.text) !== null && _b !== void 0 ? _b : '.';
@@ -2117,6 +2243,7 @@ class Util {
2117
2243
  itemName = chainItem.name;
2118
2244
  astNode = chainItem.astNode;
2119
2245
  containsDynamic = containsDynamic || ((0, reflection_1.isDynamicType)(chainItem.type) && !(0, reflection_1.isAnyReferenceType)(chainItem.type));
2246
+ crossedCallFunc = crossedCallFunc || ((_e = chainItem.data) === null || _e === void 0 ? void 0 : _e.isFromCallFunc);
2120
2247
  if (!chainItem.isResolved) {
2121
2248
  errorLocation = chainItem.location;
2122
2249
  continueResolvingAllItems = false;
@@ -2132,18 +2259,19 @@ class Util {
2132
2259
  fullChainName: fullChainName,
2133
2260
  location: errorLocation,
2134
2261
  containsDynamic: containsDynamic,
2135
- astNode: astNode
2262
+ astNode: astNode,
2263
+ crossedCallFunc: crossedCallFunc
2136
2264
  };
2137
2265
  }
2138
2266
  isInTypeExpression(expression) {
2139
2267
  //TODO: this is much faster than node.findAncestor(), but may need to be updated for "complicated" type expressions
2140
2268
  if ((0, reflection_1.isTypeExpression)(expression) ||
2141
- (0, reflection_1.isTypeExpression)(expression.parent) ||
2269
+ (0, reflection_1.isTypeExpression)(expression === null || expression === void 0 ? void 0 : expression.parent) ||
2142
2270
  (0, reflection_1.isTypedArrayExpression)(expression) ||
2143
- (0, reflection_1.isTypedArrayExpression)(expression.parent)) {
2271
+ (0, reflection_1.isTypedArrayExpression)(expression === null || expression === void 0 ? void 0 : expression.parent)) {
2144
2272
  return true;
2145
2273
  }
2146
- if ((0, reflection_1.isBinaryExpression)(expression.parent)) {
2274
+ if ((0, reflection_1.isBinaryExpression)(expression === null || expression === void 0 ? void 0 : expression.parent)) {
2147
2275
  let currentExpr = expression.parent;
2148
2276
  while ((0, reflection_1.isBinaryExpression)(currentExpr) && currentExpr.tokens.operator.kind === TokenKind_1.TokenKind.Or) {
2149
2277
  currentExpr = currentExpr.parent;
@@ -2152,6 +2280,15 @@ class Util {
2152
2280
  }
2153
2281
  return false;
2154
2282
  }
2283
+ isGenericNodeType(type) {
2284
+ if ((0, reflection_1.isComponentType)(type)) {
2285
+ const lowerName = type.toString().toLowerCase();
2286
+ if (lowerName === 'rosgnode' || lowerName === 'rosgnodenode') {
2287
+ return true;
2288
+ }
2289
+ }
2290
+ return false;
2291
+ }
2155
2292
  hasAnyRequiredSymbolChanged(requiredSymbols, changedSymbols) {
2156
2293
  if (!requiredSymbols || !changedSymbols) {
2157
2294
  return false;
@@ -2176,6 +2313,21 @@ class Util {
2176
2313
  }
2177
2314
  return false;
2178
2315
  }
2316
+ getCustomTypesInSymbolTree(setToFill, type, filter) {
2317
+ var _a, _b, _c;
2318
+ const subSymbols = (_b = (_a = type.getMemberTable()) === null || _a === void 0 ? void 0 : _a.getAllSymbols(1 /* SymbolTypeFlag.runtime */)) !== null && _b !== void 0 ? _b : [];
2319
+ for (const subSymbol of subSymbols) {
2320
+ if (!((_c = subSymbol.type) === null || _c === void 0 ? void 0 : _c.isBuiltIn) && !setToFill.has(subSymbol.type)) {
2321
+ if (filter && !filter(subSymbol)) {
2322
+ continue;
2323
+ }
2324
+ // if this is a custom type, and we haven't added it to the types to check to see if can add it to the additional types
2325
+ // add the type, and investigate any members
2326
+ setToFill.add(subSymbol.type);
2327
+ this.getCustomTypesInSymbolTree(setToFill, subSymbol.type, filter);
2328
+ }
2329
+ }
2330
+ }
2179
2331
  truncate(options) {
2180
2332
  var _a, _b, _c, _d, _e, _f, _g;
2181
2333
  let leadingText = options.leadingText;
@@ -2256,13 +2408,18 @@ class Util {
2256
2408
  }
2257
2409
  return false;
2258
2410
  }
2259
- getSpecialCaseCallExpressionReturnType(callExpr) {
2260
- var _a, _b, _c, _d;
2411
+ getSpecialCaseCallExpressionReturnType(callExpr, options) {
2412
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
2261
2413
  if ((0, reflection_1.isVariableExpression)(callExpr.callee) && callExpr.callee.tokens.name.text.toLowerCase() === 'createobject') {
2262
2414
  const componentName = (0, reflection_1.isLiteralString)(callExpr.args[0]) ? (_b = (_a = callExpr.args[0].tokens.value) === null || _a === void 0 ? void 0 : _a.text) === null || _b === void 0 ? void 0 : _b.replace(/"/g, '') : '';
2263
2415
  const nodeType = componentName.toLowerCase() === 'rosgnode' && (0, reflection_1.isLiteralString)(callExpr.args[1]) ? (_d = (_c = callExpr.args[1].tokens.value) === null || _c === void 0 ? void 0 : _c.text) === null || _d === void 0 ? void 0 : _d.replace(/"/g, '') : '';
2264
2416
  if (componentName === null || componentName === void 0 ? void 0 : componentName.toLowerCase().startsWith('ro')) {
2265
- const fullName = componentName + nodeType;
2417
+ let fullName = componentName + nodeType;
2418
+ if (nodeType.includes(':')) {
2419
+ // This node has a colon in its name, most likely from a component Library
2420
+ // This componentType is most likely unknown, so return `roSGNode`
2421
+ fullName = 'roSGNode';
2422
+ }
2266
2423
  const data = {};
2267
2424
  const symbolTable = callExpr.getSymbolTable();
2268
2425
  const foundType = symbolTable.getSymbolType(fullName, {
@@ -2276,6 +2433,72 @@ class Util {
2276
2433
  }
2277
2434
  }
2278
2435
  }
2436
+ else if ((0, reflection_1.isDottedGetExpression)(callExpr.callee) &&
2437
+ ((_g = (_f = (_e = callExpr.callee.tokens) === null || _e === void 0 ? void 0 : _e.name) === null || _f === void 0 ? void 0 : _f.text) === null || _g === void 0 ? void 0 : _g.toLowerCase()) === 'callfunc' &&
2438
+ (0, reflection_1.isLiteralString)((_h = callExpr.args) === null || _h === void 0 ? void 0 : _h[0])) {
2439
+ return this.getCallFuncType(callExpr, (_k = (_j = callExpr.args) === null || _j === void 0 ? void 0 : _j[0]) === null || _k === void 0 ? void 0 : _k.tokens.value, options);
2440
+ }
2441
+ else if ((0, reflection_1.isDottedGetExpression)(callExpr.callee) &&
2442
+ ((_o = (_m = (_l = callExpr.callee.tokens) === null || _l === void 0 ? void 0 : _l.name) === null || _m === void 0 ? void 0 : _m.text) === null || _o === void 0 ? void 0 : _o.toLowerCase()) === 'createchild' &&
2443
+ (0, reflection_1.isComponentType)((_p = callExpr.callee.obj) === null || _p === void 0 ? void 0 : _p.getType({ flags: 1 /* SymbolTypeFlag.runtime */ })) &&
2444
+ (0, reflection_1.isLiteralString)((_q = callExpr.args) === null || _q === void 0 ? void 0 : _q[0])) {
2445
+ const fullName = `roSGNode${(_u = (_t = (_s = (_r = callExpr.args) === null || _r === void 0 ? void 0 : _r[0].tokens) === null || _s === void 0 ? void 0 : _s.value) === null || _t === void 0 ? void 0 : _t.text) === null || _u === void 0 ? void 0 : _u.replace(/"/g, '')}`;
2446
+ const data = {};
2447
+ const symbolTable = callExpr.getSymbolTable();
2448
+ return symbolTable.getSymbolType(fullName, {
2449
+ flags: 2 /* SymbolTypeFlag.typetime */,
2450
+ data: data,
2451
+ tableProvider: () => callExpr === null || callExpr === void 0 ? void 0 : callExpr.getSymbolTable(),
2452
+ fullName: fullName
2453
+ });
2454
+ }
2455
+ }
2456
+ getCallFuncType(callExpr, methodNameToken, options) {
2457
+ var _a, _b, _c, _d, _e;
2458
+ let result;
2459
+ let methodName = (_a = methodNameToken === null || methodNameToken === void 0 ? void 0 : methodNameToken.text) === null || _a === void 0 ? void 0 : _a.replace(/"/g, ''); // remove quotes if it was the first arg of .callFunc()
2460
+ // a little hacky here with checking options.ignoreCall because callFuncExpression has the method name
2461
+ // It's nicer for CallExpression, because it's a call on any expression.
2462
+ let calleeType;
2463
+ if ((0, reflection_1.isCallfuncExpression)(callExpr)) {
2464
+ calleeType = callExpr.callee.getType(Object.assign(Object.assign({}, options), { flags: 1 /* SymbolTypeFlag.runtime */, ignoreCall: false }));
2465
+ }
2466
+ else if ((0, reflection_1.isCallExpression)(callExpr) && (0, reflection_1.isDottedGetExpression)(callExpr.callee)) {
2467
+ calleeType = callExpr.callee.obj.getType(Object.assign(Object.assign({}, options), { flags: 1 /* SymbolTypeFlag.runtime */, ignoreCall: false }));
2468
+ }
2469
+ if ((0, reflection_1.isComponentType)(calleeType) || (0, reflection_1.isReferenceType)(calleeType)) {
2470
+ const funcType = (_c = (_b = calleeType).getCallFuncType) === null || _c === void 0 ? void 0 : _c.call(_b, methodName, options);
2471
+ if (funcType) {
2472
+ (_d = options.typeChain) === null || _d === void 0 ? void 0 : _d.push(new interfaces_1.TypeChainEntry({
2473
+ name: methodName,
2474
+ type: funcType,
2475
+ data: options.data,
2476
+ location: methodNameToken.location,
2477
+ separatorToken: (0, creators_1.createToken)(TokenKind_1.TokenKind.Callfunc),
2478
+ astNode: callExpr
2479
+ }));
2480
+ if (options.ignoreCall) {
2481
+ result = funcType;
2482
+ }
2483
+ else if ((0, reflection_1.isCallableType)(funcType) && (!(0, reflection_1.isReferenceType)(funcType.returnType) || funcType.returnType.isResolvable())) {
2484
+ result = funcType.returnType;
2485
+ }
2486
+ else if (!(0, reflection_1.isReferenceType)(funcType) && ((_e = funcType === null || funcType === void 0 ? void 0 : funcType.returnType) === null || _e === void 0 ? void 0 : _e.isResolvable())) {
2487
+ result = funcType.returnType;
2488
+ }
2489
+ else {
2490
+ result = new ReferenceType_1.TypePropertyReferenceType(funcType, 'returnType');
2491
+ }
2492
+ }
2493
+ }
2494
+ if ((0, reflection_1.isVoidType)(result)) {
2495
+ // CallFunc will always return invalid, even if function called is `as void`
2496
+ result = DynamicType_1.DynamicType.instance;
2497
+ }
2498
+ if (options.data && !options.ignoreCall) {
2499
+ options.data.isFromCallFunc = true;
2500
+ }
2501
+ return result;
2279
2502
  }
2280
2503
  symbolComesFromSameNode(symbolName, definingNode, symbolTable) {
2281
2504
  let nsData = {};
@@ -2358,6 +2581,50 @@ class Util {
2358
2581
  }
2359
2582
  return returnType;
2360
2583
  }
2584
+ /**
2585
+ * Gets the type for a default value (eg. as a function param, class member or typed array)
2586
+ */
2587
+ getDefaultTypeFromValueType(valueType) {
2588
+ var _a;
2589
+ if (!valueType) {
2590
+ return undefined;
2591
+ }
2592
+ let resultType = DynamicType_1.DynamicType.instance;
2593
+ if (Array.isArray(valueType)) {
2594
+ // passed an array opf types, potential from ArrayType.innerTypes
2595
+ if (valueType.length > 0) {
2596
+ //at least one, use it
2597
+ resultType = valueType[0];
2598
+ if ((valueType === null || valueType === void 0 ? void 0 : valueType.length) > 1) {
2599
+ // more than 1, find union
2600
+ resultType = (0, helpers_1.getUniqueType)(valueType, UnionType_1.unionTypeFactory);
2601
+ }
2602
+ }
2603
+ }
2604
+ else {
2605
+ resultType = valueType;
2606
+ }
2607
+ if (!resultType.isResolvable()) {
2608
+ resultType = new ReferenceType_1.ParamTypeFromValueReferenceType(resultType);
2609
+ }
2610
+ else if ((0, reflection_1.isEnumMemberType)(resultType)) {
2611
+ // the type was an enum member... Try to get the parent enum type
2612
+ resultType = (_a = resultType.parentEnumType) !== null && _a !== void 0 ? _a : resultType;
2613
+ }
2614
+ else if ((0, reflection_1.isUnionType)(resultType)) {
2615
+ // it was a union -- I wonder if they're resolvable now?
2616
+ const moddedTypes = resultType.types.map(t => {
2617
+ var _a;
2618
+ if ((0, reflection_1.isEnumMemberType)(t)) {
2619
+ // the type was an enum member... Try to get the parent enum type
2620
+ return (_a = t.parentEnumType) !== null && _a !== void 0 ? _a : resultType;
2621
+ }
2622
+ return t;
2623
+ });
2624
+ resultType = (0, helpers_1.getUniqueType)(moddedTypes, UnionType_1.unionTypeFactory);
2625
+ }
2626
+ return resultType;
2627
+ }
2361
2628
  }
2362
2629
  exports.Util = Util;
2363
2630
  /**