* Remove unnecessary redirection now that we are not in namespaces
* Move the tsc helpers in one place
* Move virtual file system with watch in unittests folder instead of harness since harness doesnt use it anyways
* Replace protocol and commandNames
* Revert incorrect pick
This eliminates a significant number of dependencies, eliminating all
npm audit issues, speeding up `npm ci` by 20%, and overall making the
build faster (faster startup, direct code is faster than streams, etc)
and clearer to understand.
I'm finding it much easier to make build changes for the module
transform with this; I can more clearly indicate task dependencies and
prevent running tasks that don't need to be run.
Given we're changing our build process entirely (new deps, new steps),
it seems like this is a good time to change things up.
This configures the existing build tasks to use esbuild by default. If
using the plain files is desired, passing `--bundle=false` will build
using plain files and still produce a runnable system.
This is only a basic build; a more efficient build is provided later
when gulp is replaced by hereby.
Although the existing require calls would work fine, it's more
consistent to make them actual imports and let them be converted at
compile/bundle time. It also lets us emit ESM if needed.
There are still conditional requires present for things like the node
System, but that's a more difficult problem to solve.
If these are regular comments, then they won't appear in our d.ts files.
But, now we are relying on an external d.ts bundler to produce our final
merged, so they need to be present in the "input" d.ts files, meaning
they have to be JSDoc comments.
These comments only work today because all of our builds load their TS
files from scratch, so they see the actual source files and their
non-JSDoc comments.
The comments also need to be attached to a declaration, not floating,
otherwise they won't be used by api-extractor, so move them if needed.
This step converts as many explicit accesses as possible in favor of direct imports from the modules in which things were declared. This restores the code (as much as possible) back to how it looked originally before the explicitify step, e.g. instead of "ts.Node" and "ts.Symbol", we have just "Node" and "Symbol".
This step converts each file into an exported module by hoisting the namespace bodies into the global scope and transferring internal markers down onto declarations as needed.
The namespaces are reconstructed as "barrel"-style modules, which are identical to the old namespace objects in structure. These reconstructed namespaces are then imported in the newly module-ified files, making existing expressions like "ts." valid.
* Add test that fails
* Handle impliedNodeFormat when handling sourceFileCache
Fixes#50872
* Revert the fix
* Make sure impliedNodeFormat is set for the sourceFile
* Revert "Make sure impliedNodeFormat is set for the sourceFile"
This reverts commit 651a47fdd6ea200e59fdf150dfa913230a86653a.
* Revert "Revert the fix"
This reverts commit 5c98b9cfc1f275877d8d57a60f8f28a5c8d08157.
* Swap the keys for map
* added test case to try to retrieve duplicate refactor as in #50416. 'verify.refactorAvailable' correctly retrieves nonduplicate refactors...
* optional arguments in refactorAvailable return `true` even if there is no single refactor that satisfies both
* it still passes :C
* Delete fixExtractToInnerFunctionDuplicaton.ts
* deleted extra test code
* fix 'verify.refactorAvailable' so that tests correctly check for multiple arguments
* fixes#50416
* refactor
* Remove unnecessary parameter
* Dont store name unnecessarily in the watchers
* Polled watches and not files
* Use fs events as default watching
* Some refactoring
* Make single per directory native watchers now that we are using it as default
* Rename
* Comment
* 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>
* Add test where clearing affected files watcher that also is shared by real path causes Debug failure
* Ensure that file watcher is closed only once for affected file locations that share watcher because of different names but same real path
* Lift up package json map
* 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 a simple queue implementation with better performance than `Array.shift`
This lets us clean up the hack introduced in #49581
* Correct typo
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
* 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
* Prototype TS plugins on web
This prototype allows service plugins to be loaded on web TSServer
Main changes:
- Adds a new host entryPoint called `importServicePlugin` for overriding how plugins can be loaded. This may be async
- Implement `importServicePlugin` for webServer
- The web server plugin implementation looks for a `browser` field in the plugin's `package.json`
- It then uses `import(...)` to load the plugin (the plugin source must be compiled to support being loaded as a module)
* use default export from plugins
This more or less matches how node plugins expect the plugin module to be an init function
* Allow configure plugin requests against any web servers in partial semantic mode
* Addressing some comments
- Use result value instead of try/catch (`ImportPluginResult`)
- Add awaits
- Add logging
* add tsserverWeb to patch in dynamic import
* Remove eval
We should throw instead when dynamic import is not implemented
* Ensure dynamically imported plugins are loaded in the correct order
* Add tests for async service plugin timing
* Update src/server/editorServices.ts
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
* Partial PR feedback
* Rename tsserverWeb to dynamicImportCompat
* Additional PR feedback
Co-authored-by: Ron Buckton <ron.buckton@microsoft.com>
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
* Merge 'decorators' into 'modifiers' on various Nodes
* Drop RESERVED argument in favor of removing parameter
* Ignore grammar error nodes when asserting invariants
* Revert 'illegalX' property renames
* PR Feedback
* Convert some of the watchEnvironment tests to baselines for updating later
* Add tests for inode watching by making fsWatch part of system function that tests presence before creating fs watch
* Refactor for simpler tests
* Accept map of file content or file or symlink or folder
* Add test when rename event occurs when file has already reappeared
* On rename event for the file, replace file watcher irrespective of file presence
* Fix regex
* Ensure that when doing inode watching watchers is replaces only on disappearance or appearance
* Some logging for debugging further
* Revert "Some logging for debugging further"
This reverts commit dd2164ac83666725c4cc58e0223425b10530d682.
* Add test when rename event occurs on mac with ~ appended to file name
* If the relativeFileName ends with tilde, remove it from the event
* Some logging for debugging further
* Revert "Some logging for debugging further"
This reverts commit e1ba8a8d5f2f30cc039a89a1e8e4e6c64ba7c44d.
* Add documentation and fail safe the event firing
* 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
* Handle timesouts to reflect the time it was set with
* Remove unused internal calls from solution builder
* If the project doesnt need building or updating bundle, dont schedule it but do it right away
* Reduce the time between project builds to 100ms
* Some tests for projects building
* Schedule builds such that when change is not detected 5 projects are built at a time
* Fix tests in main
* Clean up FAR and RenameLocations
This change had two goals:
1. Make the code easier to understand, primarily by simplifying the callback structure and minimizing side-effects
2. Improve performance by reducing repeated work, both FAR searches of individual projects and default tsconfig searches
This implementation attempts to preserve the merging order found in the original code (someone less relevant in the present state of using syntactic isDefinition).
* Stop enforcing search and aggregation order
...in preparation for implementing isDefinition explicitly.
Also restore convention of referring to `DocumentPosition`s as "locations".
* Introduce LanguageService.updateIsDefinitionOfReferencedSymbols
...to allow use of the checker when computing isDefinition across projects.
* Update baselines
* Tidy diff
* De-dup simplified results
* Baseline cross-project isDefinition results
* Move de-duping upstream to fix Full output
* Add server baseline test to confirm searches are not repeated
* Manually merge #48758
* Update baseline for newer fix to #48963
* 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.
* WIP
* fix cross-project renaming logic
* only use configure if prefix opt is defined
* refactor skipAlias into stopAtAlias
* fix stopAtAlias
* update another stopAtAlias location
* 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
* 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
* Prototype resolving to JS when go-to-def aliases all resolve to ambient declarations
* Add test infrastructure
* Start fleshing out test coverage
* Fix some go-to-def stuff
* Finish lodash test case
* Make go-to-implementation never return ambient results
* Build new functionality into go-to-implementation
* Update baselines
* Two more test cases
* Refine definition searches for unresolved imports
* Revert "Build new functionality into go-to-implementation"
This reverts commit 381799d0f104000c676334c8e08fcdff9ccac896.
* Fix tests
* Revert go-to-implementation changes
* Wow a bunch of code was unnecessary
* Update baselines and go-to-def test
* Fix navigation on symbols that are not aliases but resolve through aliases in chain
* Temporarily replace go-to-def with new command implementation
* Revert "Temporarily replace go-to-def with new command implementation"
This reverts commit 34c6cfdebbb9e2506ea5e6d528d2cb57b2cdeb2e.
* Revert "Wow a bunch of code was unnecessary"
This reverts commit 1cb2ba646c9e80d1ca08b6fc3f6a2219aac44f67.
* Bring back some deleted code needed for a new test case
* Clean up a little
* Rename more stuff
* Update test
* Update API baseline
* Temporarily replace go-to-def with new command implementation
* PR review fixes
* Fix getTopMostDeclarationNamesInFile
* Rename local
* Use hash set
* Remove option from commandLineParser
* Keep noDtsResolution project around
* Handle AuxiliaryProject kind in ScriptInfo getDefaultProject etc.
* Do not run updateGraph in the background for AuxiliaryProject
* Don’t create auxiliary project outside of semantic mode
* No-op on scheduled invalidation
* Add comments to unit test
* Sync compiler options to auxiliary project
* Fix case sensitivity
* Update extensionIsOk with new file extensions
* PR feedback
* Update API baseline
* Mark scheduleInvalidateResolutionsOfFailedLookupLocations internal
* Use same heuristics on property accesses of loosely-resolvable aliases as unresolvable named imports
* Rename command, and no need to return the bound span
* Update API baseline
* Don't report isDefinition unless the starting node is a declaration
* Drop isDefinition everywhere it isn't specifically needed
* Fix tsserver tests
* Update shim comment
* Update baselines
* Add tests for isDefinition
* Update doc comment
* Clear isDefinition from all references if the first one lacks it