Commit graph

3853 commits

Author SHA1 Message Date
ShuiRuTian f29e03eea5
autocomplete works for const assertion. (#39412)
* fix 39384

* add test
2020-07-06 08:49:50 -04:00
Nathan Shively-Sanders 93ccc17658
Node-based @deprecated checks (#39323)
* 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
2020-07-02 14:09:59 -07:00
Alexander T d137e4a23b fix(39346): show completion in inherited classes from the composited base interface 2020-07-02 11:40:17 +03:00
Nathan Shively-Sanders df5981319f
Fix crash on completion in jsdoc namepath (#39347)
contextToken may be undefined, so the isAssertionExpression call in
filterGlobalCompletion needs to check for undefined.
2020-06-30 15:53:13 -07:00
Andrew Branch e2c5a90cc3
Disable signature help on unresolved bare identifiers; add more declaration info on other unresolved calls (#39352)
* Disable signature help on unresolved bare identifiers; add more declaration info on unresolvedproperty access

* Remove stray ts-ignore
2020-06-30 14:25:27 -07:00
Alexander T 8b6a88700e
fix(32297): add quick-fix action to delete parameter destructuring elements (#38764) 2020-06-30 11:44:47 -07:00
Daniel Rosenwasser 1bbd5ef36b
Merge pull request #38754 from a-tarasyuk/feat/25259
feat(25259): Better error report for equals instead of colon in object literals
2020-06-30 01:56:26 -07:00
Alexander T 21a26ca08a feat(25259): add better error to report for equals instead of the colon in object literals 2020-06-30 10:33:56 +03:00
Daniel Rosenwasser 619658bd44
Merge pull request #39109 from Kingwl/lambda_span
Add outlining spans for call expression or arrow body
2020-06-29 23:33:04 -07:00
Daniel Rosenwasser 57dd722ab6
Merge pull request #38776 from a-tarasyuk/bug/29890
fix(29890): JSX: "extract to constant" generates invalid code
2020-06-29 14:09:52 -07:00
Wesley Wigham 99bec5067b
Use mapped rest type member when expanding rest parameter names (#39317)
* Use mapped rest type member when expanding rest parameter names

* Add test for #39228 which is also fixed by parameters having unique names
2020-06-29 12:30:23 -07:00
Alexander T ee5c3fa57d
fix(39047): handle extra spaces after the catch statement (#39306) 2020-06-29 10:10:44 -07:00
Alexander T c75af697af fix(29890): wrap variable/method/property to jsx expression 2020-06-28 10:51:11 +03:00
Andrew Branch 3d22a4fd72
Preserve newlines between try/catch/finally, if/else, do/while (#39280)
* Preserve newlines between try/catch, if/else, do/while

* Update baselines
2020-06-26 14:48:19 -07:00
Alexander T 95690c0aca
fix(38840): omit completions for a spread like argument in a function definition (#38897) 2020-06-26 09:38:05 -07:00
Alexander T 59f80970d9
fix(38785): include in NavigationBar child items from default exported functions (#38915) 2020-06-26 09:35:27 -07:00
Andrew Branch 086e00de91
Expand auto-import to all package.json dependencies (#38923)
* 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>
2020-06-22 16:34:27 -07:00
Ron Buckton fe33e61823
Reparse top level 'await' in modules (#39084)
* Reparse top-level 'await' in modules

* Add more tests and additional diagnostics

* One more incremental parse test
2020-06-18 23:43:18 -07:00
Wenlu Wang 59ad375234
Add deprecated related feature (#38523)
* 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>
2020-06-18 17:41:26 -07:00
Jacob Bandes-Storch 8136047a3d
Code fix for accidental calls to get-accessors (#38749)
* add code fix

* fix forEachChild and update some baselines

* excluding them from forEachChild is easier!

* cleanup

* review feedback

* fix whitespace
2020-06-18 13:58:42 -07:00
ShuiRuTian 8293e517c0
fix rename cause import change wrongly (#38462)
* 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>
2020-06-18 08:31:30 -07:00
kingwl 4d57d591d2 Avoid semi 2020-06-18 10:33:17 +08:00
kingwl 98a74ddfe8 Update baseline 2020-06-17 22:41:08 +08:00
kingwl 3b8ad5c870 Add outlining spans for call expression or arrow body 2020-06-17 20:50:19 +08:00
Ron Buckton eb3645f16b
Refactor node factory API, use node factory in parser (#35282)
* 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)
2020-06-16 16:55:03 -07:00
Andrew Branch 852e7a0b60
Add containerName to CallHierarchyItem (#38997)
* Add containerName to CallHierarchyItem

* Update public APIs

* Update test to demonstrate nested namespace working
2020-06-10 11:56:03 -07:00
Nathan Shively-Sanders d841971347
Merge pull request #38358 from a-tarasyuk/bug/38081
fix(38081): 'Debug Failure. Invalid cast.' for convert import quick fix
2020-06-09 08:50:56 -07:00
Eli Barzilay a4c14a2cdc getSymbolDisplayPartsDocumentationAndSymbolKind: use actual symbol.flags for getAliasedSymbol
Fixes #35347.
2020-06-04 13:50:33 -04:00
Jesse Trinity 3b15b35b37
Merge pull request #38378 from jessetrinity/refactorTriggerReason
Add RefactorTriggerReason
2020-06-03 11:18:08 -07:00
Eli Barzilay 073fb308bf Fix two tests
* `docCommentTemplateInSingleLineComment`: Accidentally dropped space, fixes #38651

* `codeFixCorrectReturnValue13`: Bogus test code copied
2020-06-03 12:59:16 -04:00
Jesse Trinity d88ea4e1f8 address PR comments 2020-06-02 19:06:12 -07:00
Jesse Trinity 463f8e10b9
Merge pull request #38734 from a-tarasyuk/bug/34934
fix(34934): Completions for private members appear in JavaScript files
2020-06-02 12:47:17 -07:00
Alexander T bc502c8c3c fix(38081): allow transforming object binding to named imports 2020-06-02 11:23:56 +03:00
Jesse Trinity 52dad733db
Merge branch 'master' into m-lambda-to-fn 2020-06-01 13:53:19 -07:00
Jack Works 8e290e5aae
Improve error range for ts2657 (jsx expr must have parent element), add code fix for it (#37917)
* 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>
2020-06-01 12:22:44 -07:00
Alexander T 4f0b81d415
fix(32341): add prefix name for module exports properties (#38541) 2020-06-01 11:45:05 -07:00
Alexander T fa49ac0b78
fix(19385): add space after brace in the multiline string template (#38742) 2020-06-01 10:30:52 -07:00
Alexander T 68d2ee055c
fix(38815): dive in arrow functions to check only this usage instead of checking all statements (#38865) 2020-06-01 10:27:11 -07:00
Jesse Trinity a86a2fa703 polish tests 2020-05-29 13:03:14 -07:00
Jesse Trinity 2db0054444 remove outdated tests 2020-05-29 13:03:11 -07:00
Jesse Trinity f479279217 convert import trigger reason test 2020-05-29 13:03:08 -07:00
Jesse Trinity c20908a3e7 convert export trigger reason test 2020-05-29 13:03:01 -07:00
Jesse Trinity 4971c7d546 remove declaration 2020-05-29 13:02:55 -07:00
Jesse Trinity 3e1e61470b Revert "update refactorConvertImport_partialSelection"
This reverts commit e28d8a0895f118321c37016a6dad4751a7c13673.
2020-05-29 13:02:52 -07:00
Jesse Trinity 86122c412f convert get set test 2020-05-29 12:55:52 -07:00
Jesse Trinity 673a86833a update test names 2020-05-29 12:55:48 -07:00
Jesse Trinity 3825d193f6 extract symbol test 2020-05-29 12:55:43 -07:00
Jesse Trinity df8ff659c5 extract type test 2020-05-29 12:55:39 -07:00
Jesse Trinity 85e0d8b14a add refactorNotAvailableForTriggerReason 2020-05-29 12:55:35 -07:00
Jesse Trinity dc363f10fc fix some indices 2020-05-29 12:55:32 -07:00
Jesse Trinity fbf6737ae2 use verify trigger reason for import export 2020-05-29 12:55:28 -07:00
Jesse Trinity 96f210c1c8 arrow function refactor test 2020-05-29 12:55:24 -07:00
Jesse Trinity f3751fbdf3 change type of RefactorTriggerReason 2020-05-29 12:54:59 -07:00
Jesse Trinity 665e434832 convert import tests 2020-05-29 12:50:18 -07:00
Jesse Trinity 57e856b0b4 convert export tests 2020-05-29 12:50:14 -07:00
Jesse Trinity c5343f1d4e update refactorConvertImport_partialSelection 2020-05-29 12:46:03 -07:00
Daniel Rosenwasser 6128f30c3b
Merge pull request #38821 from a-tarasyuk/bug/23716
fix(23716): signature help of tagged template doesn't show instantiated signature
2020-05-28 17:19:23 -07:00
BigAru e6dc8f6c69 Merge remote-tracking branch 'upstream/master' into m-lambda-to-fn 2020-05-27 20:33:27 +02:00
Armando Aguirre 0985afd51a Fixed uncomment bug 2020-05-26 19:26:28 -07:00
Nathan Shively-Sanders bfa1744586
Merge pull request #37894 from microsoft/always-error-on-property-override-accessor
Always error on property override accessor
2020-05-26 10:37:07 -07:00
Alexander T 6e98431cec fix(23716): show generic type in tagged template expression 2020-05-26 19:16:44 +03:00
Nathan Shively-Sanders 324d292e3d
Merge pull request #38415 from Kingwl/navTree-fix
Fix trancked es5 classes after new scope
2020-05-26 09:05:17 -07:00
Armando Aguirre ee37d8e8d3 Added comment and uncomment selection 2020-05-22 16:56:57 -07:00
Armando Aguirre fe91f317de Fixed uncomment bug 2020-05-22 16:47:35 -07:00
Armando Aguirre e5829881b5 Fixed toggleLineComment jsx cases 2020-05-22 16:46:33 -07:00
Armando Aguirre fc9753473e Added jsx to singleLineComment 2020-05-22 16:46:33 -07:00
Armando Aguirre 97de811d48 Fix multiline name 2020-05-22 16:46:32 -07:00
Armando Aguirre 33333e86eb Added toggleLineComment, toggleMultilineComment with jsx and tests 2020-05-22 16:46:31 -07:00
Nathan Shively-Sanders e466bb94c1 Fix multi-file usage
1. Follow aliases with getSupers.
2. Make fix in file with superclass, not with the error.
2020-05-22 09:06:05 -07:00
Alexander T 4c278aa33b fix(34934): exclude private properties from Js completion list 2020-05-22 15:11:39 +03:00
Nathan Shively-Sanders 802e87b1eb Merge branch 'master' into always-error-on-property-override-accessor 2020-05-21 16:08:09 -07:00
Daniel Rosenwasser 62675a58d6
Merge pull request #38481 from a-tarasyuk/bug/38463
fix(38463): No indexed access completions after Record<...>
2020-05-21 13:44:44 -07:00
Alexander T c00aeb5486
fix(33286): add outlining for arrow function with one parameter (#38631) 2020-05-21 08:07:47 -07:00
Alexander T 528d82afd1 Merge branch 'master' of https://github.com/microsoft/TypeScript into bug/38463 2020-05-20 11:04:55 +03:00
Alexander T 1c72da6e49 fix(38463): show completions for index access properties 2020-05-20 10:17:20 +03:00
Wesley Wigham 5f597e69b2
Support naming tuple members (#38234)
* 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
2020-05-19 15:54:02 -07:00
Jack Works 7ec467e270
fix: extract const in jsx (#37912)
* fix: extract const in jsx

* Update src/services/refactors/extractSymbol.ts

Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>

* Update src/services/refactors/extractSymbol.ts

Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>

Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>
2020-05-19 14:29:49 -07:00
Nathan Shively-Sanders 415b2e7969
Merge pull request #38656 from a-tarasyuk/bug/33233
fix(33233): Code Folding on es5 object functions does not work (getOutliningSpans)
2020-05-19 14:18:42 -07:00
Andrew Branch 707e977056
Ensure formatter can always get a newline character (#38579)
* 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
2020-05-19 13:14:32 -07:00
Alexander T 2b703d254a fix(33233): add outlining for comments before property access expression 2020-05-18 15:26:46 +03:00
Eli Barzilay d7dd06e36d goToDefinition: find only the value if it's the RHS of an assignment 2020-05-15 18:55:57 -04:00
Alexander T 71711257ea
fix(33836): allow readonly modifier for a field with only get accessor (#36543) 2020-05-13 13:28:32 -07:00
Daniel Rosenwasser b682ee1a8a
Merge pull request #38489 from microsoft/removeDuplicateInfo
Remove duplicate JSDoc comments
2020-05-12 12:52:15 -07:00
Nathan Shively-Sanders 3f06adf662
Merge pull request #38240 from a-tarasyuk/feat/add-outlining-spans-for-object-destructuring-elements
feat: Add outlining spans for object destructuring elements
2020-05-12 07:35:03 -07:00
Nathan Shively-Sanders cbf15bb6ed
feat(38225): change diagnostic message for remove braces from arrow function body (#38226) 2020-05-12 07:27:09 -07:00
Alexander T 5895493815
fix(37877): include in NavigationBar default exported child items (#38255) 2020-05-12 07:26:31 -07:00
Daniel 1450908e5c Added tests for union types with identical doc comments. 2020-05-11 21:36:43 +00:00
Alexander T 738b6b5b68
fix(38073): hide 'Extract to function in global scope' action for arrow functions which use 'this' (#38107) 2020-05-11 12:25:25 -07:00
kingwl 6f4deaea78 Fix tranced es5 classes after new scope 2020-05-08 17:34:41 +08:00
Eli Barzilay 29cf049e61 moveToNewFile: handle namespace imports too
Fixes #35591
2020-05-07 11:46:36 -04:00
Alexander T 683b3ec058
feat(37782): 'declare method' quick fix for adding a private method (#37806)
* 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>
2020-05-06 15:10:02 -07:00
Wenlu Wang 8d78984558
Add support of contextual quick info (#37451)
* 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>
2020-05-06 15:05:31 -07:00
Alexander T d86bdf4e5c
add outlining spans for the tuple type (#38179) 2020-05-05 09:48:33 -07:00
Alexander T 2bdc8fdc94
add outlining spans for array destructuring elements (#38191) 2020-05-05 09:29:24 -07:00
Daniel Rosenwasser 94c5c3ff47
Add missing arguments to typeToTypeNode. (#38336)
* Add missing arguments to typeToTypeNode.

* Use returnTypeNode as the enclosingDeclaration.

* Add a test.
2020-05-04 19:32:27 -07:00
Wesley Wigham d9c9c9d9e4
Harden node builder APIs to no longer return undefined for a node when NodeBuilderFlags.IgnoreErrors is provided (#38273) 2020-05-04 14:47:39 -07:00
Alexander T 5e0e254ef7
fix(38177): add auto-import for missing argument type in new functions/methods (#38213) 2020-05-04 12:37:04 -07:00
Alexander T 0503da225d feat(36266): add a quick fix for incorrect return types in async functions 2020-05-04 13:18:52 -04:00
Jack Works 6f7faa7636
Fix: convertFunctionToEs6Class cannot recognize x.prototype = {} pattern (#35219)
* 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
2020-04-30 11:06:46 -07:00
Alexander T ef72e84314 Merge branch 'master' of https://github.com/microsoft/TypeScript into feat/add-outlining-spans-for-object-destructuring-elements 2020-04-28 17:15:25 +03:00
Alexander T 57f161eaa8 feat(38225): change diagnostic message for remove braces from arrow function body 2020-04-28 10:44:36 +03:00
Alexander T 31b81bafe7
fix(38138): show suggestions for identifier in class property initializer (#38157) 2020-04-24 13:50:34 -07:00
Andrew Branch ce95d9ca6b
Fix values and types merging in JS module exports (#37896)
* Fix values and types merging in JS module exports

* Fix everything

* Share `setValueDeclaration` between binder (local merge) and checker (cross-file merge)

* Revert accidental changes to baselines

* Update baseline from master merge
2020-04-24 13:49:48 -07:00
Andrew Branch 9569e8aaa4
Fix newline issues when adding multiple imports (#38119)
* Add new import declarations in a single TextChanges call

* Refactor
2020-04-23 11:59:38 -07:00
Josh Goldberg ef83109dbf
Prefer a likely literal over anonymous type in --noImplicitAny codefixes (#36015)
* 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
2020-04-22 11:28:11 -07:00
Alexander T d2016912b5
fix(37825): exclude private fields from completions in subclasses (#37906) 2020-04-22 12:07:36 -04:00
Alexander T 92a63741a2
fix(38080): add outlining spans for TypeLiteral (#38089) 2020-04-22 11:51:36 -04:00
Andrew Branch 7d4fc73331
Fix preserveNewlines printer option when a list child has the same start or end as its parent (#37846)
* Fix preserveNewlines printer option when a list child has the same start or end as its parent

* Fix leading line separator calculation and JSX bug
2020-04-21 15:34:30 -07:00
Alexander T 1e48057b9e
fix(15398): skip adding line breaks when replacing JS checks directives (#38086) 2020-04-21 11:02:56 -07:00
Alexander T 52d32e5597 Add outlining spans for object destructuring elements 2020-04-21 12:57:52 +03:00
Andrew Branch 547fd12c2f
Fix doc comment template on assignment expressions (#38032) 2020-04-20 11:15:12 -07:00
sergeir82 b346f5764e
prefix-unused-parameter-with-_ codefix now works in jsdoc @param (#36152)
* 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.
2020-04-17 13:18:05 -07:00
Alexander T a16c44180a
fix(37940): add space after parameter decorator (#37959) 2020-04-15 11:42:29 -07:00
Joe Previte 583e70b3d1
fix(refactor): keep comments after refactor (#35937)
* 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>
2020-04-15 11:06:04 -07:00
Alexander T a8e1ad4e62
fix(37781): import missing argument types for a new method (#37857) 2020-04-13 10:23:12 -07:00
Alexander T aa6be6ee6f
fix(37364): show completions for string literal index on mapped type (#37367) 2020-04-10 12:36:26 -04:00
Neonit d6af9b7cbc Fix indentation preservation in JSDoc (#37717)
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.
2020-04-10 17:46:08 +02:00
Nathan Shively-Sanders 3030cd8eff refactoring done except for deduping 2020-04-09 16:43:31 -07:00
Nathan Shively-Sanders e287c8321a Codefix invokes generate get-set accessor refactor
1. Add add-all test
2. Add codefix that delegates to get-set accessor refactor.

Needs massive amounts of cleanup and deduplication.
2020-04-09 15:06:45 -07:00
Nathan Shively-Sanders 71b7695113 add fourslash tests for codefix 2020-04-09 11:24:54 -07:00
Andrew Branch 57f9076612
Remove extraneous string escape from convert to template string refactor (#37743)
* Add failing test

* Remove extraneous string escape

* Revert unnecessary change
2020-04-09 09:40:28 -07:00
Alexander T e897eb1b2a
fix(37817): omit comments in name accessor (#37822) 2020-04-07 16:59:54 -07:00
Wenlu Wang afc41f095d
Quick fix for functions lacking return expressions (#26434)
* 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
2020-04-02 10:06:14 -07:00
Zixiang Li 54b0e4acc5
Fix goto implementation does not suggest all subtypes (#33652) 2020-04-02 09:57:48 -07:00
Andrew Branch 3810c2fe6b
Fix rename for type symbols imported as a different name (#37745)
* Add failing test

* Fix getMeaningFromLocation for imports

* Only the name of an ImportEqualsDeclaration counts

* Commit baseline
2020-04-02 09:06:19 -07:00
Alexander T 72a0411776
fix(37431): allow only one space between async keyword and method name (#37504) 2020-04-02 11:30:05 -04:00
Wesley Wigham 78a99241d8
Reuse input type nodes when serializing signature parameter and return types (#37444)
* 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
2020-04-01 19:50:21 -07:00
Wenlu Wang 5596ed80d7
Add replacement span for string literal (#37490)
* Add replacement span for string literal

* fix change requests

* fix lint

* Avoid flag

* Fix baseline

* ADd misising baseline
2020-04-01 17:58:16 -07:00
Andrew Branch 23b500cadf
Don’t offer this. completions on self, window, global, globalThis. Disambiguate this. completions from others in details requests. (#37652)
* 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
2020-03-31 12:40:57 -07:00
Jesse Trinity ef377d5a66
Don't delete comments when deleting unused declarations (#37467)
* don't delete comment on variable declaration

* add more declaration kinds

* don't copy comment in convertes6 class

* don't copy comments in convertToES6Class

* add tests

* use isAnyImportSyntax

* handle mixed comment types

* update tests
2020-03-31 10:18:06 -07:00
Andrew Branch 0f3a9d4d4b
Support completions for local named exports (#37606)
* 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
2020-03-27 10:47:02 -07:00
Sheetal Nandi 84a3252e76
Handle packages inside another node modules package when auto importing (#37561)
Fixes #37542
2020-03-25 16:27:02 -07:00
Andrew Branch a04225dbec
Don’t suppress completions after yield (#37609) 2020-03-25 15:27:47 -07:00
Jack Works 38e717a244
fix: hyphened name not auto-completed by the ls (#37455)
* 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>
2020-03-23 17:08:44 -04:00
Andrew Branch 292d01880f
Add code fix for importsNotUsedAsValues error (#37468) 2020-03-19 13:13:15 -08:00
Andrew Branch 237ea526f9
Preserve newlines from original source when printing nodes from TextChanges (#36688)
* 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
2020-03-19 09:46:00 -07:00
Alexander T 0aa2e2783c
feat(37409): add fix all quick fix to fixInvalidJsxCharacters (#37436) 2020-03-18 09:54:17 -07:00
Alexander T c8e43d878f
fix(37194): fix crash on go to the definition in variable assignment (#37253) 2020-03-17 16:16:28 -07:00
Andy Hanson b0450aed56
Add codefix for --noImplicitThis (#27565)
* 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>
2020-03-17 13:00:14 -07:00
Sheetal Nandi 2458c8a016
When the imported module is through node_modules and symlink to folder that isnt node_modules (#37387)
* 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
2020-03-16 11:15:39 -07:00
Klaus Meinhardt 8b6bd41ce7
getPropertiesOfUnionOrIntersectionType: handle types with index signature (#31979)
* 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>
2020-03-13 14:30:53 -07:00
Jesse Trinity 4c160683c3
Add trimTrailingWhitespace Editor Option (#36905)
* 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
2020-03-13 13:42:49 -07:00
Alexander T fc30095e8b
feat(33792): add new quick fix service to handle missing call in condition (#37152) 2020-03-13 13:38:44 -07:00
Andrew Branch db44231e38
Add outlining spans for case clauses (#37374)
* Add outlining spans for case clauses

* Update old test

* Update other test

* Update yet another of the same test
2020-03-13 10:52:27 -07:00
Alexander T b41eb1bc61
feat(36249): add quick-fix action to declare a property as private which starts from underscore (#36632) 2020-03-13 10:33:56 -07:00
Joey Watts 31963d54b8
Add implementation for fixExpectedComma (#33879)
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>
2020-03-12 14:55:02 -07:00
David 4406717f13
add config to insert space for empty braces (#35427) 2020-03-12 16:35:35 -04:00
Alexander T 8d63a7a842
fix(28163): change outdated options (#37268) 2020-03-07 10:23:07 -08:00
Jonathan Share c0c5760d15
Fixes duplicated comment when executing code fix to add missing enum member (#28163)
Resolves issue #28031 by overriding default value of
`useNonAdjustedStartPosition` option to replaceNode. Test case included
that confirms intended behaviour.
2020-03-06 16:53:37 -08:00
Eli Barzilay 5c8def9a06 Fix emitting ?.
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`.
2020-03-04 14:52:33 -05:00