mirror of
https://github.com/swc-project/swc.git
synced 2024-11-24 10:12:42 +03:00
feat(es/parser): Reject 'use strict'
with non-simple params list in TS (#4416)
This commit is contained in:
parent
63efd0089b
commit
6dc64c9ca0
@ -1527,7 +1527,7 @@ impl<I: Tokens> FnBodyParser<BlockStmtOrExpr> for Parser<I> {
|
||||
};
|
||||
let result = self.with_ctx(ctx).parse_block(false);
|
||||
result.map(|block_stmt| {
|
||||
if !self.input.syntax().typescript() && !is_simple_parameter_list {
|
||||
if !is_simple_parameter_list {
|
||||
if let Some(span) = has_use_strict(&block_stmt) {
|
||||
self.emit_err(span, SyntaxError::IllegalLanguageModeDirective);
|
||||
}
|
||||
@ -1558,7 +1558,7 @@ impl<I: Tokens> FnBodyParser<Option<BlockStmt>> for Parser<I> {
|
||||
}
|
||||
let block = self.include_in_expr(true).parse_block(true);
|
||||
block.map(|block_stmt| {
|
||||
if !self.input.syntax().typescript() && !is_simple_parameter_list {
|
||||
if !is_simple_parameter_list {
|
||||
if let Some(span) = has_use_strict(&block_stmt) {
|
||||
self.emit_err(span, SyntaxError::IllegalLanguageModeDirective);
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
const f = ([x]: string) => { 'use strict' }
|
@ -0,0 +1,6 @@
|
||||
|
||||
x Illegal 'use strict' directive in function with non-simple parameter list.
|
||||
,-[$DIR/tests/typescript-errors/use-strict/arrow-fn-expr/input.ts:1:1]
|
||||
1 | const f = ([x]: string) => { 'use strict' }
|
||||
: ^^^^^^^^^^^^
|
||||
`----
|
@ -0,0 +1 @@
|
||||
function f([x]: string) { 'use strict' }
|
@ -0,0 +1,6 @@
|
||||
|
||||
x Illegal 'use strict' directive in function with non-simple parameter list.
|
||||
,-[$DIR/tests/typescript-errors/use-strict/fn-block/input.ts:1:1]
|
||||
1 | function f([x]: string) { 'use strict' }
|
||||
: ^^^^^^^^^^^^
|
||||
`----
|
Loading…
Reference in New Issue
Block a user