Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

feature(annotations): add two new types of annotations to optionally be more explicit about the type #96

Merged
merged 6 commits into from
Feb 4, 2015

Conversation

iammerrick
Copy link
Contributor

This is to address minification issues by allowing folks to be more explicit.

@@ -1,17 +1,28 @@
// A bunch of helper functions.
import {
Copy link
Contributor Author

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
else if (clsOrFunction.name) {
return isUpperCase(clsOrFunction.name.charAt(0));
} else {
return Object.keys(clsOrFunction.prototype).length > 0;

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are 2 things:

  1. Reflect.ownKeys(O) (not implemented yet anywhere), but this would be the best
  2. Combination of Object.getOwnPropertyNames(O) and Object.getOwnPropertySymbols(O) --- but you'd have to be careful with getOwnPropertySymbols(O) since it's not ES5.

Copy link
Contributor Author

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?

Copy link
Contributor Author

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. :-)

@iammerrick
Copy link
Contributor Author

@caitp Anything else on this before it can be merged? :-)

if (Object.getOwnPropertySymbols) return keys.concat(Object.getOwnPropertySymbols(O));
return keys;
});


export {
isUpperCase,
isClass,

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.

@tbosch
Copy link

tbosch commented Feb 2, 2015

Hi,
thanks for the PR. However, we are building a new version of DI within the angular/angular project right now, and won't continue the development of DI in this repository. And there we already differentiate between classes and factories.

@iammerrick
Copy link
Contributor Author

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?

@iammerrick
Copy link
Contributor Author

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?

@iammerrick
Copy link
Contributor Author

I'm feeling very frustrated by this experience... :-(

@caitp
Copy link
Contributor

caitp commented Feb 3, 2015

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

@iammerrick
Copy link
Contributor Author

If you plan on publishing an entirely different project under the di on npm this repo should have a warning on it. I misunderstood what you meant when you said that @caitp. Not being used by angular and being deprecated and eventually replaced are different things.

@iammerrick
Copy link
Contributor Author

And thank you @caitp for your help. I apologize to all for my raging. Just very frustrated by this decision.

@caitp
Copy link
Contributor

caitp commented Feb 3, 2015

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 =)

@iammerrick
Copy link
Contributor Author

Oh thats good to know. :-) @tbosch's comment would make one believe otherwise.

@iammerrick
Copy link
Contributor Author

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.

@caitp
Copy link
Contributor

caitp commented Feb 3, 2015

I suppose there's no reason you can't do that so long as the apache license terms are met

@iammerrick
Copy link
Contributor Author

I think I'm going to rewrite a similar lib with vanilla es6.

@vsavkin vsavkin merged commit a52ee97 into angular:master Feb 4, 2015
@tusharmath
Copy link

Yay!

@iammerrick
Copy link
Contributor Author

WAHOO! THANK YOU! @vsavkin

@iammerrick
Copy link
Contributor Author

@vsavkin It seems the latest push to npm is missing the "dist" folder? Does a build need to be run before publishing?

@xmlking
Copy link

xmlking commented Feb 11, 2015

@iammerrick I am getting following error with this code change when transpiled to AMD. Can you change from this.Reflect to Reflect?

Error Cannot read property 'Reflect' of undefined

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;
});

xmlking added a commit to xmlking/di.js that referenced this pull request Feb 11, 2015
xmlking added a commit to xmlking/spa-starter-kit that referenced this pull request Feb 11, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants