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

Optional index signature #7118

Closed
Pajn opened this issue Feb 17, 2016 · 4 comments
Closed

Optional index signature #7118

Pajn opened this issue Feb 17, 2016 · 4 comments
Labels
External Relates to another program, environment, or user action which we cannot control.

Comments

@Pajn
Copy link

Pajn commented Feb 17, 2016

It should be possible to make the index signature optional like this:
export type Actions = {[type: string]?: Action}

If the index signature is not optional (as I'm required to type right now) I get errors when passing parameters with the Actions type as the index signature is missing in the passed object.

@mhegazy
Copy link
Contributor

mhegazy commented Feb 17, 2016

An index signature is a "constraint" on a type; i do not understand what an optional constraint means..

Can you elaborate on your case, and what you are trying to achieve here.

In your example, all properties should be Action; and if not, what should they be? why not define the index signature in a more permissive fashion, i.e [type:string]: any or [type:string]:Action|Person|Entity?

@Pajn
Copy link
Author

Pajn commented Feb 17, 2016

I currently get the error "Index signature is missing in type", what I want to constrain is that all values are Action, not that the passed object allows setting additional keys

@RyanCavanaugh
Copy link
Member

If your use case isn't solved by #7029, please post some code so we can understand the scenario. Thanks!

@RyanCavanaugh RyanCavanaugh added the Needs More Info The issue still hasn't been fully clarified label Feb 17, 2016
@Pajn
Copy link
Author

Pajn commented Feb 17, 2016

Oh, sorry. Didn't look for already fixed issues, just open :/

@Pajn Pajn closed this as completed Feb 17, 2016
@RyanCavanaugh RyanCavanaugh added External Relates to another program, environment, or user action which we cannot control. and removed Needs More Info The issue still hasn't been fully clarified labels Feb 17, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
External Relates to another program, environment, or user action which we cannot control.
Projects
None yet
Development

No branches or pull requests

3 participants