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
I want to constrain the keys of an index schema against a type alias (union with literals). Using this type for values works as expected, but using this type to constrain the key of index signature schemas does not work.
I know that I can create a "check" in the schema to validate against a set of strings, but then the question arises, how to constrain the check against the type _foo without duplicating the definition of _foo.
I also played with other types for the key e.g. int and kcl throws an error ("invalid index signature key type: 'int'"), which suggests that only strings are allowed, but that would make specifying a type for the key obsolete at all...
1. Minimal reproduce step (Required)
type _foo = "foo" | "bar"
schema IndexSignature:
[..._foo]: any
IndexSignature {
foo = "foo"
# this should throw an error
baz: "baz"
}
2. What did you expect to see? (Required)
something like ^ expected str(foo) | str(bar), got str(baz)
3. What did you see instead (Required)
foo: foo
baz: baz
4. What is your KCL components version? (Required)
0.11.0-linux-amd64
The text was updated successfully, but these errors were encountered:
Bug Report
I want to constrain the keys of an index schema against a type alias (union with literals). Using this type for values works as expected, but using this type to constrain the key of index signature schemas does not work.
I know that I can create a "check" in the schema to validate against a set of strings, but then the question arises, how to constrain the check against the type
_foo
without duplicating the definition of_foo
.I also played with other types for the key e.g.
int
and kcl throws an error ("invalid index signature key type: 'int'"), which suggests that only strings are allowed, but that would make specifying a type for the key obsolete at all...1. Minimal reproduce step (Required)
2. What did you expect to see? (Required)
something like
^ expected str(foo) | str(bar), got str(baz)
3. What did you see instead (Required)
4. What is your KCL components version? (Required)
0.11.0-linux-amd64
The text was updated successfully, but these errors were encountered: