Skip to content
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

Support this pseudo-params in classes, and enforce subtyping on structural class statics #1761

Closed
wants to merge 10 commits into from
Closed
3 changes: 3 additions & 0 deletions src/parser/estree_translator.ml
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,7 @@ end with type t = Impl.t) = struct
| Any -> any_type loc
| Void -> void_type loc
| Null -> null_type loc
| This -> this_type loc
| Number -> number_type loc
| String -> string_type loc
| Boolean -> boolean_type loc
Expand All @@ -893,6 +894,8 @@ end with type t = Impl.t) = struct

and null_type loc = node "NullTypeAnnotation" loc [||]

and this_type loc = node "ThisTypeAnnotation" loc [||]

and number_type loc = node "NumberTypeAnnotation" loc [||]

and string_type loc = node "StringTypeAnnotation" loc [||]
Expand Down
1 change: 1 addition & 0 deletions src/parser/lexer_flow.mll
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@
"false", T_FALSE;
"number", T_NUMBER_TYPE;
"string", T_STRING_TYPE;
"this", T_THIS;
"void", T_VOID_TYPE;
"null", T_NULL;
]
Expand Down
6 changes: 6 additions & 0 deletions src/parser/loc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ let btwn loc1 loc2 = {
_end = loc2._end;
}

let start loc = {
source = loc.source;
start = loc.start;
_end = loc.start;
}

let btwn_exclusive loc1 loc2 = {
source = loc1.source;
start = loc1._end;
Expand Down
2 changes: 2 additions & 0 deletions src/parser/parse_error.ml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ type t =
| ExportNamelessFunction
| UnsupportedDecorator
| MissingTypeParamDefault
| CtorThisParam

exception Error of (Loc.t * t) list

Expand Down Expand Up @@ -170,6 +171,7 @@ module PP =
| UnsupportedDecorator -> "Found a decorator in an unsupported position."
| MissingTypeParamDefault -> "Type parameter declaration needs a default, \
since a preceding type parameter declaration has a default."
| CtorThisParam -> "Found a `this` pseudo-param on a constructor."


end
Loading