-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
25667 - getModifiedTime has wrong return type #25680
Conversation
177efea
to
550710d
Compare
@sheetalkamat and @Andy-MS can you please review this change. |
src/compiler/tsbuild.ts
Outdated
@@ -1058,7 +1063,7 @@ namespace ts { | |||
} | |||
|
|||
const inputTime = host.getModifiedTime(inputFile); | |||
if (inputTime > newestInputFileTime) { | |||
if (inputTime !== undefined && inputTime > newestInputFileTime) { |
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.
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.
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.
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?
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.
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.
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.
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
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.
@sheetalkamat Thoughts?
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.
@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.
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.
@sheetalkamat thank you very much. I'll add changes and re-open PR.
… bug/25667-getmodifiedtime-has-wrong-return-type
428d710
to
8ae163a
Compare
src/compiler/tsbuild.ts
Outdated
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); |
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.
Why cant you have this or with missingFileModifiedTime ?
@sheetalkamat thanks, fixed. |
Fixes #25667