Commit Graph

6098 Commits

Author SHA1 Message Date
Gabriela Araujo Britto
9f025b90a4 Don't include literals from enum members in completions (#45588)
* don't include literals from enum members in completions

* add enum symbol to completions test

* use symbol flags for detecting enum member

* use type flags to check for enum member

* fix test
2021-08-26 16:33:06 -07:00
Armando Aguirre
ead9dfbdbd Fixed JS completions type spread (#45484)
* Fix and updated tests

* Added test

* Revert "Fix and updated tests"

This reverts commit 33829fa4a4.

* Filter out empty access expression

* PR feedback
2021-08-24 14:54:19 -07:00
Oleksandr T
076f22b2c9 fix(45501): don't remove spaces between empty object literals with enabled insertSpaceAfterOpeningAndBeforeClosingEmptyBraces (#45514) 2021-08-24 11:28:58 -07:00
Daniel Rosenwasser
59b8bef3e7 Only provide hints for simple literals when 'literals' is specified. (#45557)
* Only provide hints for simple literals when 'literals' is specified.

* Update fourslash tests.
2021-08-23 16:38:26 -07:00
Daniel Rosenwasser
af54990055 Some cleanup around inlay hints types to get more-precise checking. (#45391)
* Some cleanup around inlay hints types to get more-precise checking.

* Update Baselines and/or Applied Lint Fixes

Co-authored-by: TypeScript Bot <typescriptbot@microsoft.com>
2021-08-23 16:15:54 -07:00
Oleksandr T
65ed4124ee feat(44888): omit completions in an object expression with an instantiated class type (#45044) 2021-08-20 13:51:37 -07:00
Oleksandr T
69b5b2b2f3 feat(16755): show QF to declare missing properties in a call expression with an object literal argument (#44781) 2021-08-20 13:49:46 -07:00
Oleksandr T
e00722f262 feat(44720): allow renaming string literal in switch/case (#45084) 2021-08-19 17:09:35 -07:00
Gabriela Araujo Britto
945179fb64 Reuse checker's property accessibility check for completions (#45388)
* add test for completions crash

* WIP: experiment

* remove comments

* add call to getParseTreeNode

* Revert "add call to getParseTreeNode"

This reverts commit 8dd1cf67cf.

* Fix comments

* minor fixes

* fix formatting

* rename type to containingType
2021-08-19 13:02:20 -07:00
Eli Barzilay
7a19c22063 getReferencesAtLocation: fix handling of destructoring imports
Fixes #45423.
2021-08-18 14:39:54 -04:00
Oleksandr T
dc80e6a28b feat(18147): skip uncessary parenthesis (#44769) 2021-08-16 17:20:40 -07:00
Oleksandr T
424464d46b feat(43963): change var to a parameter in destructured function parameters (#44767) 2021-08-16 17:19:44 -07:00
Oleksandr T
55ed742574 fix(45294): show parameter inlay hints for template strings (#45305) 2021-08-16 14:11:02 -07:00
Ryan Cavanaugh
e00b5ecd40 Enable max-statements-per-line lint rule (#45475)
* Enable the rule

* Fix all the violations
2021-08-16 13:53:51 -07:00
Oleksandr T
dfd84ec0b2 fix(45417): show inlay hints for null and literal-like identifiers (#45426) 2021-08-13 11:31:47 -07:00
Jm
7139f37201 fix: nodeWillIndentChild judge for BinaryExpression with JsxElement child (#44695) 2021-08-12 14:01:52 -07:00
Nathan Shively-Sanders
8d4fe5a0fb Fix unassignable properties by adding undefined with exactOptionalPropertyTypes (#45032)
* Simple first version

Doesn't cover or test any complicated variations.

* Lots of cases work

Destructuring does not. But

- skipping node_modules and lib.* does.
- call expressions does
- property access, including with private identifiers, does

* Support variable declarations, property assignments, destructuring

As long as it's not nested

* More cleanup

* skip all d.ts, not just node_modules/lib

* Offer a codefix for a lot more cases

* remove incorrect tuple check

* Use getSymbolId instead of converting to string

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

* add test + switch to tracking number symbol ids

* Address PR comments

* Exclude tuples from suggestion

* Better way to get error node

Plus add a check that errorNode is an argument to the call, not the
call's expression.

* fix semicolon lint

* fix another crash

* Simplify: add undefined to all optional propertie

whether or not somebody tried to assign undefined to them in the
erroneous assignment

* remove fix-all

Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>
2021-08-10 16:57:38 -07:00
Oleksandr T
6c42d7949b fix(45393): show parameter name hints for unary literal expressions (#45399) 2021-08-10 11:51:00 -07:00
Ikko Ashimine
5e496d52e1 Fix typo in helpers.ts (#45365)
funtions
2021-08-09 08:40:54 -07:00
Andrew Casey
792e6d652a Fix symbol display exception when handling incomplete class (#44936)
When a class declaration lacks a name, don't throw an exception when
producing the display parts (e.g. for QuickInfo).

Remaining issues:
 1. The name shows as "__missing", the name of the underlying symbol,
    rather than "(Missing)", as it is for the corresponding function
    declaration case (because the parse constructs a missing identifier
    node for the function declaration).
 2. "(Missing)" is hard-coded, rather than being a localizable resource
    string.
 3. When an anonymous class declaration is a default export, the
    corresponding symbol is named "default", resulting in the confusing
    display string "class default".

Since display parts are built using existing `symbolToString`
functionality, it wasn't clear whether detecting special symbol names
and replacing them with user-friendly strings could be done without
breaking other functionality.

Similarly, changing the shape of the parse tree seemed riskier than the
problem justified (the user experience is just not getting QuickInfo for
the incomplete declaration, which seems acceptable).
2021-08-06 15:05:54 -07:00
Oleksandr T
cce2e926de feat(45163): add QF to declare missing jsx attributes (#45179) 2021-08-06 12:38:22 -07:00
Ron Buckton
4fc4c18299 Fix completions in return when in function with contextual 'this' (#45340) 2021-08-05 22:40:20 -07:00
Andrew Branch
f80bc3f5f0 Store symbol table map key in CachedSymbolExportInfo (#45289)
* Store symbol table map key in CachedSymbolExportInfo

* Remove debug assertion

* Filter out known symbols (again) and private identifiers
2021-08-04 16:31:47 -07:00
Eli Barzilay
2bae169306 convertStringOrTemplateLiteral.ts: Re-fix escapeStringForTemplate
Make it backslash-escape backticks too.  While I was there, remove the
use of this function for the text (which was the earlier confused
version that used only `text`), and rename it as
`escapeRawStringForTemplate` to clarify.

Added a test to the preivious pile of tests.

Fixes #45278.
2021-08-04 18:37:31 -04:00
David Sherret
03dff41c9f Fix getting completion details for meta properties (#45031)
* Fix getting completion details for meta properties.

* Move inside the worker.

* Move ImportMeta handling to completions.ts

* Fix property type name for new.target.

* Use symbols for ImportMeta completions.

* Accept baselines.

* Revert lib change.

* Revert needless parser change.

* Missed these reverts.

* Remove now unused `isMetaPropertyExpression`

* Move up meta property keyword check to be done in `getSymbolAtLocation` and `getTypeOfNode`

* Call `checkNewTargetMetaProperty` directly and handle when it's an error type.

* Make meta property expression types synthetic.

* Make event.target and import.meta properties readonly

* Add a test for go to definition (I think?)

* Copy built-in types/values test for go to definition.

* Add tests for go to definition when not a module.

* Fix "go to definition" for new.target
2021-08-04 09:41:04 -07:00
Oleksandr T
318930b9e3 fix(45221): suggest unknown symbols in type positions (#45323) 2021-08-04 09:37:06 -07:00
Jean Pierre
1cbb0bd4d3 Do not classify Infinity and NaN (#44778)
* Do not classify Infinity and NaN. Fixes #42022

* Internally expose so that the classifier can use it

* Increase the test complexity, and revert the type-checker

* Drop the -Infinity

Co-authored-by: Orta <git@orta.io>
2021-08-04 10:00:39 +01:00
Oleksandr T
5971b68231 fix(45224): show inlay hints for setter parameter (#45229) 2021-08-03 11:33:26 -07:00
Oleksandr T
c4080437b2 fix(45102): do not suggest refactoring for functions contains arguments reference (#45116) 2021-08-03 11:31:56 -07:00
Martin Johns
5a2153a729 Fix position of keyword in "Add 'override' modifier" code fix (#45274)
fixes #45270
2021-08-03 11:01:30 -07:00
Oleksandr T
39c653cd83 fix: omit inlay hints for setters (#45228) 2021-08-02 16:27:22 -07:00
Daniel Rosenwasser
975aabe788 Ensure all SortText entries have the same length (#45292)
* Ensure all `SortText` entries have the same length.

* Update Baselines and/or Applied Lint Fixes

* Update the exact same enum to the exact same values in fourslash. 🙄

* Make `SortTextId` a const enum, switch to use an explicit offset in `SortTextId`.

Co-authored-by: TypeScript Bot <typescriptbot@microsoft.com>
2021-08-02 16:27:01 -07:00
Oleksandr T
c23abc8957 fix(45192): show implement interface QF for re-exported types (#45245) 2021-08-02 15:19:19 -07:00
Oleksandr T
fcf7bafd57 fix(44812): add outlining spans for comments inside blocks (#44847) 2021-07-30 15:56:32 -07:00
Armando Aguirre
76d754329e Fix bigInt completions (#45059)
* Fix bigInt completions

* Added regresion test
2021-07-30 14:40:50 -07:00
Wenlu Wang
8cdcec4454 Avoid provide hints for binding patterns (#44961)
* Avoid provide hints for binding patterns

* Rename as 56
2021-07-30 09:43:20 -07:00
tjjfvi
9d957c64c5 Fix getChildCount/At methods in EndOfFileTokens (#44991)
* Fix getChildCount/At methods in EndOfFileTokens

Before, they were hardcoded to return `0` and `undefined!`, respectively, but that is inaccurate for `EndOfFileToken`s with attached jsdoc.

* Add tests for getChild* methods on EndOfFileTokens
2021-07-30 09:03:19 -07:00
Andrew Branch
62773051e7 Fix import statement completions for export= in JS files (#45128) 2021-07-29 10:28:47 -07:00
Oleksandr T
c79ec7bfbb fix(45225): do not show add missing member QF for libraries files (#45231) 2021-07-29 10:22:27 -07:00
Eli Barzilay
7e8bba6908 Fix template string refactoring and nodeFactory bug
Instead of letting `createTemplate*` generate a broken raw string from
the cooked one, grab the source code for it.

Also, add a missing bit to `\`-quote `$`s.  As the comment in the code
says, it could just `\`-quote `${` since other `$`s are valid, but I
think that it's less confusing to always quote $s (but the change is in
the comment if minimalism is preferred).

Also, a small-but-confusing bug in `getCookedText()`.

Many tests for all of this.

Fixes #40625
2021-07-29 04:23:06 -04:00
Oleksandr T
7c197becb6 feat(45210): add inlay hints for getters and setters (#45214) 2021-07-28 14:52:37 -07:00
Oleksandr T
85e0e5ad07 fix(44837): add graceful recovery for require completions (#45151) 2021-07-26 15:26:43 -07:00
Wenlu Wang
9665bc6199 Supress hints for access expr too (#45121) 2021-07-26 11:59:14 -07:00
Andrew Branch
f029a8266c Filter auto imports by symbol flags before resolving module specifiers (#45168)
* Filter auto imports by symbol flags before resolving module specifiers

* Don’t filter types out of import statement completions
2021-07-23 15:56:34 -07:00
Andrew Branch
9c8a90d685 Check cancellation token during exportInfoMap generation (#45138) 2021-07-21 14:17:34 -07:00
Andrew Branch
476054ea57 Fix auto import crashes caused by unrelocatable symbols (#45055)
* Add failing test

* Fix auto import crashes caused by unrelocatable symbols

* Use util for testing if symbol is an external module
2021-07-19 10:32:47 -07:00
Andrew Branch
36225c3260 Detect preference for Unode:-prefixed node core modules (#45080) 2021-07-19 09:56:24 -07:00
Oleksandr T
ba2e2600c8 fix(44701): allow renaming string literal in rhs/lhs of equality (#44708) 2021-07-16 14:45:06 -07:00
Oleksandr T
00596e19f5 fix(44168): exclude adding export to existing exported identifier (#44755) 2021-07-16 09:40:17 -07:00
Andrew Branch
6d3772f357 Fix auto import require of CJS module with module:es2015+ and allowSyntheticDefaultExports (#44955) 2021-07-15 16:08:05 -07:00