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
@types/jest Use Mock in MockedFunction #50720
Conversation
This change allows `MockedFunction` to be used where `Mock` can be used. I don't think this fundamentally changes `MockedFunction`, just makes it more robust. This would resolve issues where an extended expect method takes a `Mock` type, but the mocking library uses `MockedFunction`. Related issues: extend-chrome/jest-chrome#9 jest-community/jest-extended#292
👋 Hi there! I’ve run some quick measurements against master and your PR. These metrics should help the humans reviewing this PR gauge whether it might negatively affect compile times or editor responsiveness for users who install these typings. Let’s review the numbers, shall we? Comparison details 📊
It looks like nothing changed too much. I won’t post performance data again unless it gets worse. |
@jacksteamdev Thank you for submitting this PR! I see this is your first time submitting to DefinitelyTyped 👋 — I'm the local bot who will help you through the process of getting things through. This is a live comment which I will keep updated. 1 package in this PRCode ReviewsBecause this is a widely-used package, a DT maintainer will need to review it before it can be merged. Status
Once every item on this list is checked, I'll ask you for permission to merge and publish the changes. InactiveThis PR has been inactive for 34 days — it is still unreviewed! Diagnostic Information: What the bot saw about this PR{
"type": "info",
"now": "-",
"pr_number": 50720,
"author": "jacksteamdev",
"headCommitOid": "fe85fdfd985f8ede19974ce4b1cff4a4bf126e37",
"lastPushDate": "2021-02-02T17:08:56.000Z",
"lastActivityDate": "2021-03-07T12:11:40.000Z",
"maintainerBlessed": false,
"hasMergeConflict": false,
"isFirstContribution": true,
"popularityLevel": "Critical",
"pkgInfo": [
{
"name": "jest",
"kind": "edit",
"files": [
{
"path": "types/jest/index.d.ts",
"kind": "definition"
},
{
"path": "types/jest/jest-tests.ts",
"kind": "test"
}
],
"owners": [
"NoHomey",
"jwbay",
"asvetliakov",
"alexjoverm",
"epicallan",
"ikatyang",
"wsmd",
"JamieMason",
"douglasduteil",
"ahnpnl",
"joshuakgoldberg",
"UselessPickles",
"r3nya",
"hotell",
"sebald",
"andys8",
"antoinebrault",
"gstamac",
"ExE-Boss",
"quassnoi",
"Belco90",
"tonyhallett",
"ycmjason",
"devanshj",
"pawfa",
"regevbr",
"gerkindev"
],
"addedOwners": [],
"deletedOwners": [],
"popularityLevel": "Critical"
}
],
"reviews": [],
"ciResult": "pass"
} |
🔔 @NoHomey @jwbay @asvetliakov @alexjoverm @epicallan @ikatyang @wsmd @JamieMason @douglasduteil @ahnpnl @JoshuaKGoldberg @UselessPickles @r3nya @Hotell @sebald @andys8 @antoinebrault @gstamac @ExE-Boss @quassnoi @Belco90 @tonyhallett @ycmjason @devanshj @pawfa @regevbr @GerkinDev — please review this PR in the next few days. Be sure to explicitly select |
I'm not certain this is the correct change. Note that My assumption, after some sleuthing across various PRs over the years, is that DefinitelyTyped/types/jest/index.d.ts Lines 163 to 170 in fe85fdf
Should probably be something more like this: function fn(): Mock;
function fn<F extends (...args: any[]) => any>(implementation?: F): MockedFunction<F>;
function fn<F extends new (...args: any[]) => any>(implementation?: F): MockedClass<F>; DefinitelyTyped/types/jest/index.d.ts Lines 177 to 180 in fe85fdf
Should probably be something more like this (to preserve the type information): function isMockFunction<F extends (...args: any[]) => any>(fn: F): fn is MockedFunction<F>;
function isMockFunction<F extends new (...args: any[]) => any>(fn: F): fn is MockedClass<F>;
function isMockFunction(fn: any): fn is Mock; The only reason Due to the possible repercussions a change like this could have, I would like to have one of the definitions owners weigh in on this PR. I'd also like someone to weigh in on whether |
@rbuckton Totally agree. Thanks for the detailed analysis! Deprecating |
Re-ping @NoHomey, @jwbay, @asvetliakov, @alexjoverm, @epicallan, @ikatyang, @wsmd, @JamieMason, @douglasduteil, @ahnpnl, @JoshuaKGoldberg, @UselessPickles, @r3nya, @Hotell, @sebald, @andys8, @antoinebrault, @gstamac, @ExE-Boss, @quassnoi, @Belco90, @tonyhallett, @ycmjason, @devanshj, @pawfa, @regevbr, @GerkinDev: This PR has been out for over a week, yet I haven't seen any reviews. Could someone please give it some attention? Thanks! |
It has been more than two weeks and this PR still has no reviews. I'll bump it to the DT maintainer queue. Thank you for your patience, @jacksteamdev. (Ping @NoHomey, @jwbay, @asvetliakov, @alexjoverm, @epicallan, @ikatyang, @wsmd, @JamieMason, @douglasduteil, @ahnpnl, @JoshuaKGoldberg, @UselessPickles, @r3nya, @Hotell, @sebald, @andys8, @antoinebrault, @gstamac, @ExE-Boss, @quassnoi, @Belco90, @tonyhallett, @ycmjason, @devanshj, @pawfa, @regevbr, @GerkinDev.) |
@jacksteamdev -- Sounds like this should be closed following @rbuckton's comment and your reply--? |
This change allows
MockedFunction
to be used whereMock
can be used. I don't think this fundamentally changesMockedFunction
, just makes it more robust. This would resolve issues where an extended expect method takes aMock
type, but the mocking library usesMockedFunction
.Related issues:
extend-chrome/jest-chrome#9
jest-community/jest-extended#292
Please fill in this template.
npm test <package to test>
.Select one of these and delete the others:
If changing an existing definition: