Skip to content

25667 - getModifiedTime has wrong return type #25680

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

Conversation

a-tarasyuk
Copy link
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 sheetalkamat and a user July 16, 2018 18:50
@mhegazy
Copy link
Contributor

mhegazy commented Jul 16, 2018

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

@@ -1058,7 +1063,7 @@ namespace ts {
}

const inputTime = host.getModifiedTime(inputFile);
if (inputTime > newestInputFileTime) {
if (inputTime !== undefined && inputTime > newestInputFileTime) {
Copy link
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
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

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
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

Choose a reason for hiding this comment

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

@sheetalkamat Thoughts?

Copy link
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
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
const now = new Date();
const outputs = getAllProjectOutputs(proj);
let priorNewestUpdateTime = minimumDate;
for (const file of outputs) {
if (isDeclarationFile(file)) {
priorNewestUpdateTime = newer(priorNewestUpdateTime, compilerHost.getModifiedTime!(file));
const fileModifiedTime = compilerHost.getModifiedTime!(file);
Copy link
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
Contributor Author

@sheetalkamat thanks, fixed.

@mhegazy mhegazy merged commit 00a6417 into microsoft:master Jul 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants