-
-
Notifications
You must be signed in to change notification settings - Fork 33
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
fix(metadata): targetKey in Reflect.defineMetadata is optional #33
Conversation
@cmichaelgraham any comments for me? you're the ts guy right |
@doktordirk This looks right to me. Make sure to run the build and doc task locally just to make sure that the d.ts and docs generator process everything correctly. You don't need to commit those generated files though. I'll do that at release. |
i'll do more tests and come back then |
looks good to me too 👍 |
please wait till i've tested more. while the pr is obviously right, the problems is that the types on Reflect aren't used, as only exported functions enter the d.ts file. hence, it seems it doesn't fix the problem. i'm on it though |
Ok, that's a different issues altogether. @cmichaelgraham can you look into this? There may be a bug in the d.ts generator. |
Should be able to take a look at this tonight... |
seems though my issue comes from the reflect polyfill. targetKey===undefined leads to different results in es6 and ts |
since hasOwnProperty of Typescript doesn't work as specifies since 'extends' of Typescript 1.5 doesn't work as specified, on nice solution would be to default targetKey=target.name, since parent and child classes have different names, the problem with interitance would be fixed. as i'd say positive side effect, since you don't use that optional paremeter yourself, (and maybe the Reflect implementation is wrong?), you register under the key 'undefined'. defaulting targetKey to target.name would make look the objects much nicer :). that seems to work fine (by alrge). didn't have any issues with es6, with typescript (again!), however, @autoinject breaks (while inject works fine). i'll have a quick look why's that |
too many problems with above version. i for my part, just use add 'target.name' as targetKey to Metadata.getOrCreateOwn() whenever it comes up for derived classes. |
d.ts updates were correct so I got this merged. |
as currently it isn't marked optional for typescript "undefined" is used for all if no key is given. That's not working.
alternatively setting a default as
targetKey:string = target.name
would work