New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(FastCheck): missing namespace on function objects #428
base: main
Are you sure you want to change the base?
Conversation
This fixes the issue, but it likely needs further iteration. Especially in regards to |
Okay, went ahead and made |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, but we need to make this work for namespaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add this crazy test case and make it work:
export function test() {
}
if (true) {
test.skip = () => {};
}
test.skip();
export namespace Test {
export function test() {
}
test.other = () => {};
test.other();
}
export namespace Test {
test.other2 = () => {};
test.other2();
}
This is TypeScript's dts output:
export declare function test(): void;
export declare namespace test {
var skip: () => void;
}
export declare namespace Test {
function test(): void;
namespace test {
var other: () => void;
var other2: () => void;
}
}
export declare namespace Test {
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll save this one for later.
}, | ||
exports: { | ||
"skip": 2, | ||
"prop": 3, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See here how the myFunc
symbol now has these expando properties as exports.
This PR addresses an issue with FastCheck where the following snippet would lead to a type error:
Internally, TypeScript generates a namespace for
it
which tells the compiler that the function has askip
property. Theinteface
itself is interestingly ignored. This lead to us erroring.The solution is to generate the
namespace
declaration which we need to anyway for the dts transform.This matches the exact output that
tsc
generates.Fixes denoland/deno#23276