Skip to content
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

compiler error in TS 1.8 #15

Closed
joesonw opened this issue Nov 28, 2015 · 9 comments
Closed

compiler error in TS 1.8 #15

joesonw opened this issue Nov 28, 2015 · 9 comments

Comments

@joesonw
Copy link

joesonw commented Nov 28, 2015

error TS2339: Property 'getMetadata' does not exist on type 'typeof Reflect'.

Reflect.getMetadata("design:type", target, key);
@mcwebdev
Copy link

Having same issue withTS2339 Property 'getOwnMetadata' does not exist on type 'typeof Reflect'. TypeScript

@rbuckton
Copy link
Owner

@joesonw Are you using import "reflect-metadata"; at the top of the file?

@mcwebdev
Copy link

Is that a RequireJS import? I am using Angular2 with TS. When I open the Reflect.ts it says in the comments that it has no imports/exports. I am not sure how this es6 shim is getting made but it seems getOwnMetadata needs to be added. declare namespace Reflect { function apply(target: Function, thisArgument: any, argumentsList: ArrayLike<any>): any; function construct(target: Function, argumentsList: ArrayLike<any>): any; function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; function deleteProperty(target: any, propertyKey: PropertyKey): boolean; function enumerate(target: any): IterableIteratorShim<any>; function get(target: any, propertyKey: PropertyKey, receiver?: any): any; function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor; function getPrototypeOf(target: any): any; function has(target: any, propertyKey: PropertyKey): boolean; function isExtensible(target: any): boolean; function ownKeys(target: any): Array<PropertyKey>; function preventExtensions(target: any): boolean; function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean; function setPrototypeOf(target: any, proto: any): boolean; }

@rbuckton
Copy link
Owner

The easiest way to load the shim is to add this to the top of any module:

import "reflect-medata";

This will both load the type information for TypeScript when it resolves the module name at compile time, and will insure that the shim is installed at runtime.

@judsonmusic
Copy link

judsonmusic commented Apr 21, 2016

@mcwebdev and I are both dealing with this on a current project. These are the scripts being loaded...

<script src="node_modules/reflect-metadata/Reflect.js"></script> <script src="node_modules/angular2/bundles/angular2-polyfills.js"></script> <script src="node_modules/systemjs/dist/system.src.js"></script> <script src="node_modules/rxjs/bundles/Rx.js"></script> <script src="node_modules/angular2/bundles/angular2.dev.js"></script> <script src="node_modules/angular2/bundles/router.dev.js"></script> <script src="node_modules/angular2/bundles/http.dev.js"></script>

When adding the suggested import statement to the top of the app.component.ts file, i get and error cannot find localhost:13245/reflect-metadata.js

If I put a mapping in system.config then it starts looking for crypto.js etc. It seems that the ie6 shim is interfering because it has a namespace of reflect that does not have property getOwnMetadata.

Is this a loading order issue? Can someone be more specific on how to solve? The goal is to have Reflect.getOwnMetadata resolve to the property provided by reflect-metadata.js

@rbuckton
Copy link
Owner

If you are loading via <script/> tag, you will need to add a reference to the declaration file directly. You can do this either with a triple-slash reference or through tsconfig.json.

@sqlsolver
Copy link

I added the import statement to the top of the app plus a mapping to system.config and am getting a similar error, that 'Reflect.getOwnMetadata is not a function.'

Here's what's showing in the Chrome dev tools console:
zone.js:323 Error: (SystemJS) TypeError: Reflect.getOwnMetadata is not a function at PropDecorator (http://easyofficeforms.com/easyOfficeForms/node_modules/@angular/core/bundles/core.umd.js:2817:40) at __decorate (http://easyofficeforms.com/easyOfficeForms/node_modules/ng2-bootstrap/components/accordion/accordion.component.js:5:110) at eval (http://easyofficeforms.com/easyOfficeForms/node_modules/ng2-bootstrap/components/accordion/accordion.component.js:39:5) at Object.eval (http://easyofficeforms.com/easyOfficeForms/node_modules/ng2-bootstrap/components/accordion/accordion.component.js:55:2) at eval (http://easyofficeforms.com/easyOfficeForms/node_modules/ng2-bootstrap/components/accordion/accordion.component.js:58:4) at eval (http://easyofficeforms.com/easyOfficeForms/node_modules/ng2-bootstrap/components/accordion/accordion.component.js:59:3) Evaluating http://easyofficeforms.com/easyOfficeForms/node_modules/ng2-bootstrap/components/accordion/accordion.component.js Evaluating http://easyofficeforms.com/easyOfficeForms/node_modules/ng2-bootstrap/components/accordion.js Evaluating http://easyofficeforms.com/easyOfficeForms/node_modules/ng2-bootstrap/ng2-bootstrap.js Error loading http://easyofficeforms.com/easyOfficeForms/app/EOFapp.ts
http://easyofficeforms.com

If I remove the entry from system.config then reflect-metadata is not found.

@sqlsolver
Copy link

Doesn't appear to be a ReflectDecorators or systemjs issue. Created a second app without ng2-bootstrap and it works fine. Created new ng2-bootstrap issue.

@rbuckton
Copy link
Owner

rbuckton commented Aug 9, 2016

Since this does not seem to be an issue with reflect-metadata, I am closing this issue. If you feel this is in error, please reopen with comments.

@rbuckton rbuckton closed this as completed Aug 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants