* Add separate flag serverMode for server mode to allow back compatibility
* Addressed code review feedback.
Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
* Limit auto import provider project size
* Add test
* Make option configurable
* Fix test
* Only bail when setting is auto
* Fix other test
* Update API baseline
* added Error 5084 to diagnosticMessages.json
* added test case errorForBareSpecifierWithImplicitModuleResolution1 to tests/cases/compiler
* modified checker.ts to report error 5084 when classic resolution and incorrect path are used
* added baseline changes
* passes all test cases including src/testRunner/unittests/ tests
* Update with feedback
* Make it check whether it is the right module resolution kind
* Use the right diagnostic message in tsserver tests
Co-authored-by: Meera Shivakumar <mshivaku@umich.edu>
Co-authored-by: Orta <git@orta.io>
* Use disableReferencedProjectLoad to stop loading child projects to allow users to disable loading large solutions
Fixes#39144
* Handle indirect references
* Support loading of child project if found project is not pure solution has some of its own files and project references
Fixes#38605
* Fix grammar
* Use disableReferencedProjectLoad to stop loading child projects to allow users to disable loading large solutions
Fixes#39144
* Handle indirect references
* PR feedback
* Add tests corresponding to repro from #37928
* Triple slash references must resolve against the resolved file name (.d.ts and not original source file) since they are rewritten in the .d.ts emit
* Remove the scenario not fixed in this PR
* Resolve only relative references in open files on syntax server
* Support resolving tripleslash references only in the open file
* Apply suggestions from code review
Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
* JSDoc uses same newlines as normal scanner
Previously, scanJsDocToken treated each newline character separately, so
the sequence \r\n would be treated as two lines. This is unexpected, and
not the way the normal scanner does it.
This change makes the jsdoc scanner behave the same as the normal
scanner.
* fix lint in test
* Add full implemention of Map and Set to shims
* Update default Map interface
* Remove WeakMap/WeakSet
* Add tests for set shim
* Update most usages of Map<K, true> to Set
* PR Feedback
* Fix lint issues
* Change key in fsWatchCallback
* Simpler shim, more tests
* Fix typo in collection shim
* Start experiment
* Add logging
* Go back to a single program
* Fix forEachExternalModuleToImportFrom
* Move auxiliary program to language service
* Add logging
* Don’t use resolution cache
* Fix(?) containingProjects for ScriptInfo in auxiliary program
* Fix ScriptInfo project inclusion
* Add test for default project of auto-importable ScriptInfo
* Add fourslash server test
* Don’t create auto import provider inside node_modules
* Add monorepo-like test
* WIP
* Naively ensure autoImportProvider is up to date after package.json change
* Start limiting when auto update provider gets updated
* Respond to changes in node_modules
* Don’t create auto-import provider until a file is open that would use it
e.g., don’t create them during cross-project find-all-refs
* Clean up naming, @internal marking, and fix empty project creation bug
* Drop devDependencies, include peerDependencies
* Add additional compiler options
* Fix interaction with importSuggestionsCache
* Move option to UserPreferences, allow inclusion of devDependencies
* Don’t filter out peerDependencies
* Watch unparseable package.jsons
* But don’t filter packages out due to an invalid package.json
* Update test
* Don’t use autoImportProvider in codefixes where it can never be used (or any refactors)
* Add CompletionEntry property for telemetry
* Add assertion for isPackageJsonImport to fourslash
* Fix missing pushSymbol argument
* Add isPackageJsonImport to tests and API baselines
* Fix unit test
* Host auto import provider in new Project kind
* Fix InferredProject attaching on AutoImportProvider-included files, load eagerly
* Update Public APIs
* Simplify PackageJsonCache host
* Remove unneeded markAsDirty
* Defer project finished event until after AutoImportProvider is created
* Make AutoImportProviderProject always report isOrphan = true
* Close and remove AutoImportProviderProject when host project closes
* Don’t set pendingEnsureProjectForOpenFiles
* Use hasAddedOrRemovedFiles instead of hasNewProgram
* Use host-wide watchOptions for package.json watching
* Add to `printProjects`
* Clean up
* Get autoImportProvider directly from LanguageServiceHost
* Clean up
* Clean up
* Close auto import provider on disableLanguageService
* Move AutoImportProvider preload to project updateGraph
* Clear auto import suggestion cache when provider program changes
* Fix tests
* Revert yet-unneeded change
* Use projectService host for module resolution host
* Don’t re-resolve type directives if nothing has changed
* Update src/server/project.ts
Co-authored-by: Sheetal Nandi <shkamat@microsoft.com>
* Use ts.emptyArray
Co-authored-by: Sheetal Nandi <shkamat@microsoft.com>
* Add deprecated related feature
* Add more support
* fix navtree
* Add identifier check
* Add more deprecated
* fix crash
* fix more crash
* fix crash
* improve diagnostic
* avoid new tag
* avoid tags
* accept baseline
* Check deprecated in binder
* fix baseline
* fix jsdoc cache
* fix incorrect fix
* Avoid useless changes
* Accept baseline
* Add tests
* fix perf
* fix public api
* Adjust deprecated mark on qualifed name
* Revolve alias symbol
* Use modifier flags insted of symbol props
* Fix modifier flag resolve
* Make lint happy
* Fix crash
* fix crash
* Add cached utils function
* Accept baseline
* Add more tests
* try pinning octokit again
* Avoid tests
* Use utils some
* Deprecated perf test (#3)
* check valueDeclaration only
* check without modifierFlags
* donot check alias
* use cached tag
* remove call to jsdoc
* use deprecated tag
* revert changes
* Revert mission changes
* use node flags
* cache result
* cache
* avoid modifier flags
* Opts
* fix jsdoc include modifier
* fix tests
* fix again
* use symbol flag
* set @octokit/rest back to latest
* fix trailing spacel int
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
* Refactor node factory API, use node factory in parser
* Move UnparsedSource nodes to factory
* Make most Node properties read-only
* Make pos/end/parent and JSDoc 'comment' read-only
* Update function/constructor-type factories
* Remove treeStateObserver
* Simplify Debug.deprecate
* Remove unused factory methods, simplify lazy factory methods
* Fix base factory used for source file updates
* Update test baseline due to merge from master
* Rename factory methods to be more consistent (#39058)
* If there is no changes to folder structure when watching directories recursively, send the updates to fileNames only
Fixes#37994
* Ignore excluded directories from wild card watching
* Testcase showing that renaming file with non sync directory watcher displays correct error in the end
Testcase for #38684
* Syntax only server creates inferred project with all the open files with noResolve and can handle semantic operations
* No Watching
* Disable tests
* Add and fix tests
* Only support selected commands
* Revert "Disable tests"
This reverts commit 90d8a966eb.
* Dont log request details for unsupported commands
* Emit buildinfo when there are errors with noEmitOnError?
TODO: --build mode
* Always emit tsbuild info even if there are non syntax errors in tsc --build mode
* Sort affectedFilesPendingEmit for consistent build info text
* Initial draft of named tuple members
* Show tuple labels and documentation in completions
* Swap allowed syntax to parameter-like
* Add quickfix for labeled tuple syntax mistakes
* Add refactoring to convert list of signatures to single overload
* Fix small bug in visitor verification
* Signature help for rest parameters which are unions of tuples are displayed as seperate entries now
* Expand sanity check test cases in conformance suite
* Add tests and code for preserving tuple names through spreads where possible
* More refactoring tests, some comment preservation and some fixed formatting of multiline tuples
* Handle missing parameter named in isValidDeclarationForTupleLabel
* Minor text fixes
* Ensure formatter can always get a newline character
* Make FormatContext.host optional since it’s not necessary if format options are all applied
* Make FormattingHost required again
* Allowed comment directives to be multiline
* Added tests, and perhaps fixed a test runner bug?
* I think it's going to need a consistent variable to loop over
* Used dynamically computed indexes in verifies
* Added multiline tests
* Increased flexibility for multiline comment parsing
* Undid a couple of formatting changes; removed backslashes from multiline regexp
* Added baseline tests for multiline comment skipping
Co-authored-by: Orta Therox <orta.therox@gmail.com>
* Filter out edits that are no-ops in 'organize imports'.
* Updated tests for 'organize imports'.
* Always remove no-op changes from the change tracker.
* Add a new `stringContainsAt` helper function to avoid traversing the entire file contents.
* Combine `map`/`filter` sequence into `mapDefined`.
* Fix up documentation.
* Remove needless structure/destructuring
Just pass multiple arguments! Sheesh!
* Basic working prototype
* Cleaned up version
1. Add test
2. Change protocol. navto-all only happens when filename is undefined or
missing.
3. Change location to earlier code path. This change was largely
type-guided and resulted in some duplicated code, but I think it's less
fault-prone.
* remove temp notes
* Single-project hits if projectFileName is provided
and file is not
* use original code as fallback
* Add test case that shows failure to handle commentDirectives in incremental parsing
Testcase for #37536
* Handle comment directives in incremental parsing
Fixes#37536
* Add test case when the errors are not refreshed if global file is deleted
Testcase for #36728
* When the global file is deleted mark all files as changed
Fixes#36728
* Update other baselines to fix file info
* Add test for #35011
When searching for a default configured project, stop at
`node_modules`.
* Be more explicit about inferred projects
* Move test into tsserver/projects.ts
* Use existing helpers to simplify tests
* Add test that calling getAffectedFiles on two different files (even if the second one is saved) returns all files
* If emitting declaration file, update the d.ts signature in state to not have to save all files when different file changes without changing its shape
Fixes#30508
* Add test for project reference and auto import
Test for #34677
* Add project reference redirect to the possible file name to import if file is source of project reference redirect
Fixes the auto import suggestion when project is built
* Use fileExists that mimics presence of project reference redirect file when trying to get auto import file name
* Convert symlink scenarios to virtual FS where its symlinks are correctly maintained
Adds test for #36866
* Fix the casing issue when redirects differ in casing of the file
* Make ModuleSpecifierResolutionHost internal
* Refactoring for ModuleSpecifierResolutionHost
* If any of the file path option is from node_modules folder, consider only paths in node_modules folder
* Update src/services/utilities.ts
Co-Authored-By: Andrew Branch <andrewbranch@users.noreply.github.com>
Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>
* Add test where file from referenced project of solution belongs to inferred project instead of referenced project
* Try to find project from project references if the default config project is solution
Fixes#36708
* Add test to verify the correct collection of projects
* Handle when default config project is indirectly referenced in the solution
* Include public API tests in unittests
* Make sure default project for script info is calculated correctly
* Handle reload projects
* Ensure to load solution project tree when project is referenced by solution
* Find all refs when the file is referenced via d.ts
* Some comments per feedback
* Fix typo
* 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
* 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
* Hoist initial assignment to exported names in cjs to they are not blocked by bindings made by __exportStar
* Copy hoisted identifiers so they do not create sourcemaps
* Accept updated baselines
* Add tests for specifying composite as command line option
* Allow passing --composite false on commandline
* Add test to verify tsc --composite false from command line
* Handle "undefined" as option value to be set to undefined for that option
* Support "null" as option to be converted to undefined which is normally end result from our config file as well
* Support null as option for any tsconfig only option as well, and dont support undefined
* Fix public api test case
* Validates objects instead of stringify result
* Add composite true to base source
* Fix tests when there are project references but has disableSourceOfProjectReferenceRedirect
* Handle getScriptVersion correctly to ensure program structure is checked correctly
Fixes#36748
* Harness's language service host doesnt have getProjectVersion.
This means earlier we were creating fresh program everytime we did LS operation
Now we reuse same program, so quick info depends on order of quickinfo demands
* Because same program is used, it unvails a bug that if `export=` is evaluated before finding references, it cant find all definitions from the merge
* Update src/server/project.ts
Co-Authored-By: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
* Make clearSourceMapperCache required
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
* Add test case to verify directory casing preservation when watching
* Fix unicode file name handling when watching failed lookup locations
* Add special file name lower conversion routine and use that instead of toLowerCase
Fixes#31819 and #35559
* Remove unicode from code
* Replace toLocaleLowerCase on filenames with ts.toFileNameLowerCase
* Make the intent of using toFileNameLowerCase more clear and why we make the restriction on turkish I with dot on top of it
* Update baselines for newly added tests in master
* Refactor the test
* Add tests for syntax errors in tsconfig not being reported
* Report config file parsing diagnostics correctly
Fixes#36515
* Fix errors in existing tests for unintended tsconfig parse errors
* Fix lint
* Handle when files get checked in different orders
* Fix interface extends clause
* Fix import= something type only from a module
* Revert apparently unnecessary addition
* Revert "Revert apparently unnecessary addition"
This reverts commit 7444b0b72e.
* Disallow `import = a.b.c` on anything with type-only imports
* Safety first
* Add test for TS Server single-file open
* Add big comment
* Extract error reporting function for import aliases
* Delete blank line
* Un-export, comment, and colocate some utils
* Combine 3 type-only marking function calls into one
* Add more export default tests
* WIP
* Test no longer crashes, but emit trampoline is incomplete and skips pipeline phases
* Fix lints, use non-generator trampoline in emit (still skips pipeline)
* Final version with emitBinaryExprssion work stack that is only used if possible
* Fix lints
* retarget to es2015 for testing
* Use bespoke state machine trampolines in binder and checker
* Remove now extraneous code in parser
* Adjust fixupParentReferences to use a depth first preorder traversal rather than breadth first
* Reintroduce incremental fast bail in fixupParentReferences
* Revert target to es5
* PR feedback
* Small edit for devops rebuild with updated definition
* Fix comment nits, add internally extraneous check back into transformer
* If script info is not attached to the project on which wild card is invoked, update it.
* Instead of getting default project before starting error list timer, get it at that time if no project is specified
Fixes#35794
* Fix the open File watch triggered setting
* Add test that demonstrates npm install watch behaviour some times
* Use watch invoked with `node_modules/.staging` as watch for refreshing complete node_modules, so that npm install is reflected correctly
Fixes#35966
Add a response property indicating how much of the elapsed time (from
`onMessage` to `doOutput`) was spent in `updateGraph` calls. If there's
no `updateGraph` call, the property is undefined, to save space (with
the downside that it's harder to tell whether a given telemetry event
could have had the property).
Fixes#34774
* Add type-only support for export declarations
* Use a synthetic type alias instead of binding type-only exports as a type alias
* Works for re-exports!
* isolatedModules works fine
* Diagnostic for type-only exporting a value
* Start isolated modules codefix
* Update for LKG control flow changes
* Type-only import clause parsing
* Type-only default import checking
* Type-only named imports
* Fix isolated modules error
* Filter namespaces down to type-only
* Fix class references
* Test nested namespaces
* Test circular type-only imports/exports
* Fix getTypeAtLocation for type-only import/export specifiers
* Fix type-only generic imports
* Update public APIs
* Remove unused WIP comment
* Type-only namespace imports
* Fix factory update calls
* Add grammar errors for JS usage and mixing default and named bindings
* Update updateExportDeclaration API baseline
* Fix grammar checking import clauses
* Enums, sort of
* Dedicated error for type-only enum
* Skip past type-only alias symbols in quick info
* Update error code in baseline
* WIP: convertToTypeOnlyExport
* isolatedModules codefix (single export declaration)
* isolatedModules code fix (all)
* Stop eliding non-type-only imports by default, add compiler flag
* Update to match updated diagnostic messages
* Update more baselines
* Update more tests
* Auto-import as type-only
* Add codefix for splitting type-only import with default and named bindings
* Add more services tests
* Add targeted error message for "export type T;" when T exists
* Add targeted error for "import type T = require(...)"
* Flip emit flag
* Add test for preserveUnusedImports option
* Fix flag flip on import =
* Make compiler option string-valued
* Fix merge conflicts
* Add --importsNotUsedAsValue=error
* Phrasing of messages.
Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
* Baselining tsc --watch output
* Add noIndirectImports as a option to skip checking and generating .d.ts files for files indirectly importing affected file
Fixes#33329
* Rename option to assumeChangesOnlyAffectDirectDependencies
* Description change as per feedback
* Add support for Call Hierarchies in language server
* Use baselines for callHierarchy tests
* Clean up commented code
* Support multiple hierarchy items when an implementation can't be found
* Use optional chaining in a few places
* Use getFileAndProject
It was previously not populated correctly if preserveSymlinks with useSourceOfProjectReference was true,
in that case if module was resolved to symlink and we deduced it refers to source of project reference we want to set "resolvedFileName" correctly
otherwise it results in incorrect module not found errors.
* Add tests for noEmitOnError
* Do not write files directly from builder when noEmitOnError is true
Fixes#34823
* make linter happy
* Instead of generating output in memory, check errors before doing the emit in case of noEmitOnError
* Create different watch options in compiler options
* Thread through the new watch options
* Actually use the options passed through for watch strategy
* Support delay on updating child directory watches
* Make watchOptions separate from compilerOptions
* Support passing watch options from command line
* Handle displaying of watchOptions
* Add isInferredProject, isConfiguredProject and isExternalProject
* Skip refreshing configured project on change of config file if its not loaded
* Open a tree of projects when doing findAllRefs or rename operations
* Fix addToSeen project key
* Refactor combineProjectsOutputWorker
* if the definition is local, no need to load and look in other projects
* Add disableSearchSolution as option to disable looking for solution
* Rename the option to disableSolutionSearching
* Add isInferredProject, isConfiguredProject and isExternalProject
* Add test for rename on file with case change that fails
Test for #25460
* Dont store fileName on text storage
* Store root file names in the root file map to reflect their name
* Delay open file triggering watches
* Correct the name of source file as we query it (eg. it could be same source file returned in old program with different casing on case insensitive file name)
* More tests
* Refactoring
* Cache bind And check diagnostics and always get program diagnostics from the program
* Another test
* Try to report conflicting file error on file instead of global diagnostics
* Create better tests for module resolution diagnostics check
* Fix lint errors
* Move most harness globals into namespaces
* Remove forward declaration from `createMapShim` and move all `Map` declarations into one file
* A small pile of more changes to get the harness transforming
* Adds did you mean to the CLI args parser
* Adds test coverage for the did you mean on CLI args
* Adds did you mean to convertOptionsFromJson
* Ensure tsconfig compiler flags also get 'did you mean?'
* Use empty object for invalid package json contents instead of undefined
Fixes#34726
* Behave as if package json doesnt exist in case of invalid json in package json
When transforming a module declaration and block, parse tree nodes
contained in the module block have their parent pointers reset due to
`shouldEmitModuleDeclaration` calling into `isInstantiatedModule`, which
needs to set parent pointers to operate.
That causes a crash when later transforming any nodes within the module,
as retrieving their source file in `getSourceFileOfNode` (via
`getOrCreateEmitNode`) fails, due to their new synthesized parent nodes
not being in a source file.
This change avoids the issue by using the parse tree node in `ts.ts` to
decide whether a module declaration should be emitted (i.e. whether the
module contains values).
This means transformers cannot add values to modules that previously did
not contain any.
Fixes#34644.
The word multi-line and multiline are used interchangeably within the file. Multiline seems to be the most used spelling of the word across the TypeScript repository codebase so a few strings have been updated to keep consistency within a single file. Additionally, corrected a minor capitalization mistake.
Msbuild currently uses a combination of `--listFiles` and `--noEmit` to
obtain a list of files to be consumed by tsc. However, these two flags
don't suppress type checking, the results of which msbuild will never
consume. This new switch gives msbuild a faster way to obtain the file
list.
Note: like `--noEmit`, doesn't make sense in build mode.