fix(es/lints): Allow overload in typescript (#5116)

This commit is contained in:
Austaras 2022-07-06 00:33:58 +08:00 committed by GitHub
parent 5a5cfb7e86
commit bef8aebdea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 4 deletions

View File

@ -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);
}
}

View 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 {}