Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TS compile errors on 4.10.0 - An index signature parameter type must be 'string' or 'number'. #1986

Closed
timothyallan opened this issue Jun 4, 2019 · 8 comments
Labels

Comments

@timothyallan
Copy link

timothyallan commented Jun 4, 2019

Hey all, I'm getting TS compile errors with mobx 4.10.0 and TS 3.4.5 as well as TS 3.5.1
It's related to #1944

../client/node_modules/mobx/lib/types/observableobject.d.ts:37:10 - error TS1023: An index signature parameter type must be 'string' or 'number'.

37         [key: PropertyKey]: ObservableValue<any> | ComputedValue<any>;
            ~~~
@loklaan
Copy link
Contributor

loklaan commented Jun 5, 2019

Hi @timothyallan, could you post an abstract of the code that raises these errors when compiled?

@timothyallan
Copy link
Author

Yeah I'll look into it some more. It really just was happening while doing a ./node_modules/typescript/bin/tsc -p ./src, but if nobody else is getting that, there must be something else at play

@cameronbraid
Copy link

cameronbraid commented Jun 5, 2019

I am getting it too

ERROR in [at-loader] ./node_modules/mobx/lib/types/observableobject.d.ts:37:10
TS1023: An index signature parameter type must be 'string' or 'number'.

@cameronbraid
Copy link

export declare class ObservableObjectAdministration implements IInterceptable<IObjectWillChange>, IListenable {
    target: any;
    name: string;
    defaultEnhancer: IEnhancer<any>;
    values: {
        [key: PropertyKey]: ObservableValue<any> | ComputedValue<any>;
    };
`11

@cameronbraid
Copy link

Looks like PropertyKey has been changed to include symbol not just string and number

https://github.com/microsoft/TypeScript/blob/master/lib/lib.es5.d.ts#L105

@loklaan
Copy link
Contributor

loklaan commented Jun 5, 2019

Oh no, I checked it out, looks like the build of the [email protected] is broken. (shown above) 😭
The change that affected this is mine, my bad 😬.

My recommendation is to stay on [email protected].


Looks like the implementation in the mobx4-master branch uses a keyed object instead of a Map, and Symbols aren't yet supported as object keys (check out #microsoft/TypeScript/1863 for progress). I think the intention was to put a @ts-ignore on the line but it gets dropped during the build-step.

Together with #1987, it might be easier to leave out Symbol support for keys for the 4.x release... That's up to the maintainers.

@mweststrate
Copy link
Member

Fixed in 4.11.0

@lock
Copy link

lock bot commented Aug 16, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or questions.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants