2 ms·
It depends on your tsconfig. An empty array could be typed as never[], forcing you to annotate it.
by bastawhiz 8mo ago
It depends on your tsconfig. An empty array could be typed as never[], forcing you to annotate it.
- loevborg 8mo agoWhich setting specifically? Can you repro in the typescript playground?
- wk_end 8mo agoI don't believe this is correct. There's no settings that correspond to that AFAIK, and it'd actually be quite bad, because you could access the empty array and then get a `never` object, which you're not supposed to be able to do. https://www.typescriptlang.org/play/?#code/GYVwdgxgLglg9mABMOcAUBKAXIgzlAJxjAHNEBvAKEUQgX0TAFMA3Jg3HZtggbQF1EAXkQCA3NVr0oiAB7DGrdrl4AGfhJoEmUEASSyJAX0pA https://www.typescriptlang.org/play/?#code/GYVwdgxgLglg9mABM... `unknown[]` might be more appropriate as a default, but TypeScript does you one better: with OP's settings, although it's typed as `any[]`, it'll error out if you don't do anything to give it more information because of `noImplicitAny`.