Due to some new strict mode constraits with TS 2.7 compilation fails:
node_modules/mobx-state-tree/dist/types/complex-types/model.d.ts:29:5 - error TS2416: Property 'props' in type 'ModelType<S, T>' is not assignable to the same property in base type 'IModelType<S, T>'.
Type '<SP, TP>(properties: { [K in keyof TP]: IType<any, TP[K]>; } & { [K in keyof SP]: IType<SP[K], an...' is not assignable to type '<SP, TP>(props: { [K in keyof TP]: TP[K] | IType<any, TP[K]>; } & { [K in keyof SP]: SP[K] | ITyp...'.
Types of parameters 'properties' and 'props' are incompatible.
Type '{ [K in keyof TP]: TP[K] | IType<any, TP[K]>; } & { [K in keyof SP]: SP[K] | IType<SP[K], any>; }' is not assignable to type '{ [K
in keyof TP]: IType<any, TP[K]>; } & { [K in keyof SP]: IType<Snapshot<SP>[K], any>; }'.
Type '{ [K in keyof TP]: TP[K] | IType<any, TP[K]>; } & { [K in keyof SP]: SP[K] | IType<SP[K], any>; }' is not assignable to type '{ [K in keyof TP]: IType<any, TP[K]>; }'.
29 props<SP, TP>(properties: {
~~~~~
The same issue is:
> tsc
node_modules/protractor-element-extend/js/index.d.ts(11,22): error TS2415: Class 'BaseArrayFragment<T>' incorrectly extends base class 'ElementArrayFinder'.
Types of property 'filter' are incompatible.
Type '(filterFn: (elementFinder?: T, index?: number) => boolean | Promise<boolean> | Promise<boolean>) ...' is not assignable to type '(filterFn: (element: ElementFinder, index?: number) => boolean | Promise<boolean>) => ElementArra...'.
Types of parameters 'filterFn' and 'filterFn' are incompatible.
Type 'boolean | Promise<boolean>' is not assignable to type 'boolean | Promise<boolean> | Promise<boolean>'.
Type 'Promise<boolean>' is not assignable to type 'boolean | Promise<boolean> | Promise<boolean>'.
Type 'promise.Promise<boolean>' is not assignable to type 'promise.Promise<boolean>'. Two different types with this name exist, but they are unrelated.
Types of property 'then' are incompatible.
Type '<R>(opt_callback?: (value: boolean) => R | IThenable<R>, opt_errback?: (error: any) => any) => Pr...' is not assignable to type '<TResult1 = boolean, TResult2 = never>(onfulfilled?: (value: boolean) => TResult1 | PromiseLike<T...'.
Types of parameters 'opt_callback' and 'onfulfilled' are incompatible.
Type 'TResult1 | PromiseLike<TResult1>' is not assignable to type 'TResult1 | IThenable<TResult1>'.
Type 'PromiseLike<TResult1>' is not assignable to type 'TResult1 | IThenable<TResult1>'.
Type 'PromiseLike<TResult1>' is not assignable to type 'IThenable<TResult1>'.
Property 'cancel' is missing in type 'PromiseLike<TResult1>'.
@xaviergonz How is it fixed ?
i run it with npm run lite
Just a note that this seems to still be happening in the release versions of TypeScript 2.7 -- both 2.7.1 and 2.7.2, ie. it sure seems like any TypeScript >2.7 project using MST fails to compile as of right now!
Correct, using TS 2.7 with MST doesn't make sense atm. The fixes in the
open PRs make it compilable but infer any everwhere, which defeats the
whole point (or do the PRs work for others?).
Op vr 16 feb. 2018 06:48 schreef s notifications@github.com:
Just a note that this seems to still be happening in the release versions
of TypeScript 2.7 -- both 2.7.1 and 2.7.2, ie. it sure seems like any
TypeScript >2.7 project using MST fails to compile as of right now!—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/mobxjs/mobx-state-tree/issues/629#issuecomment-366150027,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABvGhJ1H2coOvIDq3LdgCuTEiHLOnU8Uks5tVRbEgaJpZM4RvbrL
.
Oops, didn't see that there were already PRs!
Will TS 2.8 make things fixable because of conditional types/mapped type modifiers?
@mweststrate you might want to take a second look at the alternate syntax I made in https://github.com/xaviergonz/mobx-state-tree-ts/tree/test-typescript-2.8
It works properly (actually provides even better type inference than the current one), which might be improved further with what TS 2.7+ will offer
The only thing I had to make it compile once more was adding:
// @ts-ignore
props<SP, TP>(properties: {
[K in keyof TP]: IType<any, TP[K]>;
} & {
[K in keyof SP]: IType<SP[K], any>;
}): IModelType<S & SP, T & TP>;
in the model.d.ts file (or else the project wouldn't compile due to the aforementioned error)
The possible issue might be the incorrect version of dependencies while ‘npm install’ running. If there is a package-lock.json it can be checked.
So what's the plan for this one?
Looks like #637 would fix the issues for TypeScript 2.7. Are we planning on getting the fix in prior to 2.8?
Now that ts 2.7 defs are out I'm going to close my own issue :)
Most helpful comment
So what's the plan for this one?