Add stronger typings to jasmine spys#33860
Add stronger typings to jasmine spys#33860sheetalkamat merged 2 commits intoDefinitelyTyped:masterfrom
Conversation
| return `${num} and ${str}`; | ||
| }); | ||
| it('has a typed returnValue', () => { | ||
| // $ExpectType (val: string) => Spy<(num: number, str: string) => string> |
There was a problem hiding this comment.
I could have done:
// $ExpectType string
let argType: Parameters<typeof spyObj.method.and.returnValue>[0];and the same for below but I figured this may be simpler
| spy.calls.first().returnValue; // $ExpectType string | ||
| }); | ||
| it('has a typed callFake', () => { | ||
| // $ExpectType (fn: (num: number, str: string) => string) => Spy<(num: number, str: string) => string> |
There was a problem hiding this comment.
This block can be rewritten as
type FakeFnArg = Parameters<typeof spy.and.callFake>[0]
let args: Parameters<FakeFnArg> // $ExpectType [number, string]
let returnValue: ReturnType<FakeFnArg> // $ExpectType stringLet me know if that's better
EDITThis is now sorted via https://github.com/DefinitelyTyped/DefinitelyTyped/pull/33860/files#diff-964b6bf718830679bd417defc1a8ce48 Previous content: This PR errors with: However if I make that change I then get this error: I'm not sure what to do about that. This may be related to microsoft/dtslint#192 |
|
@kolodny Thank you for submitting this PR! Because this is a new definition, a DefinitelyTyped maintainer will be reviewing this PR in the next few days once the Travis CI build passes. In the meantime, if the build fails or a merge conflict occurs, I'll let you know. Have a nice day! |
|
@kolodny The Travis CI build failed! Please review the logs for more information. Once you've pushed the fixes, the build will automatically re-run. Thanks! |
|
cc @borisyankov @theodorejb @davidparsson @gmoothart @lukas-zech-software @Engineer2B @cyungmann @Roaders @devoto13 @FDIM @pe8ter y'all should have a chance to review this before it goes in, but the bot didn't ping you, since apparently it doesn't recognize a |
|
After 5 days, no one has reviewed the PR 😞. A maintainer will be reviewing the PR in the next few days and will either merge it or request revisions. Thank you for your patience! |
|
I just published |
I added stronger typings for jasmine spys along with the
createSpyObj,spyOnandcallsinterfaces. This relies heavily on typescript 3.1 so I've created atypesVersionsfor that. This was mostly a move operation but the main highlights are at https://github.com/kolodny/DefinitelyTyped/blob/better-jasmine-types-3-1/types/jasmine/ts3.1/jasmine-tests.ts#L1165-L1222I also needed to fix
jasmine-ajax-tests.tssince they attempt to use an incomplete object for thereturnValue(which is something the type system should catch, so yay!)npm test.)npm run lint package-name(ortscif notslint.jsonis present).Provide a URL to documentation or source code which provides context for the suggested changes: <>Increase the version number in the header if appropriate.If you are making substantial changes, consider adding atslint.jsoncontaining{ "extends": "dtslint/dt.json" }.