mobxjs / mobx-angular

The MobX connector for Angular.
MIT License
483 stars 59 forks source link

Typescript error upon app load #82

Closed CharlieIGG closed 5 years ago

CharlieIGG commented 5 years ago

After installing mobx-angular everytime I start the project I get Typescript errors that prevent rendering, where the corresponding mobx interfaces are not found. However, if I save any file and the app recompiles, then it all works again (including all my mobx observables), but then again after working for a while, on the Nth save it fails again.

Here's the tslint output:

[app-scripts] [12:14:33]  typescript: node_modules/mobx/lib/core/atom.d.ts, line: 2 
[app-scripts]             '=' expected. 
[app-scripts]        L1:  import { IDerivationState, IObservable } from "../internal";
[app-scripts]        L2:  export declare const $mobx: unique symbol;
[app-scripts]        L3:  export interface IAtom extends IObservable {
[app-scripts] [12:14:33]  typescript: node_modules/mobx/lib/utils/decorators.d.ts, line: 1 
[app-scripts]             '=' expected. 
[app-scripts]        L1:  export declare const mobxDidRunLazyInitializersSymbol: unique symbol;
[app-scripts]        L2:  export declare const mobxPendingDecorators: unique symbol;
[app-scripts]             '=' expected. 
[app-scripts]        L1:  export declare const mobxDidRunLazyInitializersSymbol: unique symbol;
[app-scripts] [12:14:33]  typescript: node_modules/mobx/lib/utils/decorators.d.ts, line: 2 
[app-scripts]        L2:  export declare const mobxPendingDecorators: unique symbol;
[app-scripts]        L3:  export declare type BabelDescriptor = PropertyDescriptor & {
[app-scripts]             Cannot find name 'unique'. 
[app-scripts] [12:14:33]  typescript: node_modules/mobx/lib/core/atom.d.ts, line: 2 
[app-scripts]        L1:  import { IDerivationState, IObservable } from "../internal";
[app-scripts]        L2:  export declare const $mobx: unique symbol;
[app-scripts]        L3:  export interface IAtom extends IObservable {
[app-scripts] [12:14:33]  typescript: node_modules/mobx/lib/core/atom.d.ts, line: 2 
[app-scripts]             Cannot find name 'symbol'. Did you mean 'Symbol'? 
[app-scripts]        L1:  import { IDerivationState, IObservable } from "../internal";
[app-scripts]        L2:  export declare const $mobx: unique symbol;
[app-scripts]        L3:  export interface IAtom extends IObservable {
[app-scripts]             A computed property name in a class property declaration must directly refer to a built-in symbol. 
[app-scripts] [12:14:33]  typescript: node_modules/mobx/lib/types/observablemap.d.ts, line: 34 
[app-scripts] [12:14:33]  typescript: node_modules/mobx/lib/utils/decorators.d.ts, line: 1 
[app-scripts]       L33:  name: string;
[app-scripts]       L34:  [$mobx]: {};
[app-scripts]       L35:  private _data;
[app-scripts]             Cannot find name 'unique'. 
[app-scripts]        L1:  export declare const mobxDidRunLazyInitializersSymbol: unique symbol;
[app-scripts]        L2:  export declare const mobxPendingDecorators: unique symbol;
[app-scripts] [12:14:33]  typescript: node_modules/mobx/lib/utils/decorators.d.ts, line: 1 
[app-scripts]             Cannot find name 'symbol'. Did you mean 'Symbol'? 
[app-scripts]        L1:  export declare const mobxDidRunLazyInitializersSymbol: unique symbol;
[app-scripts]        L2:  export declare const mobxPendingDecorators: unique symbol;
[app-scripts]             Cannot find name 'unique'. 
[app-scripts]        L1:  export declare const mobxDidRunLazyInitializersSymbol: unique symbol;
[app-scripts] [12:14:33]  typescript: node_modules/mobx/lib/utils/decorators.d.ts, line: 2 
[app-scripts] [12:14:33]  typescript: node_modules/mobx/lib/utils/decorators.d.ts, line: 2 
[app-scripts]        L2:  export declare const mobxPendingDecorators: unique symbol;
[app-scripts]        L3:  export declare type BabelDescriptor = PropertyDescriptor & {
[app-scripts]             Cannot find name 'symbol'. Did you mean 'Symbol'? 
[app-scripts]        L1:  export declare const mobxDidRunLazyInitializersSymbol: unique symbol;
[app-scripts]        L2:  export declare const mobxPendingDecorators: unique symbol;
[app-scripts]        L3:  export declare type BabelDescriptor = PropertyDescriptor & {

I'm unsure if this may be related to #51 ...

...

EDIT - This also seems to be preventing me from compiling the Ionic project.

CharlieIGG commented 5 years ago

If anybody stumbles into this, the most recent Mobx types require Typescript v2.7.0+ to work properly.

adamkleingit commented 5 years ago

@CharlieIGG thanks for sharing the solution with everyone!

andrisole92 commented 4 years ago

Got the same issue, updated typescript, still having.

adamkleingit commented 4 years ago

From examining the errors, it looks like a problem with mobx, not mobx-angular. Can you open it there?