-
-
Notifications
You must be signed in to change notification settings - Fork 835
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
Convert extend util to TypeScript #2928
Conversation
Out of curiosity, what's the reasoning behind stating the file extension? Is it just to fix typings so that they work properly? |
@davwheat Yes. We currently have an |
Currently fixing issues with my proxifyCompat changes, as they break imports of e.g. tags, and others. EDIT: ^ Fixed |
6488eec
to
4852005
Compare
what happened here |
Rebased onto master |
I'd say that for something like this (utility types), we should declare them in the |
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.
LGTM, let's run prettier and revert the regex change, then good to go!
1.1 actually, since it was merged into master and not I am not well informed to know if it's something that needs to be in 1.0.5 and not wait 1.1 |
Oops. I'd say we should stick it in 1.0.5 if we can. It's just a developer improvement and waiting a whole release cycle to provide it seems pointless. |
I would prefer to keep patch releases focused on bugfixes tbh. |
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'm going to dismiss my review as I've contributed a fair bit to this PR.
I don't believe that's necessary. That being said, @datitisev could you confirm that you approve of the changes? |
@askvortsov1 I... think? I mean now I understand the |
In those cases, wouldn't we want to modify the prototype directly? |
@askvortsov1 Not if it has the potential to exist but its optional? Cause then you can take advantage of the override... I think my main example was |
Wdym by "take advantage of the override"? Are there any advantages compared to directly editing the prototype? |
@askvortsov1 Oh I'm stupid, I'm thinking about extend() and not override() EDIT: wait no i did say extend, i think i need sleep... what is going on In extend(options, 'config', (result, xhr) => xhr.setRequestHeader('X-CSRF-Token', this.session.csrfToken)); Here it would be useful because we account for it not existing. My apologies. |
I think if we allow |
This'd be breaking then tho. And I honestly don't see a problem with the current implementation 🤷♂️ |
Not really, as we'd be changing the type interface, not the implementation. Its not that there's a problem with the current non-restrictive approach as much as we're losing out on the ability to enforce something statically through the type system: in particular, because defining a function as a composition of other functions isn't quite the same as extending an existing function. |
I think this is fine as-is. The highlighted issue, if anything, will likely help people as they may realise they're extending the wrong thing (if it doesn't exist), rather than failing silently. If needed, you can use |
Necessary for extend imports to have proper typings as we also have an unrelated extend/index.js file
b0f7d1a
to
9c1fb86
Compare
Changes proposed in this pull request:
.ts
extension when referring toextend
util in core code.ts
in import path through compat for typings to work properlyextend
util to TypeScriptReviewers should focus on:
extend
compat
proxy to accept.js
,.ts
and.tsx
Screenshot
Confirmed