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?
reflect-metadata Allows you to do runtime reflection on types. The native (non reflect-metadata) version of type inference is much poorer than reflect-metadata and consists only of typeof and instanceof .
The metadata value is any possible JavaScript value. The Reflect. getMetadata returns the metadata associated with the target or its property. If no metadata is found, it returns undefined . Using these methods, you can associate any metadata with any object or its properties.
TypeORM is an Object Relational Mapper library running in node. js and written in TypeScript. TypeScript is an improvement to JavaScript with optional typing. TypeScript is a compiled language. It is not interpreted at run-time.
With the reflect-metadata package you can do runtime reflection on types. Since TypeORM mostly works with decorators (like @Entity or @Column), this package is used to parse these decorators and use it for building sql queries.
The following link provides detailed information about what this package is capable of: http://blog.wolksoftware.com/decorators-metadata-reflection-in-typescript-from-novice-to-expert-part-4.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With