* Added @ts-expect-error to @ts-ignore directives
Similar to `// @ts-ignore`, but will itself cause a new error diagnostic if it does not cause an existing diagnostic to be ignored.
Technical summary:
1. The scanner will now keep track of `CommentDirective`s it comes across: both `@ts-expect-error` and `@ts-ignore`
2. During type checking, the program will turn those directives into a map keying them by line number
3. For each diagnostic, if it's preceded by a directive, that directive is marked as "used"
4. All `@ts-expect-error` directives not marked as used generate a new diagnostic error
* Renamed to getDiagnosticsWithPrecedingDirectives per suggestion
* Added JSDoc comment I thought I did already
Co-authored-by: Orta <orta.therox+github@gmail.com>
Use `emit()` for writing `questionDotToken`, leading to properly calling
the emit hooks (which `emitTokenWithComment` doesn't) and printing the
comments. This fixes#35372 by calling its hooks to set the `.__pos`
and `.__end` fields.
Also, remove `getDotOrQuestionDotToken` which was used only here --
mainly because it seems likely to encourage misusing the
`questionDotToken` again.
Also, fix a bunch of `visitor` -> `tokenVisiton` calls in
`visitorPublic.ts`.
* More precise property-overwritten-by-spread errors
Trying to do this check in getSpreadType just doesn't have enough
information, so I moved it to checkObjectLiteral, which is a better
place for issuing errors anyway.
Unfortunately, the approach is kind of expensive in that it
1. creates a new map for each property and
2. iterates over all properties of the spread type, even if it's a
union.
I have some ideas to improve (1) that might work out. I'm not sure how
bad (2) is since we're going to iterate over all properties of all
constituents of a union.
Fixes#36779
* another test and rename
* Reinterpret a type parameter constrained to any as an upper bound constraint
* Use real constraqint in alias in test
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
* Optionally stop looking for the default configured project at
node_modules
* Make stopping at node_modules non-optional
* Generalize and simplify the change - node_modules files don't have default configured projects
* Remove bogus @implements errors
Make the search for the actual host more comprehensive by reusing the
code that previously only searched for functions. I don't know what to
call this function now, since the old name wasn't accurate either.
* undo gratuitous name change
* Improve name and make calling more uniform
It's slightly less efficient but I think worthwhile for readability.
* Treat never-like intersections as never
* Accept new baselines
* Fix compiler issues revealed by increased intersection correctness
* Delete fourslash tests that are no longer applicable
* Include isNeverLikeIntersection check in getNormalizedType
* Erase never-like types in several more places
* Check that base types are not never-like
* Add comments
* Revert isNeverLikeType check in getIndexType (keyof shouldn't resolve member types)
* Introduce getReducedType for union and intersection types
* Don't reduce in getApparentType
* Avoid relationship check in resolveMappedTypeMembers
* Accept new baselines
* Don't call getReducedType in getIndexType
* Ensure reduced and unreduced forms of a type can compare identical
* Reduce types before converting them to string representation
* Accept new baselines
* Reduce intersections before obtaining keyof X
* Add tests
* Accept new baselines
* Fix comment in tests
* Don't infer from empty intersection types
* Add tests
* Accept new baselines
* Defer instantiation of mapped type property types
* Accept new baselines
* Include more precise type in diagnostic
* Accept new baselines
* Minor optimization
* Improve error message
* Optional properties in intersections are never discriminants