@formspec/build 0.1.0-alpha.35 → 0.1.0-alpha.36

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.
@@ -2712,7 +2712,7 @@ function resolveRegisteredCustomTypeFromTypeNode(typeNode, extensionRegistry, ch
2712
2712
  };
2713
2713
  }
2714
2714
  if (ts3.isTypeReferenceNode(typeNode) && ts3.isIdentifier(typeNode.typeName)) {
2715
- const aliasDecl = checker.getSymbolAtLocation(typeNode.typeName)?.declarations?.find(ts3.isTypeAliasDeclaration);
2715
+ const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
2716
2716
  if (aliasDecl !== void 0) {
2717
2717
  return resolveRegisteredCustomTypeFromTypeNode(aliasDecl.type, extensionRegistry, checker);
2718
2718
  }
@@ -2905,13 +2905,13 @@ function getReferencedTypeAliasDeclaration(sourceNode, checker) {
2905
2905
  if (!typeNode || !ts3.isTypeReferenceNode(typeNode)) {
2906
2906
  return void 0;
2907
2907
  }
2908
- return checker.getSymbolAtLocation(typeNode.typeName)?.declarations?.find(ts3.isTypeAliasDeclaration);
2908
+ return getTypeAliasDeclarationFromTypeReference(typeNode, checker);
2909
2909
  }
2910
2910
  function shouldEmitPrimitiveAliasDefinition(typeNode, checker) {
2911
2911
  if (!ts3.isTypeReferenceNode(typeNode)) {
2912
2912
  return false;
2913
2913
  }
2914
- const aliasDecl = checker.getSymbolAtLocation(typeNode.typeName)?.declarations?.find(ts3.isTypeAliasDeclaration);
2914
+ const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
2915
2915
  if (!aliasDecl) {
2916
2916
  return false;
2917
2917
  }
@@ -3480,8 +3480,7 @@ function resolveAliasedTypeNode(typeNode, checker, visited = /* @__PURE__ */ new
3480
3480
  if (!ts3.isTypeReferenceNode(typeNode) || !ts3.isIdentifier(typeNode.typeName)) {
3481
3481
  return typeNode;
3482
3482
  }
3483
- const symbol = checker.getSymbolAtLocation(typeNode.typeName);
3484
- const aliasDecl = symbol?.declarations?.find(ts3.isTypeAliasDeclaration);
3483
+ const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
3485
3484
  if (aliasDecl === void 0 || visited.has(aliasDecl)) {
3486
3485
  return typeNode;
3487
3486
  }
@@ -3531,8 +3530,7 @@ function extractTypeAliasConstraintNodes(typeNode, checker, file, extensionRegis
3531
3530
  );
3532
3531
  }
3533
3532
  const symbol = checker.getSymbolAtLocation(typeNode.typeName);
3534
- if (!symbol?.declarations) return [];
3535
- const aliasDecl = symbol.declarations.find(ts3.isTypeAliasDeclaration);
3533
+ const aliasDecl = getAliasedTypeAliasDeclaration(symbol, checker);
3536
3534
  if (!aliasDecl) return [];
3537
3535
  if (ts3.isTypeLiteralNode(aliasDecl.type)) return [];
3538
3536
  const aliasFieldType = resolveTypeNode(
@@ -3555,6 +3553,18 @@ function extractTypeAliasConstraintNodes(typeNode, checker, file, extensionRegis
3555
3553
  );
3556
3554
  return constraints;
3557
3555
  }
3556
+ function getAliasedSymbol(symbol, checker) {
3557
+ if (symbol === void 0) {
3558
+ return void 0;
3559
+ }
3560
+ return symbol.flags & ts3.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
3561
+ }
3562
+ function getAliasedTypeAliasDeclaration(symbol, checker) {
3563
+ return getAliasedSymbol(symbol, checker)?.declarations?.find(ts3.isTypeAliasDeclaration);
3564
+ }
3565
+ function getTypeAliasDeclarationFromTypeReference(typeNode, checker) {
3566
+ return getAliasedTypeAliasDeclaration(checker.getSymbolAtLocation(typeNode.typeName), checker);
3567
+ }
3558
3568
  function provenanceForNode(node, file) {
3559
3569
  const sourceFile = node.getSourceFile();
3560
3570
  const { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart());