Search code examples
node.jstypescripttypeormreflect-metadata

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?


Solution

  • 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.