Skip to content

Commit

Permalink
Fix noImplicitAny check on ambient private getters (#33896)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajafff authored and RyanCavanaugh committed Oct 9, 2019
1 parent 3d130b7 commit e48cd3a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7436,7 +7436,9 @@ namespace ts {
}
else {
Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function");
errorOrSuggestion(noImplicitAny, getter!, Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol));
if (!isPrivateWithinAmbient(getter!)) {
errorOrSuggestion(noImplicitAny, getter!, Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol));
}
}
return anyType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ declare class Something
{
private static someStaticVar;
private someVar;
private get getter();
private set setter(v);
}

//// [app.ts]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,12 @@ declare class Something

private someVar;
>someVar : Symbol(Something.someVar, Decl(test.d.ts, 2, 33))

private get getter();
>getter : Symbol(Something.getter, Decl(test.d.ts, 3, 20))

private set setter(v);
>setter : Symbol(Something.setter, Decl(test.d.ts, 4, 25))
>v : Symbol(v, Decl(test.d.ts, 5, 23))
}

Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,12 @@ declare class Something

private someVar;
>someVar : any

private get getter();
>getter : any

private set setter(v);
>setter : any
>v : any
}

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ declare class Something
{
private static someStaticVar;
private someVar;
private get getter();
private set setter(v);
}

// @noimplicitany: true
Expand Down

0 comments on commit e48cd3a

Please sign in to comment.