Enable noImplicitThis
setting of TypeScript
#34192
Labels
developer-experience
Addressing these issues will improve the experience of developers working on Teleport
effort:low
Tasks which can be completed within a few hours.
ui
value:low
Tasks which completion brings comparatively low benefits.
https://www.typescriptlang.org/tsconfig#noImplicitThis
I feel we should enable this setting because writing code with implicit this makes it impossible for the TypeScript language server to find references for code which uses implicit this. See the example with
this.clear()
below.With this setting enabled, I'm getting the following number of errors on master (cfc3480):
Implicit this of an object
teleport/web/packages/teleport/src/services/websession/websession.ts
Lines 35 to 48 in cfc3480
On the line with
this.clear()
,this
is of typeany
. As such, if you want to find references to theclear
function, this callsite won't be listed there. The solution to this is to replacethis
withsession
. In Connect, we did so for a long time sincerouting
inuri.ts
uses a similar pattern:teleport/web/packages/teleterm/src/ui/uri.ts
Lines 95 to 100 in cfc3480
Implicit this inside a function
This happens mostly in highbar.ts and it's exactly what the docs of
noImplicitThis
describe. It can be solved by using an arrow function.The text was updated successfully, but these errors were encountered: