mirror of
https://github.com/swc-project/swc.git
synced 2024-11-23 09:38:16 +03:00
fix(es/lints): Allow overload in typescript (#5116)
This commit is contained in:
parent
5a5cfb7e86
commit
bef8aebdea
@ -87,11 +87,16 @@ impl DuplicateBindings {
|
||||
fn visit_with_stmt_like<T: StmtLike + VisitWith<Self>>(&mut self, s: &[T]) {
|
||||
let mut fn_name = AHashMap::default();
|
||||
for s in s {
|
||||
if let Some(Stmt::Decl(Decl::Fn(s))) = s.as_stmt() {
|
||||
if let Some(prev) = fn_name.get(&s.ident.sym) {
|
||||
emit_error(&s.ident.sym, s.ident.span, *prev)
|
||||
if let Some(Stmt::Decl(Decl::Fn(FnDecl {
|
||||
ident,
|
||||
function: Function { body: Some(_), .. },
|
||||
..
|
||||
}))) = s.as_stmt()
|
||||
{
|
||||
if let Some(prev) = fn_name.get(&ident.sym) {
|
||||
emit_error(&ident.sym, ident.span, *prev)
|
||||
} else {
|
||||
fn_name.insert(s.ident.sym.clone(), s.ident.span);
|
||||
fn_name.insert(ident.sym.clone(), ident.span);
|
||||
}
|
||||
}
|
||||
|
||||
|
11
crates/swc_ecma_lints/tests/pass/issue-5115/1/input.ts
Normal file
11
crates/swc_ecma_lints/tests/pass/issue-5115/1/input.ts
Normal file
@ -0,0 +1,11 @@
|
||||
function makeDate(timestamp: number): Date;
|
||||
function makeDate(m: number, d: number, y: number): Date;
|
||||
function makeDate(mOrTimestamp: number, d?: number, y?: number): Date {
|
||||
if (d !== undefined && y !== undefined) {
|
||||
return new Date(y, mOrTimestamp, d);
|
||||
} else {
|
||||
return new Date(mOrTimestamp);
|
||||
}
|
||||
}
|
||||
|
||||
export {}
|
Loading…
Reference in New Issue
Block a user