@mikro-orm/reflection 7.0.0-dev.39 → 7.0.0-dev.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -381,6 +381,8 @@ See also the list of contributors who [participated](https://github.com/mikro-or
381
381
 
382
382
  Please ⭐️ this repository if this project helped you!
383
383
 
384
+ > If you'd like to support my open-source work, consider sponsoring me directly at [github.com/sponsors/b4nan](https://github.com/sponsors/b4nan).
385
+
384
386
  ## 📝 License
385
387
 
386
388
  Copyright © 2018 [Martin Adámek](https://github.com/b4nan).
@@ -1,4 +1,4 @@
1
- import { ModuleKind, Project } from 'ts-morph';
1
+ import { ComputedPropertyName, ModuleKind, NoSubstitutionTemplateLiteral, Project, StringLiteral } from 'ts-morph';
2
2
  import { ConfigurationLoader, MetadataError, MetadataProvider, MetadataStorage, ReferenceKind, Utils, } from '@mikro-orm/core';
3
3
  export class TsMorphMetadataProvider extends MetadataProvider {
4
4
  project;
@@ -79,7 +79,22 @@ export class TsMorphMetadataProvider extends MetadataProvider {
79
79
  throw new MetadataError(`Source class for entity ${meta.className} not found. Verify you have 'compilerOptions.declaration' enabled in your 'tsconfig.json'. If you are using webpack, see https://bit.ly/35pPDNn`);
80
80
  }
81
81
  const properties = cls.getInstanceProperties();
82
- const property = properties.find(v => v.getName() === prop.name);
82
+ const property = properties.find(v => {
83
+ if (v.getName() === prop.name) {
84
+ return true;
85
+ }
86
+ const nameNode = v.getNameNode();
87
+ if (nameNode instanceof StringLiteral && nameNode.getLiteralText() === prop.name) {
88
+ return true;
89
+ }
90
+ if (nameNode instanceof ComputedPropertyName) {
91
+ const expr = nameNode.getExpression();
92
+ if (expr instanceof NoSubstitutionTemplateLiteral && expr.getLiteralText() === prop.name) {
93
+ return true;
94
+ }
95
+ }
96
+ return false;
97
+ });
83
98
  if (!property) {
84
99
  return { type: prop.type, optional: prop.nullable };
85
100
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mikro-orm/reflection",
3
3
  "type": "module",
4
- "version": "7.0.0-dev.39",
4
+ "version": "7.0.0-dev.40",
5
5
  "description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
6
6
  "exports": {
7
7
  "./package.json": "./package.json",
@@ -54,9 +54,9 @@
54
54
  "ts-morph": "27.0.2"
55
55
  },
56
56
  "devDependencies": {
57
- "@mikro-orm/core": "^6.5.8"
57
+ "@mikro-orm/core": "^6.6.0"
58
58
  },
59
59
  "peerDependencies": {
60
- "@mikro-orm/core": "7.0.0-dev.39"
60
+ "@mikro-orm/core": "7.0.0-dev.40"
61
61
  }
62
62
  }