Skip to content

[6.x] [core/public/deepFreeze] fix recursive type for better array support (#22904)#22932

Merged
spalger merged 1 commit intoelastic:6.xfrom
spalger:backport/6.x/pr-22904
Sep 11, 2018
Merged

[6.x] [core/public/deepFreeze] fix recursive type for better array support (#22904)#22932
spalger merged 1 commit intoelastic:6.xfrom
spalger:backport/6.x/pr-22904

Conversation

@spalger
Copy link
Contributor

@spalger spalger commented Sep 11, 2018

Backports the following commits to 6.x:

…lastic#22904)

The `deepFreeze()` function used by `core.injectedMetadata` uses a recursive type definition to indicate that all of the child types within the passed argument become readonly, which works fine for objects but represents arrays as objects instead of using the `ReadonlyArray<>` type. 

This PR fixes the type definition to use a `RecursiveReadonlyArray<>` type that properly represents arrays with their methods like `push()`, and iterates into the array properly to propagate `ReadOnly<>`, as proven by the tests.
@spalger spalger added the backport This PR is a backport of another PR label Sep 11, 2018
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@spalger spalger merged commit cfd2a8f into elastic:6.x Sep 11, 2018
@spalger spalger deleted the backport/6.x/pr-22904 branch September 11, 2018 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments