Skip to content
This repository has been archived by the owner on May 19, 2018. It is now read-only.

Allow keywords in object/class property names with Flow type parameters #145

Merged
merged 1 commit into from
Oct 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/plugins/flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,17 @@ export default function (instance) {
};
});

// ensure that inside property names, < isn't interpreted as JSX, but as a type parameter
instance.extend("parsePropertyName", function (inner) {
return function (prop) {
const oldInType = this.state.inType;
this.state.inType = true;
const out = inner.call(this, prop);
this.state.inType = oldInType;
return out;
};
});

// ensure that inside flow types, we bypass the jsx parser plugin
instance.extend("readToken", function (inner) {
return function (code) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class X {
foobar<T>() {}
delete<T>() {}
yield<T>() {}
do<T>() {}
static foobar<T>() {}
static delete<T>() {}
static yield<T>() {}
static do<T>() {}
};
Loading