Questions tagged [reflect-metadata]

68 questions
61
votes
1 answer

What is reflect-metadata in typescript

what are reflect-metadata and its purpose? What is syntax and purpose of using reflect-metadata? Can some one provide the example for better understanding of the same? How can be the reflect metadata helpful in implementing decorators in typescript.
Mantu Nigam
  • 2,593
  • 4
  • 20
  • 38
10
votes
3 answers

Angular4 core.es5.js Uncaught reflect-metadata shim is required when using class decorators

After upgrading my pre-existing project to Angular 4 and Angular/CLI 1.0 I'm getting this error: core.es5.js:354 Uncaught reflect-metadata shim is required when using class decorators I've compared my project to a fresh ng new and they appear alike…
Mikeumus
  • 2,440
  • 5
  • 32
  • 54
7
votes
2 answers

Get return type with reflect-metadata , when return type is Promise of something

When function return type is Promise , how can i get it with reflection? If i just do Reflect.getMetadata("design:returntype", target, key) it's return just Promise, so there is a way to know that is Promise of…
yantrab
  • 1,857
  • 21
  • 36
7
votes
1 answer

What's the difference between Reflect.getMetadata and Reflect.getOwnMetadata?

As said in the title: the reflect-metadata API provides a getMetadata method and a getOwnMetadata - what's the difference here? Same goes for hasOwnMetadata, etc.
nehalist
  • 1,236
  • 13
  • 35
7
votes
1 answer

How to access class metadata from method decorator

I'm having two decorators. A class decorator and a method decorator. The class decorator defines metadata which I want to access in the method decorator. ClassDecorator: function ClassDecorator(topic?: string): ClassDecorator { return (target)…
tmuecksch
  • 5,045
  • 3
  • 33
  • 55
6
votes
2 answers

@Reflect.metadata generates error TS1238: Unable to resolve signature of class decorator when called as an expression

I tried to apply the @Reflect.metadata decorator to a TypeScript class, following the example on lines 82-84 of reflect-metadata.d.ts: /// @Reflect.metadata('key', 0) class C…
Michael Liu
  • 44,833
  • 12
  • 104
  • 136
4
votes
2 answers

typeORM: "message": "Data type \"Object\" in \"..." is not supported by \"postgres\" database."

Given the following entity definition: @Entity() export class User extends BaseEntity { @Column({ nullable: true }) name!: string | null; @Column() age!: number; } The following error appears: typeORM: "message": "Data type \"Object\"…
silicakes
  • 4,490
  • 2
  • 23
  • 33
4
votes
1 answer

Typescript decorators + Reflect metadata

I'm using a property decorator Field which pushes its' key to a fields Reflect metadata property: export function Field(): PropertyDecorator { return (target, key) => { const fields = Reflect.getMetadata('fields', target) || []; …
nomadoda
  • 2,740
  • 2
  • 22
  • 36
4
votes
1 answer

how can I get the name of property, to which [(ngModel)] is binded? Angular6

I have following custom component How Can I get the property name from class in this case "prop1"? @Component({ selector: 'form-text', template: `
Michael
  • 84
  • 6
4
votes
1 answer

Typescript emits no decorator metadata

I have a typescript project and would like to inspect some objects. So I installed reflect-metadata, enabled experimentalDeorators and emitDecoratorMetadata in tsconfig.json. Then I have this code: import 'reflect-metadata'; class Bla { thing:…
Tim-Erwin
  • 1,061
  • 1
  • 10
  • 28
4
votes
1 answer

Why typeorm needs "reflect metadata"

I'm a software student and i'm currently learning typescript with node. Reading about typeorm i saw that reflect-metadata package is vital in order to typeorm works. If someone knows the reason I would really apprectiate know it. Thanks in advice.
Erik
  • 97
  • 2
  • 8
4
votes
1 answer

Why is reflect-metadata only working when using a decorator?

Without decorators the metadata is lost - but why? const Baz = () : ClassDecorator => { return target => {} } class Bar {} @Baz() class Foo { constructor(bar: Bar) {} } console.log(Reflect.getMetadata('design:paramtypes', Foo)); This returns…
nehalist
  • 1,236
  • 13
  • 35
4
votes
0 answers

get List of reflect-metadata decorated fields of class

I'm using reflect-metadata with typescript. I composed my own property decorator and it's called Field. How to get list of fields/properties, which are decorated by Field, of any type. For example: I want to get ProductID, ProductName field with…
4
votes
2 answers

In angular cli how can you add meta data to routes e.g. title and description tags

In angular cli how can you add meta data to routes e.g. title and description tags? These are my routes: import { Route} from '@angular/router'; import { HomeComponent } from './home.component'; export const HomeRoutes: Route[] = [ { path:…
AngularM
  • 13,932
  • 27
  • 78
  • 151
4
votes
3 answers

Trying to configure a new webpack + angular2 project and I'm getting error TS2384: Overload signatures must all be ambient or non-ambient

I'm trying to configure a new webpack + angular2 project and I'm getting some errors: When I use "npm start", I got a lot of errors like this: ERROR in ./~/reflect-metadata/Reflect.ts (953,21): error TS2384: Overload signatures must all be ambient…
Guilherme Chiara
  • 674
  • 1
  • 9
  • 15
1
2 3 4 5