Questions tagged [reflect-metadata]
83 questions
                    
                    106
                    
            votes
                
                2 answers
            
        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
        
- 3,690
 - 7
 - 24
 - 41
 
                    25
                    
            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
        
- 6,364
 - 3
 - 28
 - 39
 
                    12
                    
            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,434
 - 18
 - 45
 
                    10
                    
            votes
                
                1 answer
            
        Why does TypeORM need reflect-metadata?
I'm currently learning TypeScript with Node. Reading about TypeORM, I saw that the reflect-metadata package is needed for TypeORM to work. What is the reason for this package being needed?
        
        Erik
        
- 159
 - 2
 - 11
 
                    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
        
- 3,570
 - 9
 - 40
 - 65
 
                    9
                    
            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
        
- 6,222
 - 6
 - 40
 - 61
 
                    8
                    
            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
        
- 2,482
 - 4
 - 31
 - 52
 
                    7
                    
            votes
                
                2 answers
            
        Why can't reflect-metadata be used in vite
import "reflect-metadata"
function validate(target: any) {
  let paramtypes = Reflect.getMetadata("design:paramtypes", target);
  console.log(paramtypes);  // undefined
}
@validate
class Log {
  constructor(public readonly xx: string) {}
}
Hit me…
        
        januw a
        
- 2,056
 - 5
 - 18
 - 39
 
                    7
                    
            votes
                
                1 answer
            
        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…
        
        dvl Batdelger
        
- 151
 - 1
 - 11
 
                    6
                    
            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
        
- 4,561
 - 3
 - 30
 - 45
 
                    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
        
- 52,147
 - 13
 - 117
 - 150
 
                    5
                    
            votes
                
                3 answers
            
        After typescript update 2.3.4 => 2.4.2 i get compilation error "Cannot find type definition file for 'reflect-metadata'."
I have a React / Mobex application written in TypeScript, built by Webpack 1. After updating TypeScript version from 2.3.4 to 2.4.2 i get an error
ERROR in C:\myproject\tsconfig.json
error TS2688: Cannot find type definition file for…
        
        Ivan Koshelev
        
- 3,830
 - 2
 - 30
 - 50
 
                    5
                    
            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,434
 - 18
 - 45
 
                    4
                    
            votes
                
                0 answers
            
        Typescript: How to get metadata types info about public fields in class decorator
I'm using reflect-metadata lib and Typescript decorators.
I have this class for example (real one will have much more fields):
class Message {
    @FieldTyping
    text: string;
    @FieldTyping
    code: number;
    constructor(text: string,…
        
        FantaZ
        
- 49
 - 1
 - 2