Open steveszc opened 2 weeks ago
I should add that I am planning to write a lint rule for this and add it to my company's internal eslint plugin, so I would be happy to contribute that work in a PR here if there is agreement that we want to add this rule to eslint-plugin-ember
I have seen some typescript ember code that incorrectly uses the
declare
keyword with@tracked
properties like so:Typescript will happily compile this code even though it is incorrectly typed and will result in runtime errors since
name
is initialized toundefined
. There is really no good use-case for using@tracked declare
but it can be incorrectly used to silence the typescript compiler in situations where the@tracked
property is not initialized with a value (I'm sure there are other ways this could be abused or cause problems beyond this simple example).Since
declare
is regularly and correctly used with Ember's@service
decorator it can be unclear to Ember developers who are new to typescript or just unfamiliar with thedeclare
keyword that this particular use ofdeclare
is harmful. For this reason, I think we should lint against the use of typescript'sdeclare
keyword with the@tracked
decorator.