Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Jan 29, 2021
1 parent cd05d59 commit 2095751
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
2 changes: 1 addition & 1 deletion ecmascript/parser/src/lexer/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ impl<'a, I: Input> Iterator for Lexer<'a, I> {
}
}

if self.syntax.jsx() && !self.ctx.in_property_name {
if self.syntax.jsx() && !self.ctx.in_property_name && !self.ctx.in_type {
//jsx
if self.state.context.current() == Some(TokenContext::JSXExpr) {
return self.read_jsx_token();
Expand Down
36 changes: 20 additions & 16 deletions ecmascript/parser/src/parser/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,24 +373,28 @@ impl<I: Tokens> Parser<I> {

/// `tsParseTypeParameter`
pub(super) fn parse_ts_type_params(&mut self) -> PResult<TsTypeParamDecl> {
let start = cur_pos!(self);
self.in_type().parse_with(|p| {
p.ts_in_no_context(|p| {
let start = cur_pos!(p);

if !is!(self, '<') && !is!(self, JSXTagStart) {
unexpected!(self, "< (jsx tag start)")
}
bump!(self); // '<'

let params = self.parse_ts_bracketed_list(
ParsingContext::TypeParametersOrArguments,
|p| p.parse_ts_type_param(), // bracket
false,
// skip_first_token
true,
)?;
if !is!(p, '<') && !is!(p, JSXTagStart) {
unexpected!(p, "< (jsx tag start)")
}
bump!(p); // '<'

Ok(TsTypeParamDecl {
span: span!(self, start),
params,
let params = p.parse_ts_bracketed_list(
ParsingContext::TypeParametersOrArguments,
|p| p.parse_ts_type_param(), // bracket
false,
// skip_first_token
true,
)?;

Ok(TsTypeParamDecl {
span: span!(p, start),
params,
})
})
})
}

Expand Down

0 comments on commit 2095751

Please sign in to comment.