@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.js CHANGED
@@ -3967,7 +3967,7 @@ function resolveRegisteredCustomTypeFromTypeNode(typeNode, extensionRegistry, ch
3967
3967
  };
3968
3968
  }
3969
3969
  if (ts3.isTypeReferenceNode(typeNode) && ts3.isIdentifier(typeNode.typeName)) {
3970
- const aliasDecl = checker.getSymbolAtLocation(typeNode.typeName)?.declarations?.find(ts3.isTypeAliasDeclaration);
3970
+ const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
3971
3971
  if (aliasDecl !== void 0) {
3972
3972
  return resolveRegisteredCustomTypeFromTypeNode(aliasDecl.type, extensionRegistry, checker);
3973
3973
  }
@@ -4160,13 +4160,13 @@ function getReferencedTypeAliasDeclaration(sourceNode, checker) {
4160
4160
  if (!typeNode || !ts3.isTypeReferenceNode(typeNode)) {
4161
4161
  return void 0;
4162
4162
  }
4163
- return checker.getSymbolAtLocation(typeNode.typeName)?.declarations?.find(ts3.isTypeAliasDeclaration);
4163
+ return getTypeAliasDeclarationFromTypeReference(typeNode, checker);
4164
4164
  }
4165
4165
  function shouldEmitPrimitiveAliasDefinition(typeNode, checker) {
4166
4166
  if (!ts3.isTypeReferenceNode(typeNode)) {
4167
4167
  return false;
4168
4168
  }
4169
- const aliasDecl = checker.getSymbolAtLocation(typeNode.typeName)?.declarations?.find(ts3.isTypeAliasDeclaration);
4169
+ const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
4170
4170
  if (!aliasDecl) {
4171
4171
  return false;
4172
4172
  }
@@ -4735,8 +4735,7 @@ function resolveAliasedTypeNode(typeNode, checker, visited = /* @__PURE__ */ new
4735
4735
  if (!ts3.isTypeReferenceNode(typeNode) || !ts3.isIdentifier(typeNode.typeName)) {
4736
4736
  return typeNode;
4737
4737
  }
4738
- const symbol = checker.getSymbolAtLocation(typeNode.typeName);
4739
- const aliasDecl = symbol?.declarations?.find(ts3.isTypeAliasDeclaration);
4738
+ const aliasDecl = getTypeAliasDeclarationFromTypeReference(typeNode, checker);
4740
4739
  if (aliasDecl === void 0 || visited.has(aliasDecl)) {
4741
4740
  return typeNode;
4742
4741
  }
@@ -4786,8 +4785,7 @@ function extractTypeAliasConstraintNodes(typeNode, checker, file, extensionRegis
4786
4785
  );
4787
4786
  }
4788
4787
  const symbol = checker.getSymbolAtLocation(typeNode.typeName);
4789
- if (!symbol?.declarations) return [];
4790
- const aliasDecl = symbol.declarations.find(ts3.isTypeAliasDeclaration);
4788
+ const aliasDecl = getAliasedTypeAliasDeclaration(symbol, checker);
4791
4789
  if (!aliasDecl) return [];
4792
4790
  if (ts3.isTypeLiteralNode(aliasDecl.type)) return [];
4793
4791
  const aliasFieldType = resolveTypeNode(
@@ -4810,6 +4808,18 @@ function extractTypeAliasConstraintNodes(typeNode, checker, file, extensionRegis
4810
4808
  );
4811
4809
  return constraints;
4812
4810
  }
4811
+ function getAliasedSymbol(symbol, checker) {
4812
+ if (symbol === void 0) {
4813
+ return void 0;
4814
+ }
4815
+ return symbol.flags & ts3.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
4816
+ }
4817
+ function getAliasedTypeAliasDeclaration(symbol, checker) {
4818
+ return getAliasedSymbol(symbol, checker)?.declarations?.find(ts3.isTypeAliasDeclaration);
4819
+ }
4820
+ function getTypeAliasDeclarationFromTypeReference(typeNode, checker) {
4821
+ return getAliasedTypeAliasDeclaration(checker.getSymbolAtLocation(typeNode.typeName), checker);
4822
+ }
4813
4823
  function provenanceForNode(node, file) {
4814
4824
  const sourceFile = node.getSourceFile();
4815
4825
  const { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart());