python2ts 1.4.1 → 1.4.2
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.
|
@@ -2273,11 +2273,10 @@ function transformMemberExpression(node, ctx) {
|
|
|
2273
2273
|
const objCode = transformNode(obj, ctx);
|
|
2274
2274
|
const attrMap = {
|
|
2275
2275
|
__name__: "name",
|
|
2276
|
-
__doc__: "undefined",
|
|
2277
|
-
// JS functions don't have docstrings
|
|
2278
2276
|
__class__: "constructor",
|
|
2279
2277
|
__dict__: "this"
|
|
2280
2278
|
// Rough equivalent
|
|
2279
|
+
// Note: __doc__ is kept as-is since it's a valid JS property name
|
|
2281
2280
|
};
|
|
2282
2281
|
const mappedProp = attrMap[propName] ?? propName;
|
|
2283
2282
|
return `${objCode}.${mappedProp}`;
|
|
@@ -2368,9 +2367,35 @@ function transformDictionaryExpression(node, ctx) {
|
|
|
2368
2367
|
}
|
|
2369
2368
|
function transformTupleExpression(node, ctx) {
|
|
2370
2369
|
const children = getChildren(node);
|
|
2371
|
-
const
|
|
2370
|
+
const elementCodes = [];
|
|
2371
|
+
let hasSpread = false;
|
|
2372
|
+
let i = 0;
|
|
2373
|
+
while (i < children.length) {
|
|
2374
|
+
const child = children[i];
|
|
2375
|
+
if (!child) {
|
|
2376
|
+
i++;
|
|
2377
|
+
continue;
|
|
2378
|
+
}
|
|
2379
|
+
if (child.name === "(" || child.name === ")" || child.name === ",") {
|
|
2380
|
+
i++;
|
|
2381
|
+
continue;
|
|
2382
|
+
}
|
|
2383
|
+
if (child.name === "*" || getNodeText(child, ctx.source) === "*") {
|
|
2384
|
+
const nextChild = children[i + 1];
|
|
2385
|
+
if (nextChild && nextChild.name !== "," && nextChild.name !== ")") {
|
|
2386
|
+
hasSpread = true;
|
|
2387
|
+
elementCodes.push(`...${transformNode(nextChild, ctx)}`);
|
|
2388
|
+
i += 2;
|
|
2389
|
+
continue;
|
|
2390
|
+
}
|
|
2391
|
+
}
|
|
2392
|
+
elementCodes.push(transformNode(child, ctx));
|
|
2393
|
+
i++;
|
|
2394
|
+
}
|
|
2395
|
+
if (hasSpread) {
|
|
2396
|
+
return `[${elementCodes.join(", ")}]`;
|
|
2397
|
+
}
|
|
2372
2398
|
ctx.usesRuntime.add("tuple");
|
|
2373
|
-
const elementCodes = elements.map((el) => transformNode(el, ctx));
|
|
2374
2399
|
return `tuple(${elementCodes.join(", ")})`;
|
|
2375
2400
|
}
|
|
2376
2401
|
function isNegativeIndexLiteral(node, ctx) {
|
package/dist/cli/index.js
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "python2ts",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "AST-based Python to TypeScript transpiler. Convert Python code to clean, idiomatic TypeScript with full type preservation.",
|
|
5
5
|
"homepage": "https://sebastian-software.github.io/python2ts/",
|
|
6
6
|
"repository": {
|