@player-tools/xlr-converters 0.3.0-next.1 → 0.3.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.js +10 -1
- package/dist/index.esm.js +10 -1
- package/package.json +3 -3
- package/src/ts-to-xlr.ts +19 -1
package/dist/index.cjs.js
CHANGED
|
@@ -120,6 +120,9 @@ class TsConverter {
|
|
|
120
120
|
} else {
|
|
121
121
|
resultingNode = this.tsLiteralToType(variable.initializer);
|
|
122
122
|
}
|
|
123
|
+
if (resultingNode.type === "function" || resultingNode.type === "ref") {
|
|
124
|
+
resultingNode = __spreadProps(__spreadValues$1({}, resultingNode), { name: variable.name.getText() });
|
|
125
|
+
}
|
|
123
126
|
return __spreadValues$1({
|
|
124
127
|
name: variable.name.getText()
|
|
125
128
|
}, resultingNode);
|
|
@@ -412,7 +415,13 @@ class TsConverter {
|
|
|
412
415
|
}
|
|
413
416
|
}
|
|
414
417
|
const functionReturnType = this.context.typeChecker.getTypeAtLocation(functionCall);
|
|
415
|
-
|
|
418
|
+
let syntheticNode = this.context.typeChecker.typeToTypeNode(functionReturnType, document, void 0);
|
|
419
|
+
if (ts__default["default"].isArrowFunction(functionCall)) {
|
|
420
|
+
const syntheticWithParameters = __spreadProps(__spreadValues$1({}, syntheticNode), {
|
|
421
|
+
parameters: functionCall.parameters
|
|
422
|
+
});
|
|
423
|
+
syntheticNode = syntheticWithParameters;
|
|
424
|
+
}
|
|
416
425
|
if (syntheticNode) {
|
|
417
426
|
if (ts__default["default"].isTypeReferenceNode(syntheticNode) && ts__default["default"].isIdentifier(syntheticNode.typeName)) {
|
|
418
427
|
const { typeName } = syntheticNode;
|
package/dist/index.esm.js
CHANGED
|
@@ -112,6 +112,9 @@ class TsConverter {
|
|
|
112
112
|
} else {
|
|
113
113
|
resultingNode = this.tsLiteralToType(variable.initializer);
|
|
114
114
|
}
|
|
115
|
+
if (resultingNode.type === "function" || resultingNode.type === "ref") {
|
|
116
|
+
resultingNode = __spreadProps(__spreadValues$1({}, resultingNode), { name: variable.name.getText() });
|
|
117
|
+
}
|
|
115
118
|
return __spreadValues$1({
|
|
116
119
|
name: variable.name.getText()
|
|
117
120
|
}, resultingNode);
|
|
@@ -404,7 +407,13 @@ class TsConverter {
|
|
|
404
407
|
}
|
|
405
408
|
}
|
|
406
409
|
const functionReturnType = this.context.typeChecker.getTypeAtLocation(functionCall);
|
|
407
|
-
|
|
410
|
+
let syntheticNode = this.context.typeChecker.typeToTypeNode(functionReturnType, document, void 0);
|
|
411
|
+
if (ts.isArrowFunction(functionCall)) {
|
|
412
|
+
const syntheticWithParameters = __spreadProps(__spreadValues$1({}, syntheticNode), {
|
|
413
|
+
parameters: functionCall.parameters
|
|
414
|
+
});
|
|
415
|
+
syntheticNode = syntheticWithParameters;
|
|
416
|
+
}
|
|
408
417
|
if (syntheticNode) {
|
|
409
418
|
if (ts.isTypeReferenceNode(syntheticNode) && ts.isIdentifier(syntheticNode.typeName)) {
|
|
410
419
|
const { typeName } = syntheticNode;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@player-tools/xlr-converters",
|
|
3
|
-
"version": "0.3.0
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"typescript": "4.8.4"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@player-tools/xlr": "0.3.0
|
|
13
|
-
"@player-tools/xlr-utils": "0.3.0
|
|
12
|
+
"@player-tools/xlr": "0.3.0",
|
|
13
|
+
"@player-tools/xlr-utils": "0.3.0",
|
|
14
14
|
"@babel/runtime": "7.15.4"
|
|
15
15
|
},
|
|
16
16
|
"main": "dist/index.cjs.js",
|
package/src/ts-to-xlr.ts
CHANGED
|
@@ -177,6 +177,7 @@ export class TsConverter {
|
|
|
177
177
|
const variableDeclarations = node.declarationList.declarations;
|
|
178
178
|
if (variableDeclarations.length === 1) {
|
|
179
179
|
const variable = variableDeclarations[0];
|
|
180
|
+
|
|
180
181
|
if (variable.initializer) {
|
|
181
182
|
let resultingNode;
|
|
182
183
|
if (
|
|
@@ -191,6 +192,13 @@ export class TsConverter {
|
|
|
191
192
|
resultingNode = this.tsLiteralToType(variable.initializer);
|
|
192
193
|
}
|
|
193
194
|
|
|
195
|
+
// If resultingNode is a reference to a function or custom primitive and not a concrete value
|
|
196
|
+
// we need to update the name to be the name of the exporting variable
|
|
197
|
+
// not the name of the identifier its aliasing
|
|
198
|
+
if (resultingNode.type === 'function' || resultingNode.type === 'ref') {
|
|
199
|
+
resultingNode = { ...resultingNode, name: variable.name.getText() };
|
|
200
|
+
}
|
|
201
|
+
|
|
194
202
|
return {
|
|
195
203
|
name: variable.name.getText(),
|
|
196
204
|
...resultingNode,
|
|
@@ -629,12 +637,22 @@ export class TsConverter {
|
|
|
629
637
|
const functionReturnType =
|
|
630
638
|
this.context.typeChecker.getTypeAtLocation(functionCall);
|
|
631
639
|
|
|
632
|
-
|
|
640
|
+
let syntheticNode = this.context.typeChecker.typeToTypeNode(
|
|
633
641
|
functionReturnType,
|
|
634
642
|
document,
|
|
635
643
|
undefined
|
|
636
644
|
);
|
|
637
645
|
|
|
646
|
+
// Synthetic node loses parameter location information, and text making it unable
|
|
647
|
+
// to get the parameter name in tsNodeToType
|
|
648
|
+
if (ts.isArrowFunction(functionCall)) {
|
|
649
|
+
const syntheticWithParameters = {
|
|
650
|
+
...syntheticNode,
|
|
651
|
+
parameters: functionCall.parameters,
|
|
652
|
+
};
|
|
653
|
+
syntheticNode = syntheticWithParameters as unknown as ts.TypeNode;
|
|
654
|
+
}
|
|
655
|
+
|
|
638
656
|
if (syntheticNode) {
|
|
639
657
|
if (
|
|
640
658
|
ts.isTypeReferenceNode(syntheticNode) &&
|