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

Type 'string' cannot be used to index type 'EffectsMetadata<T>' #623

Closed
alex-okrushko opened this issue Dec 2, 2017 · 4 comments
Closed

Comments

@alex-okrushko
Copy link
Member

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ X ] Bug report  
[ ] Feature request
[ ] Documentation issue or request

What is the current behavior?

I'm syncing the latest ngrx into Google and I'm getting the build error:

metadata[propertyName] = { dispatch };
~~~~~~~~~~~~~~~~~~~~~~
third_party/javascript/ngrx/modules/effects/src/effects_metadata.ts(56,5): error TS2536: Type 'string' cannot be used to index type 'EffectsMetadata'.

Expected behavior:

I think it doesn't like the fact that propertyName cannot be narrowed down to keyof T.
The fix would be to use less fancy Indexable EffectsMetadata, e.g. this works:

export type EffectsMeta = {
  [key: string]:
    | undefined
    | {
        dispatch: boolean;
      }
};

The other option is to use ES6 Map altogether instead of Indexable.

Thoughts?

Minimal reproduction of the problem with instructions:

Version of affected browser(s),operating system(s), npm, node and ngrx:

Other information:

@brandonroberts
Copy link
Member

The first option seems reasonable to me. Is this error specific to closure compiler and how can we reproduce it?

@alex-okrushko
Copy link
Member Author

@brandonroberts thanks for a quick reply.

I don't think it's about closure compiler. It's failing during "Compiling Angular templates (ngc)" in the project that is using ngrx v4.

Also, someone already discovered this exact issue (#518) which was also happening during ngc, but closed it assuming the fix was in uglify.

@brandonroberts
Copy link
Member

@alex-okrushko is this still an issue?

@alex-okrushko
Copy link
Member Author

yes it is. I've done Local Mod for now to get it into Google.
I can probably change it here as well sometime next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants