[decorators] [typescript] Parse type parameters (#8767)

* [decorators] [typescript] Parse type parameters

* Add test for invalid code
This commit is contained in:
Nicolò Ribaudo
2018-10-01 22:04:19 +02:00
committed by GitHub
parent 07862e7272
commit 3c87401714
13 changed files with 383 additions and 9 deletions

View File

@@ -2047,6 +2047,22 @@ export default (superClass: Class<Parser>): Class<Parser> =>
}
}
parseMaybeDecoratorArguments(expr: N.Expression): N.Expression {
if (this.isRelational("<")) {
const typeArguments = this.tsParseTypeArguments();
if (this.match(tt.parenL)) {
const call = super.parseMaybeDecoratorArguments(expr);
call.typeParameters = typeArguments;
return call;
}
this.unexpected(this.state.start, tt.parenL);
}
return super.parseMaybeDecoratorArguments(expr);
}
// === === === === === === === === === === === === === === === ===
// Note: All below methods are duplicates of something in flow.js.
// Not sure what the best way to combine these is.