-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
Jest: Add setSystemTime and getRealSystemTime fn types #45496
Jest: Add setSystemTime and getRealSystemTime fn types #45496
Conversation
@liamfd Thank you for submitting this PR! I see this is your first time submitting to DefinitelyTyped 👋 — keep an eye on this comment as I'll be updating it with information as things progress. Code 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. Diagnostic Information: What the bot saw about this PR{
"type": "info",
"now": "-",
"pr_number": 45496,
"author": "liamfd",
"owners": [
"NoHomey",
"jwbay",
"asvetliakov",
"alexjoverm",
"epicallan",
"ikatyang",
"wsmd",
"JamieMason",
"douglasduteil",
"ahnpnl",
"joshuakgoldberg",
"UselessPickles",
"r3nya",
"hotell",
"sebald",
"andys8",
"antoinebrault",
"favna",
"gstamac",
"ExE-Boss",
"quassnoi",
"Belco90",
"tonyhallett",
"ycmjason",
"devanshj",
"pawfa",
"regevbr",
"mskelton"
],
"dangerLevel": "ScopedAndTested",
"headCommitAbbrOid": "725c00d",
"headCommitOid": "725c00d5da5651ae54f3b98679d54d28f8279751",
"mergeIsRequested": false,
"stalenessInDays": 7,
"lastCommitDate": "2020-06-16T12:56:12.000Z",
"lastCommentDate": "2020-06-16T12:56:42.000Z",
"reviewLink": "https://github.com/DefinitelyTyped/DefinitelyTyped/pull/45496/files",
"hasMergeConflict": false,
"authorIsOwner": false,
"isFirstContribution": true,
"popularityLevel": "Critical",
"anyPackageIsNew": false,
"packages": [
"jest"
],
"files": [
{
"filePath": "types/jest/index.d.ts",
"kind": "definition",
"package": "jest"
},
{
"filePath": "types/jest/jest-tests.ts",
"kind": "test",
"package": "jest"
}
],
"hasDismissedReview": false,
"ciResult": "pass",
"lastReviewDate": "2020-06-17T15:24:58.000Z",
"reviewersWithStaleReviews": [],
"approvalFlags": 2,
"isChangesRequested": false
} |
🔔 @NoHomey @jwbay @asvetliakov @alexjoverm @epicallan @ikatyang @wsmd @JamieMason @douglasduteil @ahnpnl @JoshuaKGoldberg @UselessPickles @r3nya @Hotell @sebald @andys8 @antoinebrault @favna @gstamac @ExE-Boss @quassnoi @Belco90 @tonyhallett @ycmjason @devanshj @pawfa @regevbr @mskelton - please review this PR in the next few days. Be sure to explicitly select |
/** | ||
* Set the current system time used by fake timers. Simulates a user | ||
* changing the system clock while your program is running. It affects the | ||
* current time but it does not in itself cause e.g. timers to fire; they | ||
* will fire exactly as they would have done without the call to | ||
* jest.setSystemTime(). | ||
* | ||
* > Note: This function is only available when using modern fake timers | ||
* > implementation | ||
*/ |
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.
I tried to follow the comment patterns I observed elsewhere in this file, I just copy pasted this comment and the one below straight out of jest's docs.
types/jest/index.d.ts
Outdated
* > Note: This function is only available when using modern fake timers | ||
* > implementation | ||
*/ | ||
function setSystemTime(now?: number | Date): void; |
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.
As mentioned in the PR description, jest currently types this as:
function setSystemTime(now?: number): void;
I have a PR open to expand it to support Date
, given that under the hood setSystemTime
is calling a function that accepts both. If they do not want to support Date
, I will remove it here.
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.
Perhaps we can hold off on adding support for Date
until the other PR is merged to keep things consistent and work as intended? Once that other PR is merged and a newer version of Jest is released with the Date
support, we can then update the types here to reflect that latest changes?
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.
Sounds good to me
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.
Thanks for the PR @liamfd! This looks good overall. I left one comment suggesting that we hold off on adding support for Date
for now.
types/jest/index.d.ts
Outdated
* > Note: This function is only available when using modern fake timers | ||
* > implementation | ||
*/ | ||
function setSystemTime(now?: number | Date): void; |
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.
Perhaps we can hold off on adding support for Date
until the other PR is merged to keep things consistent and work as intended? Once that other PR is merged and a newer version of Jest is released with the Date
support, we can then update the types here to reflect that latest changes?
@liamfd One or more reviewers has requested changes. Please address their comments. I'll be back once they sign off or you've pushed new commits or comments. If you disagree with the reviewer's comments, you can "dismiss" the review using GitHub's review UI. Thank you! |
👋 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. |
8d9e2d8
to
725c00d
Compare
@wsmd Thank you for reviewing this PR! The author has pushed new commits since your last review. Could you take another look and submit a fresh review? |
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.
Thanks @liamfd!
I just published |
…ed#45496) * feat: add setSystemTime and getRealSystemTime to jest types * test: jest setSystemTime and getRealSystemTime * feat: remove Date from setSystemTime types while not yet officially supported
Please fill in this template.
npm test
.)npm run lint package-name
(ortsc
if notslint.json
is present).If changing an existing definition:
26.0
and if my jest PR is accepted I would assume it would be a patch release.tslint.json
containing{ "extends": "dtslint/dt.json" }
. If for reason the any rule need to be disabled, disable it for that line using// tslint:disable-next-line [ruleName]
and not for whole package so that the need for disabling can be reviewed.