* feat(7481): add explicit type compatibility check with 'satisfies' expression
* Add failing test for lack of intersectioned contextual type
* Implement the behavior
* Add test corresponding to the 'if'
* Add test based on defined scenarios
* remove isExpression in favor of using type casting
* move tests from compiler to conformance folder
* update baseline
* add missing contextFlags argument
* use asserted type
* accept baseline
Co-authored-by: Ryan Cavanaugh <ryanca@microsoft.com>
* Update error messages for CJS imports resolving to ES modules
* Update error message
* Use package scope from source file
* Update baselines
* Issue error for JSX/TSX files
* Switch from related info to message chain
* Add test where module resolution cache is not local and hence doesnt report errors in watch mode
* Ensure module resolution cache is passed through in watch mode
* Remove unnecessary setting of impliedFormat which should anyways be done as part of create source file
* Add test for packge.json changing and modifying implied format
* Distinguish between package.json watch and affecting file location watch
* Pass in failed lookup and affected file locations for source file's implied format
Also stop creating options if we already have them
* Add diagnostic for explaining file's implied format if based on package.json
* Watch implied format dependencies for modules and schedule update on change
* For program if implied node format doesnt match create new source file. Handle implied node format in document registry
Fixes#50086
* Modify tests to show package.json being watched irrespective of folder its in
* Check file path if it can be watched before watching package.json file
* Because we are watching package.json files and failed lookups its safe to invalidate package json entries instead of clearing them out everytime program is created
* Remove todos
* Fix the incorrect merge
* Pickup PackageJsonInfo renames from #50088
* Rename
* add bug repro test
* add test and start fix implementation
* adjust for useAlias preference
* fix existing renaming test
* refactor to get rid of options
* fix named bindings & other imports cases
* fix eslint error
* address cr comments
* hopefully actually fix eslint
* clean up stale baseline
* make API change non-breaking
* add/fix comments
* Use fixed time for vfs so baselining is consistent
* Baseline buildinfos
* Write new file text in baseline even if the file wasnt read on the shadow
* Remove unnecessary debugger statement
* Make sure that incremental correctness is checked with correct writeFile so we know buildInfo was written
Also baseline these so its easy to verify the changes
* More baselines for the tsbuildinfo
* If we are writing dts file and have used file text as version, we can update the signature when doing actual emit
* Make WriteFileCallback Api ready for future
* Assert that there is only single source file when emitting d.ts file
* Add test
* Renames
* More refactoring
* If we are updating dts of any of the file and it affects global scope, everything needs update in signature and dts emit
Fixes#42769
* Stacktrace optimization for getModified time in anticipation of using it more than fileExists wherever possible
* Baseline getModifiedTime, setModifiedTime, fileExits and directoryExits for experiment
* Remove unnecessary write file finger print code since its not used at all
* Use modified time instead of file existence check
* Remove unnecessary getModifiedTime
* No need to check for file existence before reading the d.ts file
* Do project reference errors before doing input/output file checks
* Dont call getModifiedTimes if dts change
* Passdown modified time if queried
* Use modified time passed through the file watching in tsbuild
* Handle force build as separate upto date status
* uptodate status worker to read buildinfo and use it to determine upto date ness
* No need to update output timestamps if buildinfo will determine uptodateness
* Store change file set instead of hasPendingChange to be able to reuse the information
* Add test that shows input file is not present
* No need to check input time stamp before buildinfo
* Keep buildinfos for lifetime of the solution builder and project
* Store modified time along with text of buildinfo
* Non composite projects dont need to track declaration change time
* Pass through buildInfo so we dont have to parse it back
* Save dts change time in buildinfo itself
* Store dts time for --out in the buildInfo
* Store hash of text in the bundle info so it can be verified before manipulating text for fast updates during prepend
This helps when text changes during incremental build toggling and we determine we can just manipulate text
* Since buildinfo is cached no need to maintain version check state
* Store output time stamps for non incremental builds
* Revert "Baseline getModifiedTime, setModifiedTime, fileExits and directoryExits for experiment"
This reverts commit 7e65cd3315ccf387f6d7e7c40263e85bcc3c961c.
* Change verbose messages for upto date status
* Reconcile reusable builder state and builder state so there are not two different types that are almost similar looking
* Cleanup impliedFormat
* Cleanup
* Cleanup noEmit option
* BuildInfo options emit as a flag
* Factor out types for program written in buildinfo with and without bundle emit
* No need to store output file stamps if not in watch mode
* Cleanup
* Test for single watch per file
* Fix emit and error update baselines that were duplicate
* More refactoring
* Only copy emit state fields when backing up to restore if emit fails
* Instead of maintaining delta of changes, maintain old state for those changes
* Add test to verify build when input file does not change
* If version of the input file does not change, dont mark as out of date
* Disable lint warning as build fails without the assert
* Report aggregate statistics for solution as well as some solution perf numbers
* Options solutionDiagnostics instead so that its not too verbose when printing diagnostics
* When tsc --build --clean, only remove tsbuildinfo if its incremental build
* Revert "Options solutionDiagnostics instead so that its not too verbose when printing diagnostics"
This reverts commit 0cf9e301038267bc1d9439c15d279940809b0c00.
* Revert "Report aggregate statistics for solution as well as some solution perf numbers"
This reverts commit 405d8e91978708a613fe8cb631a83b13c430a808.
* Revert "When tsc --build --clean, only remove tsbuildinfo if its incremental build"
This reverts commit e4e66726098201f38f5e8908a538e7a506f15efd.
* Comments in the code
* Feedback
* changed error message for interface extending primitive type
* moved interface check to different function
* changed part of interface declaration to is extended by interface
Co-authored-by: harsheetkakar <harsheetkakar@bitbucket.com>
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
* Improve reduction of intersection types
* Accept new baselines
* Improve CFA for truthy, equality, and typeof checks
* Accept new baselines
* Remove special case for Function type
* Don't reduce intersections of form {...} & object
* Accept new baselines
* Anything is assignable to unknown-like union
* Accept new baselines
* Tweak subtype check
* Recombine unknown type from unknown-like union in more cases
* Display union origin only if it is shorter than union itself
* Accept new baselines
* Add tests
* Only attach origin type when it is shorter than union itself
* Specially preserve string & {}, number & {}, bigint & {}
* Accept new baselines
* Add additional tests
* Fix getNormalizedType and getNarrowableTypeForReference for intersections
* Switch NonNullable<T> to use T & {}
* Accept new baselines
* Use NonNullable<T> in place of anonymous T & {}
* Accept new baselines
* Add fourslash test
* More fourslash tests
* Fix getFalsyFlags handling of intersections
* Accept new baselines
* Add constraint to compareProperties type parameter
* Unconstrained type parameter not assignable to {} with strictNullChecks
* Accept new baselines
* feat: support error when comparing with object/array literals
* chore: include regexp, function and class literal
* chore: include regexp, function and class literal
* test: update baseline
* fix: baseline
* Allow export map entries to remap back to input files for a program
* Fix file casing issues on windows
* Implement abiguity error, doesnt quite work
* Refine selection logic in error case to use getCommonSourceDirectory, add more tests
* Remove Node12, add Node16.
* Accepted baselines.
* Refactor checking for top-level await, give a better error message in CJS files.
* Accepted baselines.
* Stop erroring on JSON module imports in node ESM since they're no longer experimental.
* Accepted baselines.
* More refactoring, do the same checks for for-await loops.
* Accepted baselines.
* Adjust phrasing to permit for-await on CJS error.
* Accepted baselines.
* Accepted baselines.
* Fix lints.
* change error message on Promise
* fix(46570): Unhelpful Promise type argument hint in JS file
* refactor: Reword void Promise message for JSDoc type hint to provide better feedback
Co-authored-by: Osa <osaimola@gmail.com>
* Add 'extends' clause to 'infer' type
* Revise parse for infer..extends, improve parenthesizer
* More aggressive parens to match existing DT tests
* tests 'infer' constraint using outer type parameter
* Adds a test showing 'infer' cannot reference other 'infer' in same 'extends'
* Emit extends clause for synthetic infer typesduring declaration emit
* Add moduleSuffixes compiler option and related tests. Update baselines for compiler options tests.
* Add a flag to the command-line parser which allows "list" params to preserve "falsy" values such as empty strings. Falsy values are normally stripped out.
* Add tests. Rework resolver logic to only run module-suffix code when needed.
* PR feedback
* Add test
* Remove unnecessary conditional.
* Simplify getVariancesWorker and associated logic
* Accept new API baselines
* Add 'in' and 'out' modififers / add modifiers to type parameters
* Check variance annotations
* Update test runner
* Accept new API baselines
* Allow variance annotations only on certain type parameters
* Add deprecated implementation of createTypeParameterDeclaration
* Accept new API baselines
* Report variance markers as 'sub-XXX' and 'super-XXX'
* Add tests
* Accept new baselines
* Add isolatedModules error for ambiguous imports referenced in decorator metadata
* Improve test and accept baselines
* Error only for es2015+
* Add namespace import to error message as workaround
* Add codefix
* Fix merge fallout
* Add moduleDetection compiler flag to allow for changing how modules are parsed
The default setting is 'auto', where JSX containing files under react-jsx and react-jsxdev are
always parsed as modules, and esm-format files under module: node12+ are always parsed as modules,
in addition to the 'legacy' detection mode's conditions for other files. (Declaration files are exempt from
these new conditions)
The 'legacy' mode preserves TS's behavior prior to the introduction of this flag - a file is
parsed as a module if it contains an import, export, or import.meta expression.
In addition, there is a 'force' mode that forces all non-declaration files to be parsed as modules.
(Declaration files are still only modules if they contain a top-level import or export.)
This technically breaks the parser API, but it's kinda-sorta backwards compatible so long
as you don't need the functionality associated with more recent compiler flags.
* Fix post-merge lint
* Rename function
* Update default value documentation
* PR feedback
* Fix lint and typo
* Add import assertions for type-only imports and import types to change resolver modes
* By popular request, only allow mode assertions on top-level type only imports
* Add specifier options parameter to specifier generation
* Permit type arguments in references to generic functions
* Accept new baselines
* Delete pointless fourslash test
* Fix lint issue
* Finalize implementation
* Add tests
* Accept new baselines
* Properly handle instantiation of instantiation expression types
* Accept new API baselines
* Fix lint error
* Add more tests
* Properly handle unions/intersections of generic types
* Add more tests
* More permissive parsing of type arguments in member expressions
* Update tests
* Accept new baselines
* Triple-slash reference type directives can override the import mode used for their resolution
They now use the file's default mode by default, rather than always using commonjs. The new arguments to the
reference directive look like:
```ts
///<reference types="pkg" resolution-mode="require" />
```
or
```ts
///<reference types="pkg" resolution-mode="import" />
```
* Omit redundant import modes in emitter
* Add test for #47806
* Add server test for triple-slash reference mode overrides
* Move FileReference mode into helper
* Update tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeOverride3.ts
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
* Eliminate redundant or meaningless elaborations in type relations
* Accept new baselines
* Add resetErrorInfo (though, oddly, shouldn't be necessary)
* Less aggressive reduction in second pass union/intersection checks
* Accept new baselines
* Restructure and back off a little bit more
* Only cache union/intersection relations once
* Accept new baselines
* Properly cache identity relations, clean up error reporting
* Move more logic to cached side of relation checks
* Optimize and remove more redundant elaborations
* Accept new baselines
* Remove unnecessary error state capture
* More optimizing
* Cache isWeakType computation
* Revert "Cache isWeakType computation"
This reverts commit 25a71c4de61f6366ffac080d19685dcb200f42b9.
* Address CR feedback
* Accept new baselines