Commit graph

1 commit

Author SHA1 Message Date
Josh Goldberg ef83109dbf
Prefer a likely literal over anonymous type in --noImplicitAny codefixes (#36015)
* Prefer a likely literal over anonymous type in --noImplicitAny codefixes

Before trying to make an anonymous type for a type's usage, we'll first check if there is exactly one builtin primitive the usage is assignable to, and use it if so. Right now that's only `number` and `string` because `boolean` has no distinguishable members.

A couple of implementation details:
* `tryInsertTypeAnnotation` needed to know to insert a type _after_ a node's `exclamationToken` if it exists
* This code area was written before `??` 😉

* Used unknown/any instead of void when applicable

* Fix little whitespace change in tests/cases/fourslash/codeFixInferFromUsagePropertyAccessJS.ts

* Undid some now-unnecessary unknown additions

* Took advice on restricting void to just call expressions
2020-04-22 11:28:11 -07:00