* make splice `deleteCount` required in es5.d.ts
In ES5 `deleteCount` is not an optional argument. If it is not provided it defaults to 0 as a side effect of `undefined` being converted to an integer.
In ES6 `deleleteCount` is optional, and it defaults to the length of the array minus the start index.
If you are targeting ES5 but don't provide `deleteCount` the behaviour will be different depending on the environment your build is running in.
fixes#32638
* update baselines
* Make the systems for baselining default to pretty
* Ensure that we have seenAffectedFiles map when files are added to pending emit because they were present in the old state
This happens in build scenarios since semantic diagnostics are queried before emit and hence files are added to seenAffectedFiles pending emit
Fixes#37269
This addresses issue #28975
(https://github.com/microsoft/TypeScript/issues/28975).
When providing a value as a type argument, we can suggest a more specific
error message: "Did you mean to use typeof T?"
adds error message
WIP: Detect error
WIP: progress
updated tests
janky implementation
adds test coverage around literal types being unaffected
refactor out isIdentifierATypeArgument function
adds test case for type alias
adds test case for nested type arguments
fixes linting errors
merge master into branch to overwrite changes
changes value as type error message
This suggests 'typeof T' as a potential alternative when we give an error
about using value T as a type.
remove stale tests from old change
Co-authored-by: John Patterson <john@johnppatterson.com>
* Increase timeout for ensuring projects for open files
* Condense the project/file printing in the log (given now we have project printed anytime its structure changes)
* Use objects instead of closures for type mappers
* Flatten combined type mappers
* Single point of creation for type mappers
* More optimizations
* Fix lint error
* Fewer symbol instantiations / discard type mapper after instantiation
* More optimizations
* Simplify mapper layout and cache in composite mappers
* Removing cache as it doesn't seem to matter much
* Get rid of identityMapper
* Implement constructor type guard
* Fix code review issues for constructor type guard.
- Do not limit constructor expression to only identifiers
- Fix `assumeTrue` and operator no-narrow check
- Use better way to check that identifier type is a function
- Loosen restriction on what expr is left of ".constructor"
- Update typeGuardConstructorClassAndNumber test to include else cases
* Fix grammar & spacing in `narrowTypeByConstructor`
* fix bad merge
* switch (back?) to crlf
* update baselines
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
Using a constructor function like this can help node better optimize
object allocation. This improves memory usage when compiling
`src/compiler` from **277M** to **270M**, a nice ~3% win.
As stated in 26417, `host` is only ever written to and never read from. `createProgramHost` is the only place I could find that provides a member for `ProgramHost`'s `onCachedDirectoryStructureHostCreate`, so that's removed as well.
* Allow passing watch to the change as parameter
* Reset hasChangedAutomaticTypeDirectiveNames once new program is created
Also dont invoke afterProgramCreate if the program is not new
Resolves issue #28031 by overriding default value of
`useNonAdjustedStartPosition` option to replaceNode. Test case included
that confirms intended behaviour.
* 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>