Repository navigation
Move to TypeScript - #1750
Move to TypeScript#1750
Conversation
3589fe1 to
fa0610e
Compare
|
I'll work on this some more tomorrow evening and probably the weekend. 👋 for now. |
|
This WIP PR implements #1735. |
3928990 to
5aafdc6
Compare
| for (const comment of comments) { | ||
| const timestampEl = select('relative-time', comment); | ||
| const timestamp = timestampEl.attributes.datetime.value; | ||
| const timestamp = timestampEl.attributes['datetime'].value; // eslint-disable-line dot-notation |
There was a problem hiding this comment.
I disabled the dot-notation rule here because the type checking fails otherwise. I know it works in JS land, but the types are strict, so it's required to use [] notation because in the generic sense, not every element has an attributes.datetime property.
There was a problem hiding this comment.
I think the correct way would be to cast select<HTMLTimeElement> or whatever element GitHub’s relative-time extends
There was a problem hiding this comment.
You should cast it to the correct element instead, after the “select” call.
There was a problem hiding this comment.
Sounds good. I feel silly for not knowing there was a time element, https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tim. Will cast accordingly.
There was a problem hiding this comment.
Looks like even when it is cast to HTMLTimeElement, it still complains.
It's actually the <relative-time /> web component from github.com/github/time-elements that they're using, so you have no choice but to access it via attributes with the [] notation.
There was a problem hiding this comment.
Maybe the issue is that time actually has a dateTime attribute: https://developer.mozilla.org/en-US/docs/Web/API/HTMLTimeElement (camelcase)
const timestampEl = select<HTMLTimeElement>('relative-time', comment);
const timestamp = timestampEl.attributes.dateTime.value;Does that work?
There was a problem hiding this comment.
|
Made some good progress today. Only one file left to convert in After that I'll enable strict mode and see what still breaks. Hopefully not too much at this point ;) Do you want your webpack config converted to TypeScript as well? All it requires is the |
|
As for the strict mode, if it requires a lot more changes I’d probably suggest to settle this PR first. Making the repo strict could come in a separate round. What do you think? Also I found some solutions in the other PR to be slightly more simple, especially where you use the TailArgs here 😬 |
|
I think webpack’s config can stay JavaScript |
|
Sounds good for strict coming in another round. |
| for (const comment of comments) { | ||
| const timestampEl = select('relative-time', comment); | ||
| const timestamp = timestampEl.attributes.datetime.value; | ||
| const timestamp = timestampEl.attributes['datetime'].value; // eslint-disable-line dot-notation |
There was a problem hiding this comment.
Sounds good. I feel silly for not knowing there was a time element, https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tim. Will cast accordingly.
| for (const comment of comments) { | ||
| const timestampEl = select('relative-time', comment); | ||
| const timestamp = timestampEl.attributes.datetime.value; | ||
| const timestamp = timestampEl.attributes['datetime'].value; // eslint-disable-line dot-notation |
There was a problem hiding this comment.
Looks like even when it is cast to HTMLTimeElement, it still complains.
It's actually the <relative-time /> web component from github.com/github/time-elements that they're using, so you have no choice but to access it via attributes with the [] notation.
02469bb to
e4262e6
Compare
|
I don't know either. I tried something and it failed, even if I reset the changes and then rename the files: 5c41a72 |
|
Hmm. I have to get some ZZZs, but I'll pick the brains of a few colleagues tomorrow to see if they might know what's up. |
|
Tried again a little differently, but same result. It renames the file properly, I commit it and push and I see it's renamed in the PR, but as soon as the next commit comes in that boom, same thing. This time I checked out the file at the exact place where rename fiasco happened ahhh! 😅 |
|
@sindresorhus just curious if you have any ideas as to why we're unable to rename the files properly. From all accounts, I'm doing things correctly which is why I'm a little perplexed. |
|
I think the solution is to just merge as two commits.
This way GitHub won't try to squash/merge the two commits incorrectly. So let's review this the final time and then:
|
|
OK, sounds good. Thanks for all the help. The only thing that is missing is we need the latest |
|
It needs the updated package-lock.json. I can push that if you want. |
|
Git does not have a rename, make a commit without file modification but includes both the add and delete on the file. Git will use horistics to determine the files are the same. |
|
Here's some insight into the issue @bfred-it, |
|
I read that before that “git does not have renames” but it’s kinda wrong considering that a rename can be |
|
Nope no difference, their is no meta data to indicate a rename. As you said, git mv just uses add+remove. I recently had a collegue hit the opposite problem, he had added a new file, copied content from another and deleted the old. Git saw it as a rename but he didn't expect that because that wasn't the operation done. |
|
9f9d178 merged with file changes Now use something like Follow for Github or It turns out you git does have the concept of renames, you just have to keep the changes and the renames in separate commits. |
|
Thanks @nickytonline for the hard work! 🎈 I merged this to allow other PRs to start following the new rules. Further adjustments can be made in a separate PR. And just like that... 1000 commits! 🎂 |
|
Git does have a concept of rename with file modifications, it is just harder which is why I specified to have them separate, and when I looked at the history they were. https://www.quora.com/What-is-the-heuristic-of-Git-for-managing-renamed-files |
|
you can rewrite history where this file was mentioned
https://gist.github.com/trddddd/69f1f134499b4e1aaf84166911a2830c |
|
For those wanting to understand better why git intentionally does not track renames: https://git.wiki.kernel.org/index.php/GitFaq#Why_does_Git_not_.22track.22_renames.3F |







I'm just opening the PR right away @sindresorhus, so that I can get back any feedback from you as I move along.