@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.
package/dist/internals.js CHANGED
@@ -2688,7 +2688,7 @@ function resolveRegisteredCustomTypeFromTypeNode(typeNode, extensionRegistry, ch
2688
2688
  };
2689
2689
  }
2690
2690
  if (ts3.isTypeReferenceNode(typeNode) && ts3.isIdentifier(typeNode.typeName)) {
2691
- const aliasDecl = checker.getSymbolAtLocation(typeNode.typeName)?.declarations?.find(ts3.isTypeAliasDeclaration);
2691
+ const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
2692
2692
  if (aliasDecl !== void 0) {
2693
2693
  return resolveRegisteredCustomTypeFromTypeNode(aliasDecl.type, extensionRegistry, checker);
2694
2694
  }
@@ -2881,13 +2881,13 @@ function getReferencedTypeAliasDeclaration(sourceNode, checker) {
2881
2881
  if (!typeNode || !ts3.isTypeReferenceNode(typeNode)) {
2882
2882
  return void 0;
2883
2883
  }
2884
- return checker.getSymbolAtLocation(typeNode.typeName)?.declarations?.find(ts3.isTypeAliasDeclaration);
2884
+ return getTypeAliasDeclarationFromTypeReference(typeNode, checker);
2885
2885
  }
2886
2886
  function shouldEmitPrimitiveAliasDefinition(typeNode, checker) {
2887
2887
  if (!ts3.isTypeReferenceNode(typeNode)) {
2888
2888
  return false;
2889
2889
  }
2890
- const aliasDecl = checker.getSymbolAtLocation(typeNode.typeName)?.declarations?.find(ts3.isTypeAliasDeclaration);
2890
+ const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
2891
2891
  if (!aliasDecl) {
2892
2892
  return false;
2893
2893
  }
@@ -3456,8 +3456,7 @@ function resolveAliasedTypeNode(typeNode, checker, visited = /* @__PURE__ */ new
3456
3456
  if (!ts3.isTypeReferenceNode(typeNode) || !ts3.isIdentifier(typeNode.typeName)) {
3457
3457
  return typeNode;
3458
3458
  }
3459
- const symbol = checker.getSymbolAtLocation(typeNode.typeName);
3460
- const aliasDecl = symbol?.declarations?.find(ts3.isTypeAliasDeclaration);
3459
+ const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
3461
3460
  if (aliasDecl === void 0 || visited.has(aliasDecl)) {
3462
3461
  return typeNode;
3463
3462
  }
@@ -3507,8 +3506,7 @@ function extractTypeAliasConstraintNodes(typeNode, checker, file, extensionRegis
3507
3506
  );
3508
3507
  }
3509
3508
  const symbol = checker.getSymbolAtLocation(typeNode.typeName);
3510
- if (!symbol?.declarations) return [];
3511
- const aliasDecl = symbol.declarations.find(ts3.isTypeAliasDeclaration);
3509
+ const aliasDecl = getAliasedTypeAliasDeclaration(symbol, checker);
3512
3510
  if (!aliasDecl) return [];
3513
3511
  if (ts3.isTypeLiteralNode(aliasDecl.type)) return [];
3514
3512
  const aliasFieldType = resolveTypeNode(
@@ -3531,6 +3529,18 @@ function extractTypeAliasConstraintNodes(typeNode, checker, file, extensionRegis
3531
3529
  );
3532
3530
  return constraints;
3533
3531
  }
3532
+ function getAliasedSymbol(symbol, checker) {
3533
+ if (symbol === void 0) {
3534
+ return void 0;
3535
+ }
3536
+ return symbol.flags & ts3.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
3537
+ }
3538
+ function getAliasedTypeAliasDeclaration(symbol, checker) {
3539
+ return getAliasedSymbol(symbol, checker)?.declarations?.find(ts3.isTypeAliasDeclaration);
3540
+ }
3541
+ function getTypeAliasDeclarationFromTypeReference(typeNode, checker) {
3542
+ return getAliasedTypeAliasDeclaration(checker.getSymbolAtLocation(typeNode.typeName), checker);
3543
+ }
3534
3544
  function provenanceForNode(node, file) {
3535
3545
  const sourceFile = node.getSourceFile();
3536
3546
  const { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart());