@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/index.cjs CHANGED
@@ -3986,7 +3986,7 @@ function resolveRegisteredCustomTypeFromTypeNode(typeNode, extensionRegistry, ch
3986
3986
  };
3987
3987
  }
3988
3988
  if (ts3.isTypeReferenceNode(typeNode) && ts3.isIdentifier(typeNode.typeName)) {
3989
- const aliasDecl = checker.getSymbolAtLocation(typeNode.typeName)?.declarations?.find(ts3.isTypeAliasDeclaration);
3989
+ const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
3990
3990
  if (aliasDecl !== void 0) {
3991
3991
  return resolveRegisteredCustomTypeFromTypeNode(aliasDecl.type, extensionRegistry, checker);
3992
3992
  }
@@ -4179,13 +4179,13 @@ function getReferencedTypeAliasDeclaration(sourceNode, checker) {
4179
4179
  if (!typeNode || !ts3.isTypeReferenceNode(typeNode)) {
4180
4180
  return void 0;
4181
4181
  }
4182
- return checker.getSymbolAtLocation(typeNode.typeName)?.declarations?.find(ts3.isTypeAliasDeclaration);
4182
+ return getTypeAliasDeclarationFromTypeReference(typeNode, checker);
4183
4183
  }
4184
4184
  function shouldEmitPrimitiveAliasDefinition(typeNode, checker) {
4185
4185
  if (!ts3.isTypeReferenceNode(typeNode)) {
4186
4186
  return false;
4187
4187
  }
4188
- const aliasDecl = checker.getSymbolAtLocation(typeNode.typeName)?.declarations?.find(ts3.isTypeAliasDeclaration);
4188
+ const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
4189
4189
  if (!aliasDecl) {
4190
4190
  return false;
4191
4191
  }
@@ -4754,8 +4754,7 @@ function resolveAliasedTypeNode(typeNode, checker, visited = /* @__PURE__ */ new
4754
4754
  if (!ts3.isTypeReferenceNode(typeNode) || !ts3.isIdentifier(typeNode.typeName)) {
4755
4755
  return typeNode;
4756
4756
  }
4757
- const symbol = checker.getSymbolAtLocation(typeNode.typeName);
4758
- const aliasDecl = symbol?.declarations?.find(ts3.isTypeAliasDeclaration);
4757
+ const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
4759
4758
  if (aliasDecl === void 0 || visited.has(aliasDecl)) {
4760
4759
  return typeNode;
4761
4760
  }
@@ -4805,8 +4804,7 @@ function extractTypeAliasConstraintNodes(typeNode, checker, file, extensionRegis
4805
4804
  );
4806
4805
  }
4807
4806
  const symbol = checker.getSymbolAtLocation(typeNode.typeName);
4808
- if (!symbol?.declarations) return [];
4809
- const aliasDecl = symbol.declarations.find(ts3.isTypeAliasDeclaration);
4807
+ const aliasDecl = getAliasedTypeAliasDeclaration(symbol, checker);
4810
4808
  if (!aliasDecl) return [];
4811
4809
  if (ts3.isTypeLiteralNode(aliasDecl.type)) return [];
4812
4810
  const aliasFieldType = resolveTypeNode(
@@ -4829,6 +4827,18 @@ function extractTypeAliasConstraintNodes(typeNode, checker, file, extensionRegis
4829
4827
  );
4830
4828
  return constraints;
4831
4829
  }
4830
+ function getAliasedSymbol(symbol, checker) {
4831
+ if (symbol === void 0) {
4832
+ return void 0;
4833
+ }
4834
+ return symbol.flags & ts3.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
4835
+ }
4836
+ function getAliasedTypeAliasDeclaration(symbol, checker) {
4837
+ return getAliasedSymbol(symbol, checker)?.declarations?.find(ts3.isTypeAliasDeclaration);
4838
+ }
4839
+ function getTypeAliasDeclarationFromTypeReference(typeNode, checker) {
4840
+ return getAliasedTypeAliasDeclaration(checker.getSymbolAtLocation(typeNode.typeName), checker);
4841
+ }
4832
4842
  function provenanceForNode(node, file) {
4833
4843
  const sourceFile = node.getSourceFile();
4834
4844
  const { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart());