Skip to content

Commit af25a88

Browse files
authored
fix(swc): Fix bugs for v1.2.47 (#1368)
swc_ecma_parser: - Fix generic parsing issue in jsx context. (#1299) swc_ecma_transforms_module: - Allow importing a module multiple time. (#1232) - Handle imports in the constructor of an exported class decl. (#1213) swc: - Respect `sourceMappingURL`. (#1236) - Resolve `sourceMappingURL` relative from file. (#1255) - Respect `isModule: false` (#1258) spack: - Support loading json files. (#1225)
1 parent ca417e9 commit af25a88

File tree

32 files changed

+1101
-24
lines changed

32 files changed

+1101
-24
lines changed

ecmascript/parser/src/lexer/state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ impl<'a, I: Input> Iterator for Lexer<'a, I> {
219219
}
220220
}
221221

222-
if self.syntax.jsx() && !self.ctx.in_property_name {
222+
if self.syntax.jsx() && !self.ctx.in_property_name && !self.ctx.in_type {
223223
//jsx
224224
if self.state.context.current() == Some(TokenContext::JSXExpr) {
225225
return self.read_jsx_token();

ecmascript/parser/src/parser/class_and_fn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ impl<'a, I: Tokens> Parser<I> {
920920
};
921921

922922
self.with_ctx(ctx).parse_with(|p| {
923-
let type_params = if p.syntax().typescript() && is!(p, '<') {
923+
let type_params = if p.syntax().typescript() && is_one_of!(p, '<', JSXTagStart) {
924924
//
925925
Some(p.parse_ts_type_params()?)
926926
} else {

ecmascript/parser/src/parser/typescript.rs

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -373,24 +373,28 @@ impl<I: Tokens> Parser<I> {
373373

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

378-
if !is!(self, '<') && !is!(self, JSXTagStart) {
379-
unexpected!(self, "< (jsx tag start)")
380-
}
381-
bump!(self); // '<'
382-
383-
let params = self.parse_ts_bracketed_list(
384-
ParsingContext::TypeParametersOrArguments,
385-
|p| p.parse_ts_type_param(), // bracket
386-
false,
387-
// skip_first_token
388-
true,
389-
)?;
380+
if !is!(p, '<') && !is!(p, JSXTagStart) {
381+
unexpected!(p, "< (jsx tag start)")
382+
}
383+
bump!(p); // '<'
390384

391-
Ok(TsTypeParamDecl {
392-
span: span!(self, start),
393-
params,
385+
let params = p.parse_ts_bracketed_list(
386+
ParsingContext::TypeParametersOrArguments,
387+
|p| p.parse_ts_type_param(), // bracket
388+
false,
389+
// skip_first_token
390+
true,
391+
)?;
392+
393+
Ok(TsTypeParamDecl {
394+
span: span!(p, start),
395+
params,
396+
})
397+
})
394398
})
395399
}
396400

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export const iteratorMapGenerator = function*<T, R>(
2+
values: IterableIterator<T>,
3+
execute: IteratorExecution<T, R>,
4+
): IterableIterator<R> {
5+
}

0 commit comments

Comments
 (0)