-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
refactor(is-file): Convert to TypeScript #23093
Conversation
? Array.isArray(relativePath) | ||
? relativePath.map(withDir) | ||
: withDir(relativePath) | ||
: null |
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 don't think this check is relevant anymore, possibly ever. getAbsolutePath
is called from getFilePath
, and the relativePath
parameter is a value return from slash
in gatsby-core-utils
which is defined as returning a string
. As such, I think that Array.isArray
will always return false
.
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.
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 think you're right. Let's try not to make any more semantic changes in TS convert PR's than we have to. Then in a followup diff refactor the code because it looks to me like this file can use a little cleanup and modernization.
5618f8e
to
b005f0e
Compare
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 hope I caught everything correctly. In particular, please look into Node
vs IGatsbyNode
. I think we want to use the latter for everything in this PR.
If you rebase past master you won't have to worry about Loki anymore, either. Thanks!
b005f0e
to
d806beb
Compare
Rebased and updated. I put the while loop changes into their own commit. |
Apologies, this dropped off of my todo list to keep it updated. Remerged up-to-date after your recent 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.
Yeah this looks good.
Do you want to make the ?.
??
change or leave it like this?
? Array.isArray(relativePath) | ||
? relativePath.map(withDir) | ||
: withDir(relativePath) | ||
: null |
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 think you're right. Let's try not to make any more semantic changes in TS convert PR's than we have to. Then in a followup diff refactor the code because it looks to me like this file can use a little cleanup and modernization.
@chooban Thank you! 💜 |
Description
Converts
src/schema/infer/is-file.js
to TypeScript.Related Issues
References #21995
Unfortunately, no tests. I would be happy to add some, even do a prequel PR in JS, if someone could point me at a similar one which creates a NodeStore.Turns out there is test coverage, just not a unit test. If I run the full test suite then the file has good coverage from somewhere!
The order of functions in the file has change as the linter was complaining about declaration order. I guess that's a new check in TS compared to JS.I redid the conversion with the functions in the same order in the hope that it would show as a diff rather than delete and add, but no such luck.
I've put a few comments in-line in the PR to outline a few issues.