Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion type-generation/src/astToIR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,6 @@ export class Converter {
const typeAliasDecl = tempFile.getTypeAliases()[0];
const dummyTypeNode = typeAliasDecl.getTypeNode()!;
const res = this.typeToIR(dummyTypeNode, optional);
this.popNameContext();
// Don't remove the temp file, it causes crashes. TODO: Fix this?
return res;
};
Expand Down
29 changes: 29 additions & 0 deletions type-generation/tests/a.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1352,6 +1352,35 @@ describe("emit", () => {
"def f(type_: str, /, *, type: str, payload: int | float) -> None: ...",
);
});
it("destructure getProp regression test", () => {
// At some point we had an extra popNameContext() in sigToIRDestructure()
// and this test failed.
const res = emitFile(`
type Q = {a: string} & {
f(options?: {
x: number | string;
}): void;
};
declare function q(): Q;
`);
assert.strictEqual(
removeTypeIgnores(res.slice(1).join("\n\n")),
dedent(`
type Q = Q_iface

def q() -> Q: ...

class Q__Intersection0_iface(Protocol):
a: str = ...

class Q__Intersection1_iface(Protocol):
def f(self, /, *, x: str | int | float) -> None: ...

class Q_iface(Q__Intersection1_iface, Q__Intersection0_iface, Protocol):
pass
`).trim(),
);
});
});
describe("Type literals", () => {
it("simple", () => {
Expand Down