Open kesemdavid opened 8 years ago
I had a similar problem upgrading to angular2 2.0.1 from 2.0.0-rc5. At the same time I upgraded angular-cli from 1.0.0-beta.11-webpack.2 to 1.0.0-beta.15.
when running 'ng init' i was a bit prescriptive in what I allowed angular-cli to update: one of the things it wanted to change was main.ts, adding the line import './polyfills.ts';
to the top of main.ts fixed it for me.
I'm also getting this error. On the latest version of Angular and not using angular-cli. In my package.json I have: "reflect-metadata": "^0.1.8",
I thought polyfills were no longer used?
Any update on this? I too am having this problem.
I wanted to use reflect-metadata without Angular just to include it in a project with run-time type introspection of class properties, so I tried a very simple example with tsconfig.json target=ES2017, module=2015 and a simple test.ts:
import 'reflect-metadata';
function logType(target : any, key : string) {
var t = Reflect.getMetadata("design:type", target, key);
console.log(`${key} type: ${t.name}`);
}
export class Demo {
@logType
test: Date;
}
console.log(Reflect.getMetadata('design:type', new Demo(), "test"));
And it complains: error TS2339: Property 'getMetadata' does not exist on type 'typeof Reflect'.
The reason is that TypeScript thinks that Reflect means the lib.es2015.reflect.d.ts (because ES2015 also defines Reflect symbol on global namespace).
How do I solve this?
I added the reflect-metadata types and that resolved my problem yarn add --dev @types/reflect-metadata
I ran into this problem inside a lib. I resolved it by following @bashleigh's example and installing the types,
npm i --save @types/reflect-metadata
But also had to add an entry within tsconfig.lib.json:
{
"extends": "../../tsconfig.json",
"compilerOptions": {
...
"types": [
"reflect-metadata"
]
}
}
So i have update to the latest RC7 of angular2 and now im getting this error :
Reflect.getMetadata is not a function
What can I do to fix this issue, I'm using the 0.1.2 version. (Also tried with the latest 0.1.8)
Thanks in advance!