Repository navigation
Conversation
e8b5367 to
e8048d5
Compare
There was a problem hiding this comment.
q: Is the cast really necessary here ?
There was a problem hiding this comment.
I thought it was. I was getting the error: SELECT_MULTIPLE_VALUE_ACCESSOR' has or is using name 'ForwardRefFn' from external module "/Users/nick/Code/k3/angular/modules/@angular/core/src/di/forward_ref" but cannot be named.. But just now, going back I realize now all I needed was to import the forwardRefFn. 😶
e8048d5 to
93a47c0
Compare
There was a problem hiding this comment.
Q: I don't see how this type relates to ForwardRef, what about renaming this to Factory<T> ?
WDYT
There was a problem hiding this comment.
Do we need this type at all ?
There was a problem hiding this comment.
No. I just get carried away with naming my types. I was just trying to hint at it's purposed, since it's really just a function that we decorate, and wanted to clearly differentiate it from the type that is returned.
Shall I just change the forwardRef to this: function forwardRef<T>(forwardRefFnSrc: () => T): ForwardRefFn<T>? That definitely seems clear enough 😄
|
One minor question, otherwise LGTM |
93a47c0 to
2a06556
Compare
There was a problem hiding this comment.
return _isForwardRefFn(type) ? type() : type;
There was a problem hiding this comment.
do we need && t.hasOwnProperty('__forward_ref__') here ?
There was a problem hiding this comment.
It does seem redundant. I actually just kept the original check here, so I'm not sure if the original author had some reason for it. Is there some reason we need to ensure that the property is not an inherited one?
There was a problem hiding this comment.
I guess if there's no test for it...
There was a problem hiding this comment.
maybe leave it like this for now... thanks
2a06556 to
adb974b
Compare
|
Should be good to go. |
There was a problem hiding this comment.
Would this work ?
export function forwardRef<T>(typeFactory: () => T): ForwardRefFn<T> {
typeFactory['__forward_ref__'] = forwardRef;
typeFactory['toString'] = function() { return stringify(this()); };
return typeFactory;
}There was a problem hiding this comment.
I'll look at this when I get back to my dev computer. Do we allow implicit any?
There was a problem hiding this comment.
Also, if we use the latest TypeScript I think it's supposed to allow something like this now: forwardRefFn = <ForwardRefFn<T>>forwardRefFn
There was a problem hiding this comment.
I'm changing the name to typeFactory. Not sure I'm clear on what else you're asking for here. Are we accessing object attributes via strings to help prevent minification? Seems like that wouldn't happen.
There was a problem hiding this comment.
oh forget about it... that's ok with this clang-format version
There was a problem hiding this comment.
Ya, the tooling didn't catch it, so I assumed we were good here. 😄
|
one minor nit |
There was a problem hiding this comment.
/cc @mhevery how well do this play with minification ? (ie 'forward_ref') is hardcoded.
Should it be return isFunction(t) && t.__forward_ref__ as ForwardRef === forwardRef;
There was a problem hiding this comment.
Please remove t.hasOwnProperty('__forward_ref__') (which would not play well with minification) & rebase
|
could you please rebase and integrate required changes ? |
|
@vicb Ya, sorry about the delay, was gone on vacation. |
|
No pb Nick, only have time to get back to this PR now |
|
Had some questions in regard to the requested refactor of |
|
Yep, what ? |
|
@vicb ping |
82f1839 to
77ec25d
Compare
|
@vicb Hopefully that'll do 😃 |
|
Hi, |
|
Ya, I'll try to get to this in the next day or so. |
77ec25d to
ee12e03
Compare
Makes `forwardRef` and `resolveForwardRef` return more meaningful types. Now when resolving a forward reference, TypeScript knows what type the returned reference is. Closes angular#11638
ee12e03 to
64b2609
Compare
|
I believe it's good to go. |
|
@tbosch Is anything else needed? |
|
We need to create a branch for v5 before we can land this... |
|
@NickClark @mhevery @vicb What is the status of the task? |
|
Closing pull requests from 2016, sorry this got stale and was never merged. Please open a new one if you still care about this change. |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Please check if the PR fulfills these requirements
What kind of change does this PR introduce? (check one with "x")
What is the current behavior? (You can also link to an open issue here)
#11638
What is the new behavior?
Does this PR introduce a breaking change? (check one with "x")
If this PR contains a breaking change, please describe the impact and migration path for existing applications: ...
Other information:
Makes
forwardRefandresolveForwardRefreturn more meaningful types. Now when resolving a forward reference, TypeScript knows what type the returned reference is.Closes #11638