I wanted to see if I can update definitions a MongoDB filter object, which utilizes these expressions. Below is just a start, but I already see an issue when the code compiles when it should not. This issue possibly has similar underlying issue as #12769
TypeScript Version: 2.1.4
Code
typeMongoFilter<T>=$and<T>|$or<T>|propertyRule<T>;typelogical<T>=$and<T>|$or<T>;type$and<T>={$and: Array<logical<T>|propertyRule<T>>}type$or<T>={$or: Array<logical<T>|propertyRule<T>>}typepropertyRule<T>={[PinkeyofT]?: T[P]|comparison<T[P]>}typecomparison<V>=$eq<V>|$gt|$lt;type$eq<V>={$eq: V};type$gt={$gt: number};type$lt={$lt: number};// See if MongoFilter works:interfacePerson{id: number;name: string;age: number;}// should compileletf1: MongoFilter<Person>={$or: [{id: 1},{name: 'dima'}]};letf2: MongoFilter<Person>={$and: [{id: 1}]};letf3: MongoFilter<Person>={id: 1};// should not compileletw1: MongoFilter<Person>={wrong: 1};// does not compile - goodletw2: MongoFilter<Person>={$or: [{wrong: 1}]};// compilesExpected behavior:
Code below should not compile
letw1: MongoFilter<Person>={$or: [{wrong: 1}]};Actual behavior:
But it does
I wanted to see if I can update definitions a MongoDB filter object, which utilizes these expressions. Below is just a start, but I already see an issue when the code compiles when it should not. This issue possibly has similar underlying issue as #12769
TypeScript Version: 2.1.4
Code
Expected behavior:
Code below should not compile
Actual behavior:
But it does