4277 Commits

Author SHA1 Message Date
TypeScript Bot
6e0328af6a
Cherry-pick PR #49252 into release-4.7 (#49272)
Component commits:
94cf1272e5 Fix `isVariableDeclarationInitializedToBareOrAccessedRequire` returning true on binding elements

fae1bbedc1 Undo auto format change

Co-authored-by: Andrew Branch <andrew@wheream.io>
2022-05-26 16:43:37 -07:00
TypeScript Bot
697df6ff41
Cherry-pick PR #49233 into release-4.7 (#49244)
Component commits:
1ab6396efe Fix extensions for noDtsResolution in node16/nodenext

Co-authored-by: Andrew Branch <andrew@wheream.io>
2022-05-25 15:27:54 -07:00
TypeScript Bot
dbee2ab7fd
Cherry-pick PR #49035 into release-4.7 (#49036)
Component commits:
e8df495a1a Fix module specifier generation crash from typesVersions

Co-authored-by: Andrew Branch <andrew@wheream.io>
2022-05-09 12:49:02 -07:00
Andrew Branch
2ffe6864b1
Respect importModuleSpecifierEnding inside node_modules packages (#48995)
* Respect importModuleSpecifierEnding inside node_modules packages

* Add tests for missing package.json
2022-05-06 12:58:12 -07:00
Andrew Casey
58114cf387
Harden combineProjectOutputForReferences against empty results (#48978)
Getting an empty result doesn't seem expected, but a deeper fix doesn't make sense until #48619 is merged.

Fixes #48963
2022-05-05 13:52:34 -07:00
Andrew Branch
e26bc8a117
Skip missing nodes in formatting (#48953) 2022-05-04 15:07:34 -07:00
Andrew Branch
d879880a37
Don’t let other completions shadow type keywords in type locations (#48939)
* Allow type keywords with the same names as other completions

* Only add type keywords that are the same as other completions in type locations
2022-05-04 08:35:29 -07:00
Mateusz Burzyński
9469f95bd4
Add tests case for function check type being correctly paranthesized in quick info (#48836) 2022-05-03 17:05:37 -07:00
Daniel Rosenwasser
5f9c9a6ccf
Start Node ESM stable version at Node16 (#48879)
* 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.
2022-05-03 16:29:40 -07:00
Gabriela Araujo Britto
8f56f6b49d
Don't go past import in cross-project renaming (#48758)
* WIP

* fix cross-project renaming logic

* only use configure if prefix opt is defined

* refactor skipAlias into stopAtAlias

* fix stopAtAlias

* update another stopAtAlias location
2022-05-03 07:32:44 -07:00
Nathan Shively-Sanders
e73d755668
Fix formatter's processChildNodes (#48921)
processChildNodes needs to skip processing when the node array is
outside the target range, just like processChildNode already does for a
single node.

Fixes #48006
2022-05-02 12:50:24 -07:00
Mateusz Burzyński
63a941dc2a
Add a regression test for completion list in object literal involving inferred obj with optional members (#48910) 2022-05-02 12:27:49 -07:00
Felipe Armoni
fd06132ce9
Fix #47753 - Organize imports removes type imports that are only referenced in @link (jsdoc) (#47824)
* Added unit test

* Added baseline test

* Dirty solution

* Code refactoring and improvements

* Added more test cases

* Refactor to use flatMap

* Added utility function to get all Nodes with JSDocs

* Minor improvements

* Use recursion to check all tree levels

* Removed unit test

* Removed previous changes

* Updated resolveEntityName call

* Updated dontResolveAlias clause

* Updated symbol flags

* Updated baseline

* Fix dont resolve alias problem

* Updated tests
2022-04-29 13:45:00 -07:00
Oleksandr T
9b3853d49e
fix(48851): exclude in from document highlights (#48853) 2022-04-27 17:51:05 -07:00
Andrew Branch
476fc625df
Eagerly resolve module specifiers for auto-import completions in --moduleResolution node12+ (#48752)
* Add failing test

* Block auto-import module specifiers including node_modules path

* Eagerly resolve module specifiers in completions in nodenext so failures can be filtered

* Add completion info flags for telemetry

* Update API baseline

* Update completions baselines

* Fix missed boolean flip

* Fix remaining tests
2022-04-27 16:07:15 -07:00
Oleksandr T
717a1be3c9
feat(48743): allow autocompletion in parameter object destructuring in JavaScript (#48757) 2022-04-27 14:00:01 -07:00
Nicola Dardanis
d45012c5e2
Add JS-specific diagnostic message for resolve() in Promise where type argument can't be inferred (#48533)
* change error message on Promise

* fix(46570): Unhelpful Promise type argument hint in JS file

* refactor: Reword void Promise message for JSDoc type hint to provide better feedback

Co-authored-by: Osa <osaimola@gmail.com>
2022-04-27 11:55:35 -07:00
Nathan Shively-Sanders
2a78b225d0
Stop tag after @callback from crashing (#48860)
By copying the kludge in @typedef. @callback's order is simpler, so the
kludge is simpler. However, it's wrong here, and in @typedef. Parsing
tag comments is normally supposed to happen at the end of a tag, but in
@callback and @typedef happens *before* parsing the nested
@param/@property tags.

I still need to figure out what a real fix is -- but for the beta,
copying the existing crash-avoidance kludge from @typedef is best
anyway. I added a test case for typedefs for future use as well.
2022-04-27 11:21:10 -07:00
Andrew Branch
c99380f87b
Fix auto-import completions sometimes not updating existing imports (#48815) 2022-04-22 15:32:52 -07:00
Mateusz Burzyński
af30c79093
Fixed string literal completions for partially-typed strings when overload could get matched (#48811) 2022-04-22 08:36:14 -07:00
Andrew Branch
7abdb9e7ef
Format completion snippet text before escaping (#48793)
* Format snippet text before escaping

* Reset `escapes` before printing so printer can be reused
2022-04-21 13:40:14 -07:00
Wesley Wigham
ce487e4fd3
Fix meta property symbol lookup (#48773) 2022-04-19 17:57:06 -07:00
Andrew Branch
8bd7ce6feb
Find Source Definition (#48264)
* 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
2022-04-14 15:44:19 -07:00
Jack Bates
c1db699482
Don't skip tests named *Fourslash.ts (#48615) 2022-04-11 11:45:44 -07:00
Gabriela Araujo Britto
dfb9f2f953
don't have type annotations on suggested object literal methods (#48607) 2022-04-11 11:33:02 -07:00
Zzzen
f4b99ea47c
preserve this when extracting functions (#41992)
* preserve this when extracting functions

* rename IsThisReferringToFunction to UsesThisInFunction

* refactor

* update tests
2022-04-07 15:05:46 -07:00
Andrew Casey
76e74370ab
Only report isDefinition when FAR is triggered on a definition (#48566)
* 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
2022-04-05 17:04:18 -07:00
Oleksandr T
9881c993fc
fix(48544): allow to convert default exports to names for import type nodes (#48550) 2022-04-05 16:53:01 -07:00
Minh Quy
50a5bc839a
fix(48540): Extract to typedef from (invalid) type with comments in JS file causes assertion failure (#48545)
* fix(48540): Remove comments from jsdoc union type expression

* fix(48540) - Remove comment for top level import and add extract typedef tests

* fix(48540) - Remove comments from jsdoc's descendant

* fix(48540) - Using no nested comments instead of traversing
2022-04-05 16:51:32 -07:00
Ron Buckton
7da80d79e2
Add 'extends' clause to 'infer' type (#48112)
* Add 'extends' clause to 'infer' type

* Revise parse for infer..extends, improve parenthesizer

* More aggressive parens to match existing DT tests

* tests 'infer' constraint using outer type parameter

* Adds a test showing 'infer' cannot reference other 'infer' in same 'extends'

* Emit extends clause for synthetic infer typesduring declaration emit
2022-04-05 12:35:28 -07:00
Minh Quy
6e0447fdf1
[Feature] - Automatically create sort groups based on newlines (#48330)
Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
2022-04-05 11:53:19 -07:00
Minh Quy
25aecd4c3e
fix(48109) - 'Convert to arrow function' refactoring adds extra indent (#48440)
* fix(48109) - Remove extra indent when converting to arrow function

* fix(48109) - Only treat curly brace in object literal as block

* Apply suggestions from code review

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
2022-04-04 17:57:34 -07:00
Andrew Casey
493ddc2447
Remove non-baselining fourslash FAR validation (#48564)
* Fix fourslash failures

* Delete unused FAR fourslash helpers
2022-04-04 16:54:10 -07:00
Oleksandr T
aa3c5a787c
fix(48418): allow using empty tuple (#48420) 2022-04-04 14:56:35 -07:00
Oleksandr T
e5ca3e4386
fix(48406): resolve JSDoc host of property signature (#48407) 2022-04-04 14:42:50 -07:00
Oleksandr T
7465f04666
fix(48542): omit parameter info of contextual union type (#48549) 2022-04-04 14:05:20 -07:00
Oleksandr T
e02998f70d
fix(48541): forbid function extraction to arrow function with expression body (#48548) 2022-04-04 12:27:49 -07:00
Andrew Casey
d5f5c6d61e
Convert many tests from verify.singleReferenceGroup to verify.baselineFindAllReferences (#48518)
* Convert referenceToClass to baselining

* Delete stray marker from findAllRefsInsideWithBlock

* Bulk convert tests that just call verify.singleReferenceGroup

* Update tests with duplicate names

* Bulk update verify.singleReferenceGroup tests with BOMs

* Semi-automatically convert FAR tests with explicit range code

* Convert findAllReferencesDynamicImport2 to baselines
2022-04-04 09:23:58 -07:00
Oleksandr T
2db17fdda2
fix(48520): fix getting parameter type by index (#48521) 2022-04-03 21:42:37 -07:00
Andrew Casey
337d1326fb
Sync fourslash shims and shims-pp (#48507)
It appears that they were intended to be identical so, in each case, I updated the side that looked less correct.
2022-04-01 11:14:14 -07:00
Andrew Casey
8020072281
Respect @BaselineFile in fourslash tests and tidy up quickInfoDisplayPartsVarShims (#48506) 2022-04-01 09:24:14 -07:00
Oleksandr T
9cfa6e25af
fix(48405): emit dummy members from a mapped type (#48481) 2022-03-31 10:15:12 -07:00
Oleksandr T
e62f960648
fix(47733): omit JSDoc comment template suggestion on node with existing JSDoc (#47748) 2022-03-30 15:36:47 -07:00
Jake Bailey
3c6c2799b6
Ensure that we copy empty NodeArrays during transform (#48490) 2022-03-30 15:33:51 -07:00
Oleksandr T
c639d3afb9
feat(27615): Add missing member fix should work for type literals (#47212) 2022-03-30 12:55:18 -07:00
Gabriela Araujo Britto
f57bdaa097
Add label details to completion entry (#48429)
* add label details to completion entry

* Use label details for obj literal method completions

* add label details support flag

* add label details support to fourslash

* support both label details and non-label details in object literal method snippets

* CR fixes

* fixes after rebasing

* fix tsserver tests
2022-03-30 12:45:56 -07:00
Gabriela Araujo Britto
e25f04a30f
Enable method signature completion for object literals (#48168)
* skeleton of new feature

* working prototype

* refactor print and format code into its own function

* minor changes; don't support overloads

* have two completion entries

* get rid of accessor support

* add snippet support

* add formatting

* add trailing comma

* add sourcedisplay

* support auto-imports via completion details

* add user preference option and fix ordering of entries

* cleanup

* don't return code actions for no import fixes

* make sortText lower priority for snippets

* get rid of flag

* use optional member sort text

* update baselines

* don't collect method symbols if insert text is not supported

* remove comment

* return undefined if type is not function type

* only slice if needed

* use union reduction; more test cases

* WIP: modify sort text system

* Improve new sort text system

* add signature and union type check

* re-add flag

* fix tests

* rename sort text helper

* fix test and code for union case

* add new flag to protocol type

* fix spaces

* CR: minor fixes

* CR: more fixes

* CR: restructure main flow

* minor fix
2022-03-29 17:19:02 -07:00
Andrew Branch
7ec7d6d8e0
Fix string literal completions when a partially-typed string fixes inference to a type parameter (#48410)
* Add failing test

* Fix string literal completions when a partially-typed string fixes inference to a type parameter
2022-03-29 09:07:38 -07:00
Andrew Branch
d962091d94
Fix newline inserted in empty block at end of formatting range (#48463)
* Fix newline inserted in empty block at end of formatting range

* Clean up

* Fix refactoring mistake
2022-03-28 13:50:17 -07:00
Wesley Wigham
a5dae37943
Prevent looking up symbol for as const from triggering an error (#48464) 2022-03-28 12:53:36 -07:00