@@ -22,11 +22,14 @@ declare module Db {
22
22
interface Entity {
23
23
}
24
24
/**
25
- * Definition of an entity constructor, just to mane things.
25
+ * Definition of an entity constructor, just to name things.
26
26
*/
27
27
interface EntityType < T extends Entity > {
28
28
new ( ) : T ;
29
29
}
30
+ interface EntityTypeProducer < T extends Entity > {
31
+ ( ) : EntityType < T > ;
32
+ }
30
33
/**
31
34
* Internal module, most of the stuff inside this module are either internal use only or exposed by other methods,
32
35
* they should never be used directly.
@@ -1257,11 +1260,17 @@ declare module Db {
1257
1260
class MetaDescriptor {
1258
1261
localName : string ;
1259
1262
remoteName : string ;
1260
- ctor : EntityType < any > ;
1263
+ /**
1264
+ * This could be either a class constructor (EntityType), or an anonymous function returning a costructor
1265
+ * (EntityTypeProducer). Code for resolving the producer is in the cotr getter. This producer stuff
1266
+ * is needed for https://github.com/Microsoft/TypeScript/issues/4888.
1267
+ */
1268
+ private _ctor ;
1261
1269
classMeta : ClassMetadata ;
1262
1270
getTreeChange ( md : Metadata ) : ClassMetadata ;
1263
1271
getRemoteName ( ) : string ;
1264
1272
setType ( def : any ) : void ;
1273
+ ctor : EntityType < any > ;
1265
1274
named ( name : string ) : MetaDescriptor ;
1266
1275
setLocalName ( name : string ) : void ;
1267
1276
createEvent ( allMetadata : Metadata ) : GenericEvent ;
@@ -1357,22 +1366,22 @@ declare module Db {
1357
1366
}
1358
1367
function bind ( localName : string , targetName : string , live ?: boolean ) : Internal . IBinding ;
1359
1368
function sortBy ( field : string , desc ?: boolean ) : Internal . SortingData ;
1360
- function embedded ( def : EntityType < any > , binding ?: Internal . IBinding ) : PropertyDecorator ;
1361
- function reference ( def : EntityType < any > , project ?: string [ ] ) : PropertyDecorator ;
1362
- function map ( valueType : EntityType < any > , reference ?: boolean , sorting ?: Internal . SortingData ) : PropertyDecorator ;
1363
- function set ( valueType : EntityType < any > , reference ?: boolean , sorting ?: Internal . SortingData ) : PropertyDecorator ;
1364
- function list ( valueType : EntityType < any > , reference ?: boolean , sorting ?: Internal . SortingData ) : PropertyDecorator ;
1369
+ function embedded ( def : EntityType < any > | EntityTypeProducer < any > , binding ?: Internal . IBinding ) : PropertyDecorator ;
1370
+ function reference ( def : EntityType < any > | EntityTypeProducer < any > , project ?: string [ ] ) : PropertyDecorator ;
1371
+ function map ( valueType : EntityType < any > | EntityTypeProducer < any > , reference ?: boolean , sorting ?: Internal . SortingData ) : PropertyDecorator ;
1372
+ function set ( valueType : EntityType < any > | EntityTypeProducer < any > , reference ?: boolean , sorting ?: Internal . SortingData ) : PropertyDecorator ;
1373
+ function list ( valueType : EntityType < any > | EntityTypeProducer < any > , reference ?: boolean , sorting ?: Internal . SortingData ) : PropertyDecorator ;
1365
1374
function root ( name ?: string , override ?: string ) : ClassDecorator ;
1366
1375
function discriminator ( disc : string ) : ClassDecorator ;
1367
1376
function override ( override ?: string ) : ClassDecorator ;
1368
1377
function observable ( ) : PropertyDecorator ;
1369
1378
function ignore ( ) : PropertyDecorator ;
1370
1379
module meta {
1371
- function embedded ( def : any , binding ?: Internal . IBinding ) : Db . Internal . EmbeddedMetaDescriptor ;
1372
- function reference ( def : any , project ?: string [ ] ) : Db . Internal . ReferenceMetaDescriptor ;
1373
- function map ( valuetype : EntityType < any > , reference ?: boolean , sorting ?: Internal . SortingData ) : Db . Internal . MapMetaDescriptor ;
1374
- function set ( valuetype : EntityType < any > , reference ?: boolean , sorting ?: Internal . SortingData ) : Db . Internal . SetMetaDescriptor ;
1375
- function list ( valuetype : EntityType < any > , reference ?: boolean , sorting ?: Internal . SortingData ) : Db . Internal . ListMetaDescriptor ;
1380
+ function embedded ( def : EntityType < any > | EntityTypeProducer < any > , binding ?: Internal . IBinding ) : Db . Internal . EmbeddedMetaDescriptor ;
1381
+ function reference ( def : EntityType < any > | EntityTypeProducer < any > , project ?: string [ ] ) : Db . Internal . ReferenceMetaDescriptor ;
1382
+ function map ( valuetype : EntityType < any > | EntityTypeProducer < any > , reference ?: boolean , sorting ?: Internal . SortingData ) : Db . Internal . MapMetaDescriptor ;
1383
+ function set ( valuetype : EntityType < any > | EntityTypeProducer < any > , reference ?: boolean , sorting ?: Internal . SortingData ) : Db . Internal . SetMetaDescriptor ;
1384
+ function list ( valuetype : EntityType < any > | EntityTypeProducer < any > , reference ?: boolean , sorting ?: Internal . SortingData ) : Db . Internal . ListMetaDescriptor ;
1376
1385
function observable ( ) : Db . Internal . ObservableMetaDescriptor ;
1377
1386
function ignore ( ) : Db . Internal . IgnoreMetaDescriptor ;
1378
1387
function define ( ctor : EntityType < any > , root ?: string , discriminator ?: string , override ?: string ) : void ;
0 commit comments