Instead of trying to walk the type structure in the codefix, I changed
to call getTypeFromTypeNode in the checker and then calling
typeToString. Together, these two functions normalise out JSDoc.
Note that you only get `T | null` for `?T` if you have --strict on. This
is technically correct -- adding a null union does nothing without
strict -- but it would still serve as documentation.
For ?, provide two code fixes, one for jsdoc/closure semantics
(`?t -> t | null)` and one for flow semantics
(`?t -> t | null | undefined`).
The current way of doing this is the hackiest thing you can imagine, but
it was easier than lifting everything into the list monad for a code fix
that I might not actually keep.
1. Still pretty janky.
2. Type Reference code doesn't work yet.
3. Other transforms just aren't done.
4. Always replaces, even when there isn't any transformation of JSDoc
types. (This probably isn't an issue since we wouldn't issue an error unless there were
some JSDoc to change.)
This means that JSDoc types can include the full range of Typescript
types now. It also means that Typescript annotations can include JSDoc
types. This is disallowed with a new error, however. But Typescript can
still give the correct types to JSDoc that shows up in .ts files by
mistake. This can easily happen, for example with types like
```ts
var x: number? = null;
var y: ?string = null;
var z: function(string,string): string = (s,t) => s + t;
// less likely to show up, but still understood.
var ka: ? = 1;
```
In the future, I will add a quick fix to convert these into the correct
types.
Fixes#16550
* Completion for default export should be '.default'
* Don't include empty string in name table
* getSymbolsInScope() should return local symbols, not exported symbols
* Fix bug: getSymbolAtLocation should work for local symbol too
* Created a branded type for escaped strings
Then flowed it throughout the compiler, finding and fixing a handful of
bugs relating to underscore-prefixed identifiers in the process.
Includes a test for two cases noticed - diagnostics from conflicting
symbols from export *'s, and enum with underscore prefixed member emit.
* Correctly double underscores WRT mapped types
* Add fourslash tests for other fixed issues
* use function call over cast
* Update forEachEntry type accuracy
* Just use escaped names for ActiveLabel
* Remove casts from getPropertyNameForPropertyNameNode
* This pattern has occurred a few times, could use a helper function.
* Remove duplicated helper
* Remove unneeded check, use helper
* Identifiers list is no longer escaped strings
* Extract repeated string-getting code into helper
* Rename type and associated functions
* Make getName() return UnderscoreEscapedString, add getUnescapedName()
* Add list of internal symbol names to escaped string type to cut back on casting
* Remove outdated comments
* Reassign interned values to nodes, just in case
* Swap to string enum
* Add deprecated aliases to escapeIdentifier and unescapeIdentifier
* Add temp var
* Remove unsafe casts
* Rename escaped string type as per @sandersn's suggestion, fix string enum usages
* Reorganize double underscore tests
* Remove jfreeman from TODO
* Remove unneeded parenthesis