-
Notifications
You must be signed in to change notification settings - Fork 13
Fix checks for image duplicates #39
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
Two `URL` objects for the same image URL are not identical, store and compare their `href` attributes (of type string) instead.
Also adapt tsconfig.json to make the type acquisition of VS Code happy.
| "typeRoots": [ | ||
| "node_modules/@types", | ||
| "types", | ||
| ], | ||
| "paths": { | ||
| "*": [ | ||
| "types/*", |
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.
Not sure whether typeRoots makes paths redundant as you seem to use it only for type definitions and always have proper relative or absolute paths for regular module imports. I have not removed it since it probably does the trick in your IDE, but VS Code needs the typeRoots property and acts dumb without it.
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.
No clue. I started doing this with no TS experience, and I've never properly RTFD. The config is sub-optimal anyway, it's leading to implicitly included types which IMO should be implicitly included (like __CoverArt in https://github.com/ROpdebee/mb-userscripts/blob/main/src/lib/MB/__MB__.d.ts, which aliases another type in the src). I'll tinker with it a bit once everything slows down :)
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 discovered https://www.typescriptlang.org/tsconfig/#types while I was looking for the docs of typeRoots. Probably you need to overwrite that option to disable these automatic imports.
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.
It's a bit weird though, since typeRoots apparently only matters for /// <reference types=".." /> directives (per here. To my knowledge, we're never using those directives.
Anyway, if it works for you, I'm fine with it :) I'll be changing the paths anyway and might be splitting up some of the tsconfig files, since I've got a feeling something's not working properly.
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 am just reviewing your changes from #68 and apparently the typeRoots property is indeed not necessary (now). Removing it from tsconfig.json and restarting VS Code does no longer cause problems with relative import type statements. Something must have changed in the mean time, either your recent refactoring or me updating the dependencies has solved the problem. Anyway, I'm happy to remove it again once we are done with these huge PRs.
|
Looks good to me, but could you merge in the latest main and check the The whole URL string -> URL conversion was mainly driven by concerns that the script would be fed URLs with parameters or hashes, e.g. The funny thing is that I knew full-well that I've also go no clue what's with those JS extensions, probably something to do with babel, typescript, node, and the mixing of CJS and ES modules, and trying until something worked. Then changing something else, which then made all of the trial and error useless. Ugh. |
Yes, I noticed this right before I created the pull request. But since you have changed that line in exactly the same way there are no merge conflicts with this PR. I just merged locally and it auto-merged fine indeed. I will push the merge commit now but I guess it just creates unnecessary clutter in the git history, so I can withdraw it again before you merge.
Probably somehow related to the fact that these are (in)directly imported by the build script itself while the extensionless imports are only touched by rollup!? Anyway, never change a running system 😂 |
I think I need some tests as well 😛 |
Dealing with proper URLs instead of URL strings is not always easier, 4ae985d broke the comparison of image URLs and made the use of a
Setkind of pointless:Two
URLobjects for the same image URL are not considered identical, so I changed this to store and compare theURL.hrefattributes (of type string) instead.In addition to that I have two other minor improvements: