You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Description
The annotated allowed type work reintroduced the possibility of
modifying an allowed type array after derived data was computed. This
change closes that gap and adds some tests.
@@ -637,8 +634,8 @@ export type TreeNodeFromImplicitAllowedTypes<
637
634
* This type exists only to be linked from documentation to provide a single linkable place to document some details of
638
635
* "Input" types and how they handle schema.
639
636
*
640
-
* When a schema is used to describe data which is an input into an API, the API is {@link https://en.wikipedia.org/wiki/Covariance_and_contravariance_(computer_science | contravariant}) over the schema.
641
-
* (See also, {@link https://www.typescriptlang.org/docs/handbook/2/generics.html#variance-annotations | TypeScript Variance Annotations}).
637
+
* When a schema is used to describe data which is an input into an API, the API is {@link https://en.wikipedia.org/wiki/Type_variance | contravariant}) over the schema.
638
+
* (See also {@link https://www.typescriptlang.org/docs/handbook/2/generics.html#variance-annotations | TypeScript Variance Annotations}).
642
639
*
643
640
* Since these schema are expressed using TypeScript types, it is possible for the user of the API to provide non-exact values of these types which has implications that depended on the variance.
// If derived data is computed based on an allowed type array, then modifications to that array would cause the derived data to become invalid.
573
+
// As there is no invalidation mechanism, this would lead to incorrect behavior, and is prevented by freezing the arrays when the derived data is computed.
574
+
// These are glass box tests: they are testing that the cases where the code currently derives data from the arrays results in the arrays being frozen.
575
+
// Future changes could be made to delay both the freezing and the computation of the derived data:
576
+
// if such changes are made these tests will need to be updated.
577
+
// If done, these tests may need updates to instead test that modifying the arrays does not expose incorrect derived data.
0 commit comments