-
Notifications
You must be signed in to change notification settings - Fork 455
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
Extensible records #5715
Extensible records #5715
Conversation
@mattdamon108 take a look and ignore syntax and the rough state. Curious if this mechanism is enough to represent concisely what's required to have different types for different Dom elements. How about creating a little mock like the example in the PR, without putting all the fields only some to test the idea, see how it looks like? @cannorin possibly relevant for conversion of TS bindings. CC @zth |
I like this! This is going to be helpful in many cases. |
Got it. I’ll make some example for it. The sample cases would be the representation of types for dom props and dom events. |
If I read the code correctly, using label as “dotdotdot” means the single extension, right? Not like |
Correct. Only one extension at the moment. |
Maybe or Maybe not. Not sure for now, but I think the single extension seems enough for the dom definition at this moment. |
added some example of record extension for dom elements |
Added support for multiple "dotdotdot" |
753bcf7
to
342d0f6
Compare
Some design questions about fields possibly repeating. This is now possible: type t1 = {x: int}
type t2 = {dotdotdot: t1, x: string} What it creates, is a type that cannot be used, as it contains Two possible ways are:
|
342d0f6
to
2034d8e
Compare
@cristianoc From the code generation perspective, it is probably better to make t2 override it (that needs less corner-case checking). |
We can always relax that later if needed (without causing braking changes). |
We are going to encounter this corner case very often because many TS users write something like this: interface A {
foo: any;
...
}
interface B extends A {
foo: string;
} So I guess it is better to start permissive in this case? |
The tooling can get special capabilities. In fact it could even live inside the compiler, so it's easier to iterate on these things in a PR. |
About surface syntax, this is perfectly valid object type definition, and trying to support type xy = {
"x": float,
"y": float,
}
type z = {
"z": float,
}
type xyz = {
...xy,
...z,
} |
04c3010
to
be88572
Compare
Add support for extensible records of the form e.g.:
Fields after expansion must not be repeated.
See #5659