Skip to content

Incorrect TS type for ilm.explainLifecycle response #531

@cjcenizal

Description

@cjcenizal

🐛 Wrong type

The ilm.explainLifecycle response's indices property is typed as Record<string, IlmExplainLifecycleLifecycleExplain> | IlmExplainLifecycleLifecycleExplainProject.

Definition

If I try to access indices[indexName], TS complains with this error:

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Record<string, IlmExplainLifecycleLifecycleExplain> | IlmExplainLifecycleLifecycleExplainProject'. No index signature with a parameter of type 'string' was found on type 'Record<string, IlmExplainLifecycleLifecycleExplain> | IlmExplainLifecycleLifecycleExplainProject'.ts(7053) 

This is defined in https://github.com/elastic/elasticsearch-specification/blob/main/specification/ilm/explain_lifecycle/ExplainLifecycleResponse.ts#L26.

Based on the Explain lifecycle API docs, I don't see how LifecycleExplainProject could be relevant to the response. I believe the correct type is:

export class Response { body: { - indices: Dictionary<IndexName, LifecycleExplain> | LifecycleExplainProject + indices: Dictionary<IndexName, LifecycleExplain> } }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions