Skip to content

Commit 9d35468

Browse files
committed
Test case for failing scenario of wrongly reporting error of parameter of private method when no implicit any is speicified
1 parent 11285b1 commit 9d35468

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
tests/cases/compiler/noImplicitAnyDestructuringInPrivateMethod.ts(10,19): error TS7031: Binding element 'a' implicitly has an 'any' type.
2+
3+
4+
==== tests/cases/compiler/noImplicitAnyDestructuringInPrivateMethod.ts (1 errors) ====
5+
type Arg = {
6+
a: number;
7+
};
8+
export class Bar {
9+
private bar({ a, }: Arg): number {
10+
return a;
11+
}
12+
}
13+
export declare class Bar2 {
14+
private bar({ a, });
15+
~
16+
!!! error TS7031: Binding element 'a' implicitly has an 'any' type.
17+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//// [noImplicitAnyDestructuringInPrivateMethod.ts]
2+
type Arg = {
3+
a: number;
4+
};
5+
export class Bar {
6+
private bar({ a, }: Arg): number {
7+
return a;
8+
}
9+
}
10+
export declare class Bar2 {
11+
private bar({ a, });
12+
}
13+
14+
//// [noImplicitAnyDestructuringInPrivateMethod.js]
15+
"use strict";
16+
var Bar = (function () {
17+
function Bar() {
18+
}
19+
Bar.prototype.bar = function (_a) {
20+
var a = _a.a;
21+
return a;
22+
};
23+
return Bar;
24+
}());
25+
exports.Bar = Bar;
26+
27+
28+
//// [noImplicitAnyDestructuringInPrivateMethod.d.ts]
29+
export declare class Bar {
30+
private bar({a});
31+
}
32+
export declare class Bar2 {
33+
private bar({a});
34+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// @noimplicitany: true
2+
// @declaration: true
3+
type Arg = {
4+
a: number;
5+
};
6+
export class Bar {
7+
private bar({ a, }: Arg): number {
8+
return a;
9+
}
10+
}
11+
export declare class Bar2 {
12+
private bar({ a, });
13+
}

0 commit comments

Comments
 (0)