-
-
Notifications
You must be signed in to change notification settings - Fork 115
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 1.6: strict object literal assignment #208
Comments
👍 ran into this same issue when using TS 1.6. I also hang off |
@bryanrsmith How should we handle that? I don't think that we can do it with Babel, can we? |
@EisenbergEffect Babel does support it. I think we should instead encourage custom data to be added to a property specifically designed for arbitrary data. That would give us more flexibility in internal changes and future API additions. I thought we had such a property documented already, but I'm having trouble finding it now... |
Customizing the navigation pipeline in the doc illustrates using I also note that when you have lots of routes, adding properties on sub-objects it's not very convenient (but doable). |
@bryanrsmith Yes, there's actually already a property designated for that: |
That's exactly how I fixed it on mine for the moment. Might be better if it allows generic so we do get type strictness in our custom settings model. |
TS 1.6 introduces more strict type checking on object literals:
microsoft/TypeScript#3823
If an API is commonly meant to be extended, it's good that it adds a generic indexer to its definition for easier consumption.
I think it's the case for
RouteConfig
.I had this in my code and it now fails in TS 1.6:
The thing to notice is that I use
auth
to manage authentication and access rights for my routes (which I think is a recommended practice?).Because
auth
is not declared inRouteConfig
TS raised an error.There are several ways to remove the error, but in this case I thought that it just made more sense to add
[x: string]: any
inside theRouteConfig
declaration.The consequence is that we still get intellisense for declared
RouteConfig
properties, but we may freely extend it with undeclared properties.The text was updated successfully, but these errors were encountered: