* Node-based @deprecated checks
Switch the checker to syntactic checks for `@deprecated` on
declarations. This requires a bit more checking of declarations in the
checker at times, but it
1. Gets rid of work, and a symbol flag, in the binder.
2. Skips work in the checker unless there is a `@deprecated` tag.
3. Makes it fairly simple to only issue errors on particular signatures
of overloaded functions.
* remove in-progress comment
* remove unused isTypeDeclaration
* ❤️ lint
* support jsx and tagged template functions
* Support decorators too
* 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>
* use canonical file name when resolve module
* renameSync in vfs supports same folder.
* Update src/harness/vfsUtil.ts
Co-authored-by: Ron Buckton <ron.buckton@microsoft.com>
* change tss rather than compiler.
* remove useless comment.
* use fileName rather than path.
Co-authored-by: Song Gao <song.gao@laserfiche.com>
Co-authored-by: Ron Buckton <ron.buckton@microsoft.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)
* fix: range of ts2657 (jsx expr must have parent) and remove 2695 (LHS expr of comma has no side effects)
* feat: add code fix for 2657
* fix: resolve review
* chore: hoist a var
* chore: add test for skipTrivia
* fix: rebase error
* Update src/compiler/diagnosticMessages.json
Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>
* Update src/services/codefixes/wrapJsxInFragment.ts
Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>
Co-authored-by: Andrew Branch <andrew@wheream.io>
Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>
* 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
* feat(37782): add quick-fix action to declare a private method for names that start from underscore
* better merge order in messages json
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
* Add support of contextual quick info
* Avoid document comment map
* Make lint happy
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
* fix: convertFunctionToEs6Class cannot recognize `x.prototype = {}` pattern
* test: add test for convert fn to es6
* chore: add more tests
* chore: move tests around
* chore: make code more clear
* Prefer a likely literal over anonymous type in --noImplicitAny codefixes
Before trying to make an anonymous type for a type's usage, we'll first check if there is exactly one builtin primitive the usage is assignable to, and use it if so. Right now that's only `number` and `string` because `boolean` has no distinguishable members.
A couple of implementation details:
* `tryInsertTypeAnnotation` needed to know to insert a type _after_ a node's `exclamationToken` if it exists
* This code area was written before `??` 😉
* Used unknown/any instead of void when applicable
* Fix little whitespace change in tests/cases/fourslash/codeFixInferFromUsagePropertyAccessJS.ts
* Undid some now-unnecessary unknown additions
* Took advice on restricting void to just call expressions
* Fix prepending unused TypeScript variables with underscore doesn't rename JSDoc @param.
Fix test for quick fix "Prefix all unused declarations with '_' where possible".
Fixes#33021.
* Replace FindAllReferences.Core.eachSymbolReferenceInFile function call to more ligher call of getJSDocParameterTags when searching for a parameter in jsdoc.
* Remove redundant constant declaration.
* Add test for prefix single unused parameter in jsdoc.
* add two tests: Refactor: Remove braces from arrow function
* refactor: simplify test and add another test
* fix: copyTrailingAsLeadingComments in addOrRemoveBracesToArrowFunction
* test: add additional test
* fix: clean up changes
* fix: add check for newEdit
* fix: add function for semi colon modifier
* feat: grab all comments during refactor
* refactor: update addOrRemoveBraces logic
* fix: remove duplicate function call
* Update src/services/refactors/addOrRemoveBracesToArrowFunction.ts
* remove blank line
remove blank line
Co-authored-by: Jesse Trinity <42591254+jessetrinity@users.noreply.github.com>
This fixes two bugs in the parseJSDocCommentWorker().
1. The initial indent was calculated wrongly. It was set to the
difference between the index of the last newline or beginning of file
and the current start marker (position of /**). By calculating it
this way, the newline character itself is counted as indentation
character as well. The initial indent is used as margin for the
whole comment. The margin contains the amount of characters to skip
before the actual content or payload of a comment line. The algorithm
does not skip non-whitespace characters at the beginning of the
content, but it would strip away one whitespace character for
indented content (which does matter, if there is e.g. a Markdown
code block with indentation in the comment).
2. When reducing initial whitespace sequences of comment lines by the
remaining margin the algorithm cut off one character too much. This
might have been introduced to fix 1. It had a similar effect as 1.
* stash
* add surmise for return type
* add support for more case
* add more test case
* add more testcase and fix all test
* fix changed diagnosis
* fix broken test case
* add more case
* rename quickfix
* fix conflict
* fix fix desc
* fix semi
* Avoid replace brace with paren
* Split fix all action
* Add return work in same line
* fix test cases
* rename baseline
* refactor and handle comment
* Support semi
* make helper internal
* Accept change
* Accept the huge set of ever so slightly changed baselines
* Update return type logic to only reuse nodes if original nodes share scope with current node, like property types, only reuse nodes if symbols referened are acessible, reuse nodes for property signatures, too
* Only reuse nodes when a context is provided (otherwise identifier printback may fail)
* Only track symbol if symbol is found and no error is recorded
* Fix type parameter reuse lookup
* Forbid cjs module.exports references in retained nodes
* Adjust check for cjs export references to not include bad module type in output
* Add symbol to all identifiers we see in existing nodes for quickinfo
* Accept fourslash baseline updates
* Accept slightly updated baseline post-merge
* Do not copy original nodes for error types, replace empty type references with any
* Special-case window, self, global, globalThis methods
* Disambiguate global and this property completions in details requests
* Hide the Map<boolean> implementation
* Update old tests
* Replace SymbolOriginKind stringification with dedicated enum
* Support completions for local named exports
* Add JSDoc
* Use sort text instead of filtering
* Revert new CompletionKind
* Return valid completions even when export declaration is in an invalid place
* fix: hyphened name not auto-completed by the ls
* fix: accept new baseline
* Adds a test to validate the hypened identifiers in JSX
Co-authored-by: Orta Therox <orta.therox@gmail.com>
* Allow emitter to write multiple newlines in node lists
* Progress
* Progress
* Fix recomputeIndentation
* Add tests, fix leading line terminator count
* Do a bit less work when `preserveNewlines` is off
* Fix accidental find/replace rename
* Restore some monomorphism
* Fix single line writer
* Fix other writers
* Revert "Fix other writers"
This reverts commit 21b0cb8f3b.
* Revert "Fix single line writer"
This reverts commit e535e279f9.
* Revert "Restore some monomorphism"
This reverts commit e3ef42743a.
* Add equal position optimization to getLinesBetweenRangeEndAndRangeStart
* Add one more test
* Actually save the test file
* Rename preserveNewlines to preserveSourceNewlines
* Make ignoreSourceNewlines internal
* Optimize lines-between functions
* Add comment;
* Fix trailing line terminator count bug for function parameters
* Preserve newlines around parenthesized expressions
* Back to speculative microoptimizations, yay
* Don’t call getEffectiveLines during tsc emit at all
* Add codefix for --noImplicitThis
* Code review
* Back to building post-merge
* Remove redundant functions + update tests
Infer-from-usage also inserts `this: any` parameters when needed, so I
removed that from fixImplicitThis.
Otherwise, fixImplicitThis has better suggestions than inferFromUsage,
so I moved inferFromUsage later in the suggestion order.
* More redundancy removal
Don't need to add `@this` anymore either since inferFromUsage will do
that.
* More baseline updates
From moving inferFromUsage down in priority I think?
* remove now-redundant ad-hoc jsdoc emit
* fix more bad merge
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
* Add tests that fail because of symlink to non common directory node_modules
* When the imported module is through node_modules and symlink to folder that isnt node_modules
Most of the monorepo like scenarios are like this so looking at symlink to decide if file can be imported is essential
Fixes#28689
* getPropertiesOfUnionOrIntersectionType: handle types with index signature
Fixes: #31565
* fix test
* more testing
* fix typo in checker.ts
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
* add trim trailing whitespace option
* set default trimTrailingWhiteSpace to true
* add fourslash tests
* accept new baselines
* only preserce whitespace when setting is explicitly false
* format whitespace
Signed-off-by: Andrew Deniszczyc <adeniszczyc@bloomberg.net>
Cleanup of implementation
Move check node container check
Add test cases for fixExpectedCommaError
Renaming and add test case
Co-authored-by: Andrew Deniszczyc <adeniszczyc@bloomberg.net>
Resolves issue #28031 by overriding default value of
`useNonAdjustedStartPosition` option to replaceNode. Test case included
that confirms intended behaviour.
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`.