-
Notifications
You must be signed in to change notification settings - Fork 97
feature(annotations): add two new types of annotations to optionally be more explicit about the type #96
Conversation
@@ -1,17 +1,28 @@ | |||
// A bunch of helper functions. | |||
import { |
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.
@vojtajina For some reason my import is consistently importing undefined. Am I doing something wrong?
…be more explicit about the type chore(annotations): remove unneccessary import fix(annotations): fix cyclic dependency
276cbce
to
d9d58f9
Compare
else if (clsOrFunction.name) { | ||
return isUpperCase(clsOrFunction.name.charAt(0)); | ||
} else { | ||
return Object.keys(clsOrFunction.prototype).length > 0; |
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.
Can we test for prototype first and then function name?
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.
Object.keys()
will only return enumerable properties, and class methods are not going to be enumerable. Object.getOwnPropertyNames()
would work better for those, but would exclude symbol methods, so not that great either.
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.
After the annotations it is falling back to the existing functionality.
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 not sure why you think that matters, it's going to be broken in the future
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.
Just didn't seem relevant for this particular pull request, though I totally agree if you'd like to address that now.
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.
we can't get rid of the fallbacks, but I think we can fix up the Object.keys thing to make sure we can still get at non-enumerable methods once classes ship in M42 or M43
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.
@caitp would you like me to switch over to getOwnPropertyNames
?
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 are 2 things:
Reflect.ownKeys(O)
(not implemented yet anywhere), but this would be the best- Combination of
Object.getOwnPropertyNames(O)
andObject.getOwnPropertySymbols(O)
--- but you'd have to be careful withgetOwnPropertySymbols(O)
since it's not ES5.
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.
Ok. So would you like me to try and address this using number 2 for now and then number 1 in the future?
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.
P.S. You're really smart, I had no idea about this problem. :-)
@caitp Anything else on this before it can be merged? :-) |
if (Object.getOwnPropertySymbols) return keys.concat(Object.getOwnPropertySymbols(O)); | ||
return keys; | ||
}); | ||
|
||
|
||
export { | ||
isUpperCase, | ||
isClass, |
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.
isClass
has not been defined but being returned.
Man that would have been great before I made like all those commits based on @caitp's feedback. :-( Will the other one be published to NPM under the same name? How different is it? Can it be used in Node too? |
Hmmm. I'm thinking maybe I'll fork and maintain an ES6 specific version. I've got an entire application written in this, how different is the other framework? Will it require atscript for use? When can I start using the other framework? I'm effectively deadlocked on this issue till the other framework is released. I am feeling very frustrated that this wasn't communicated earlier? Was it already communicated or did I miss something? |
I'm feeling very frustrated by this experience... :-( |
I did tell you this wasn't being used by angular :) However, I don't think there's any reason why it couldn't be merged. It would just need an owner to ship it on npm |
If you plan on publishing an entirely different project under the |
And thank you @caitp for your help. I apologize to all for my raging. Just very frustrated by this decision. |
it's not clear that it will be replaced by angular/angular's DI implementation (it's a possibility, but that would be the third totally separate DI library published with that name on npm, and that's getting a bit crazy and confusing =) |
Oh thats good to know. :-) @tbosch's comment would make one believe otherwise. |
I think under that looming possibility it makes sense for me to fork the project, remove the Traceur style annotations and maintain a separate repo. I hate the thought of that but it seems irresponsible for me to keep building a businesses product on such unstable ground. I had the impression this project was much more concrete than it is. |
I suppose there's no reason you can't do that so long as the apache license terms are met |
I think I'm going to rewrite a similar lib with vanilla es6. |
Yay! |
WAHOO! THANK YOU! @vsavkin |
@vsavkin It seems the latest push to npm is missing the "dist" folder? Does a build need to be run before publishing? |
@iammerrick I am getting following error with this code change when transpiled to AMD. Can you change from Error var ownKeys = (this.Reflect && Reflect.ownKeys ? Reflect.ownKeys : function OwnKeys(O) {
var keys = Object.getOwnPropertyNames(O);
if (Object.getOwnPropertySymbols) return keys.concat(Object.getOwnPropertySymbols(O));
return keys;
}); |
This is to address minification issues by allowing folks to be more explicit.