@suss/adapter-typescript 0.18.0 → 0.19.0

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
@@ -12293,6 +12293,13 @@ function pathAbove(reference) {
12293
12293
  return path13;
12294
12294
  }
12295
12295
  }
12296
+ function readSymbolOf(node) {
12297
+ const parent = node.getParent();
12298
+ if (parent !== void 0 && import_ts_morph56.Node.isShorthandPropertyAssignment(parent)) {
12299
+ return parent.getValueSymbol();
12300
+ }
12301
+ return node.getSymbol();
12302
+ }
12296
12303
  function declaresParameterOf(node, func) {
12297
12304
  if (import_ts_morph56.Node.isParameterDeclaration(node)) {
12298
12305
  return node.getParent() === func;
@@ -12313,7 +12320,7 @@ function parameterReads(func, parameterNames) {
12313
12320
  if (!import_ts_morph56.Node.isIdentifier(node) || !wanted.has(node.getText())) {
12314
12321
  return;
12315
12322
  }
12316
- const declarations = node.getSymbol()?.getDeclarations() ?? [];
12323
+ const declarations = readSymbolOf(node)?.getDeclarations() ?? [];
12317
12324
  if (!declarations.some((decl) => declaresParameterOf(decl, func))) {
12318
12325
  return;
12319
12326
  }
@@ -14027,11 +14034,24 @@ function componentPropsParameters(param, mapping) {
14027
14034
  return {
14028
14035
  name,
14029
14036
  position: mapping.paramPosition,
14030
- role: name,
14037
+ role: bindingRole(element, name),
14031
14038
  typeText: typeText.length > 0 ? typeText : null
14032
14039
  };
14033
14040
  });
14034
14041
  }
14042
+ function bindingRole(element, name) {
14043
+ if (element.getDotDotDotToken() !== void 0) {
14044
+ return "rest";
14045
+ }
14046
+ const property = element.getPropertyNameNode();
14047
+ if (property === void 0) {
14048
+ return name;
14049
+ }
14050
+ if (import_ts_morph61.Node.isStringLiteral(property)) {
14051
+ return property.getLiteralValue();
14052
+ }
14053
+ return property.getText();
14054
+ }
14035
14055
  function extractParameters(func, inputMapping) {
14036
14056
  const params = func.getParameters();
14037
14057
  const result = [];
@@ -14061,11 +14081,10 @@ function extractParameters(func, inputMapping) {
14061
14081
  const boundNames = bindingPatternNames(nameNode);
14062
14082
  if (import_ts_morph61.Node.isObjectBindingPattern(nameNode)) {
14063
14083
  for (const element of nameNode.getElements()) {
14064
- const rest = element.getDotDotDotToken() !== void 0;
14065
14084
  result.push({
14066
14085
  name: element.getName(),
14067
14086
  position: i,
14068
- role: rest ? "rest" : inputMapping.defaultRole ?? element.getName(),
14087
+ role: inputMapping.defaultRole ?? bindingRole(element, element.getName()),
14069
14088
  typeText: null
14070
14089
  });
14071
14090
  }
package/dist/index.js CHANGED
@@ -12299,6 +12299,13 @@ function pathAbove(reference) {
12299
12299
  return path13;
12300
12300
  }
12301
12301
  }
12302
+ function readSymbolOf(node) {
12303
+ const parent = node.getParent();
12304
+ if (parent !== void 0 && Node54.isShorthandPropertyAssignment(parent)) {
12305
+ return parent.getValueSymbol();
12306
+ }
12307
+ return node.getSymbol();
12308
+ }
12302
12309
  function declaresParameterOf(node, func) {
12303
12310
  if (Node54.isParameterDeclaration(node)) {
12304
12311
  return node.getParent() === func;
@@ -12319,7 +12326,7 @@ function parameterReads(func, parameterNames) {
12319
12326
  if (!Node54.isIdentifier(node) || !wanted.has(node.getText())) {
12320
12327
  return;
12321
12328
  }
12322
- const declarations = node.getSymbol()?.getDeclarations() ?? [];
12329
+ const declarations = readSymbolOf(node)?.getDeclarations() ?? [];
12323
12330
  if (!declarations.some((decl) => declaresParameterOf(decl, func))) {
12324
12331
  return;
12325
12332
  }
@@ -14039,11 +14046,24 @@ function componentPropsParameters(param, mapping) {
14039
14046
  return {
14040
14047
  name,
14041
14048
  position: mapping.paramPosition,
14042
- role: name,
14049
+ role: bindingRole(element, name),
14043
14050
  typeText: typeText.length > 0 ? typeText : null
14044
14051
  };
14045
14052
  });
14046
14053
  }
14054
+ function bindingRole(element, name) {
14055
+ if (element.getDotDotDotToken() !== void 0) {
14056
+ return "rest";
14057
+ }
14058
+ const property = element.getPropertyNameNode();
14059
+ if (property === void 0) {
14060
+ return name;
14061
+ }
14062
+ if (Node59.isStringLiteral(property)) {
14063
+ return property.getLiteralValue();
14064
+ }
14065
+ return property.getText();
14066
+ }
14047
14067
  function extractParameters(func, inputMapping) {
14048
14068
  const params = func.getParameters();
14049
14069
  const result = [];
@@ -14073,11 +14093,10 @@ function extractParameters(func, inputMapping) {
14073
14093
  const boundNames = bindingPatternNames(nameNode);
14074
14094
  if (Node59.isObjectBindingPattern(nameNode)) {
14075
14095
  for (const element of nameNode.getElements()) {
14076
- const rest = element.getDotDotDotToken() !== void 0;
14077
14096
  result.push({
14078
14097
  name: element.getName(),
14079
14098
  position: i,
14080
- role: rest ? "rest" : inputMapping.defaultRole ?? element.getName(),
14099
+ role: inputMapping.defaultRole ?? bindingRole(element, element.getName()),
14081
14100
  typeText: null
14082
14101
  });
14083
14102
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suss/adapter-typescript",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "type": "module",
5
5
  "description": "TypeScript adapter for suss — walks source files with ts-morph and emits raw extractions for the suss pipeline.",
6
6
  "keywords": [
@@ -46,10 +46,10 @@
46
46
  "typecheck": "tsc --noEmit"
47
47
  },
48
48
  "dependencies": {
49
- "@suss/behavioral-ir": "0.18.0",
50
- "@suss/datalog": "0.18.0",
51
- "@suss/extractor": "0.18.0",
52
- "@suss/resolution": "0.18.0",
49
+ "@suss/behavioral-ir": "0.19.0",
50
+ "@suss/datalog": "0.19.0",
51
+ "@suss/extractor": "0.19.0",
52
+ "@suss/resolution": "0.19.0",
53
53
  "graphql": "^16.8.0",
54
54
  "picomatch": "^4.0.4",
55
55
  "ts-morph": "^23.0.0"