@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/cli.js CHANGED
@@ -4072,7 +4072,7 @@ function resolveRegisteredCustomTypeFromTypeNode(typeNode, extensionRegistry, ch
4072
4072
  };
4073
4073
  }
4074
4074
  if (ts3.isTypeReferenceNode(typeNode) && ts3.isIdentifier(typeNode.typeName)) {
4075
- const aliasDecl = checker.getSymbolAtLocation(typeNode.typeName)?.declarations?.find(ts3.isTypeAliasDeclaration);
4075
+ const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
4076
4076
  if (aliasDecl !== void 0) {
4077
4077
  return resolveRegisteredCustomTypeFromTypeNode(aliasDecl.type, extensionRegistry, checker);
4078
4078
  }
@@ -4265,13 +4265,13 @@ function getReferencedTypeAliasDeclaration(sourceNode, checker) {
4265
4265
  if (!typeNode || !ts3.isTypeReferenceNode(typeNode)) {
4266
4266
  return void 0;
4267
4267
  }
4268
- return checker.getSymbolAtLocation(typeNode.typeName)?.declarations?.find(ts3.isTypeAliasDeclaration);
4268
+ return getTypeAliasDeclarationFromTypeReference(typeNode, checker);
4269
4269
  }
4270
4270
  function shouldEmitPrimitiveAliasDefinition(typeNode, checker) {
4271
4271
  if (!ts3.isTypeReferenceNode(typeNode)) {
4272
4272
  return false;
4273
4273
  }
4274
- const aliasDecl = checker.getSymbolAtLocation(typeNode.typeName)?.declarations?.find(ts3.isTypeAliasDeclaration);
4274
+ const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
4275
4275
  if (!aliasDecl) {
4276
4276
  return false;
4277
4277
  }
@@ -4840,8 +4840,7 @@ function resolveAliasedTypeNode(typeNode, checker, visited = /* @__PURE__ */ new
4840
4840
  if (!ts3.isTypeReferenceNode(typeNode) || !ts3.isIdentifier(typeNode.typeName)) {
4841
4841
  return typeNode;
4842
4842
  }
4843
- const symbol = checker.getSymbolAtLocation(typeNode.typeName);
4844
- const aliasDecl = symbol?.declarations?.find(ts3.isTypeAliasDeclaration);
4843
+ const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
4845
4844
  if (aliasDecl === void 0 || visited.has(aliasDecl)) {
4846
4845
  return typeNode;
4847
4846
  }
@@ -4890,8 +4889,7 @@ function extractTypeAliasConstraintNodes(typeNode, checker, file, extensionRegis
4890
4889
  );
4891
4890
  }
4892
4891
  const symbol = checker.getSymbolAtLocation(typeNode.typeName);
4893
- if (!symbol?.declarations) return [];
4894
- const aliasDecl = symbol.declarations.find(ts3.isTypeAliasDeclaration);
4892
+ const aliasDecl = getAliasedTypeAliasDeclaration(symbol, checker);
4895
4893
  if (!aliasDecl) return [];
4896
4894
  if (ts3.isTypeLiteralNode(aliasDecl.type)) return [];
4897
4895
  const aliasFieldType = resolveTypeNode(
@@ -4914,6 +4912,18 @@ function extractTypeAliasConstraintNodes(typeNode, checker, file, extensionRegis
4914
4912
  );
4915
4913
  return constraints;
4916
4914
  }
4915
+ function getAliasedSymbol(symbol, checker) {
4916
+ if (symbol === void 0) {
4917
+ return void 0;
4918
+ }
4919
+ return symbol.flags & ts3.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
4920
+ }
4921
+ function getAliasedTypeAliasDeclaration(symbol, checker) {
4922
+ return getAliasedSymbol(symbol, checker)?.declarations?.find(ts3.isTypeAliasDeclaration);
4923
+ }
4924
+ function getTypeAliasDeclarationFromTypeReference(typeNode, checker) {
4925
+ return getAliasedTypeAliasDeclaration(checker.getSymbolAtLocation(typeNode.typeName), checker);
4926
+ }
4917
4927
  function provenanceForNode(node, file) {
4918
4928
  const sourceFile = node.getSourceFile();
4919
4929
  const { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart());