Skip to content

25667 - getModifiedTime has wrong return type#25680

Merged
mhegazy merged 4 commits into
microsoft:masterfrom
a-tarasyuk:bug/25667-getmodifiedtime-has-wrong-return-type
Jul 20, 2018
Merged

25667 - getModifiedTime has wrong return type#25680
mhegazy merged 4 commits into
microsoft:masterfrom
a-tarasyuk:bug/25667-getmodifiedtime-has-wrong-return-type

Conversation

@a-tarasyuk
Copy link
Copy Markdown
Contributor

Fixes #25667

@a-tarasyuk a-tarasyuk force-pushed the bug/25667-getmodifiedtime-has-wrong-return-type branch from 177efea to 550710d Compare July 16, 2018 10:39
@mhegazy mhegazy requested review from a user and sheetalkamat July 16, 2018 18:50
@mhegazy
Copy link
Copy Markdown
Contributor

mhegazy commented Jul 16, 2018

@sheetalkamat and @Andy-MS can you please review this change.

Comment thread src/compiler/tsbuild.ts Outdated

const inputTime = host.getModifiedTime(inputFile);
if (inputTime > newestInputFileTime) {
if (inputTime !== undefined && inputTime > newestInputFileTime) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you do a single check up-front? Plus, it doesn't seem like we're now actually handling undefined, we're just doing observably nothing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, will move. Maybe would be better to set a default value in order to avoid checking on undefined, like it was done in this case https://github.com/a-tarasyuk/TypeScript/blob/550710d2a2ce019dfc7ba8120b112e635fb5d9dc/src/compiler/sys.ts#L306. what do you think?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we haven't run into undefined errors before, we're likely always be passing valid paths. So dropping every exception at the implementation of function getModifiedTime using catch (e) { return undefined; } was probably the wrong choice in the first place.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition has been changed because the program uses https://github.com/a-tarasyuk/TypeScript/blob/550710d2a2ce019dfc7ba8120b112e635fb5d9dc/src/compiler/program.ts#L194 sys.getModifiedTime where has been added undefined

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sheetalkamat Thoughts?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Andy-MS we shouldnt assume that getModifiedTime would be called only on present files.
@a-tarasyuk You are on right track. Please use inputTime = host.getModifiedTime(inputFile) || missingFileModifiedTime; instead of additional checks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sheetalkamat thank you very much. I'll add changes and re-open PR.

@a-tarasyuk a-tarasyuk closed this Jul 18, 2018
@a-tarasyuk a-tarasyuk reopened this Jul 20, 2018
@a-tarasyuk a-tarasyuk force-pushed the bug/25667-getmodifiedtime-has-wrong-return-type branch from 428d710 to 8ae163a Compare July 20, 2018 07:18
Comment thread src/compiler/tsbuild.ts Outdated
for (const file of outputs) {
if (isDeclarationFile(file)) {
priorNewestUpdateTime = newer(priorNewestUpdateTime, compilerHost.getModifiedTime!(file));
const fileModifiedTime = compilerHost.getModifiedTime!(file);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why cant you have this or with missingFileModifiedTime ?

@a-tarasyuk
Copy link
Copy Markdown
Contributor Author

@sheetalkamat thanks, fixed.

@mhegazy mhegazy merged commit 00a6417 into microsoft:master Jul 20, 2018
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants