6088 Commits

Author SHA1 Message Date
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
Gabriela Araujo Britto
3358f137c6
Fix namespace name conflict detection in "Convert named imports to namespace import" action (#45019)
* fix namespace conflict detection
2021-07-14 11:07:12 -07:00
Daniel Rosenwasser
0996bff509
Support syntactic diagnostics in partial mode (#44859)
* Initial work to support syntactic diagnostics in partial mode.

* Test out 'syntacticDiagnosticsSync' requests.

* Added a 'geterr' test.

* Accepted baselines.

* Remove/clean up comments.
2021-07-13 11:22:34 -07:00
Eli Barzilay
bb7de99e5a Improve "Convert to template string" with template-strings
Fixes #44396
2021-07-06 18:14:58 -04:00
Andrew Branch
1da18c60d6
Refactor export map cache to not store transient symbols (#44816)
* Add some failing tests around transient symbols

* Working, but slower

* A class is much faster, apparently

* This is probably best?

* Back to multimap

* Go back to single symbol cache

* Revert now-unnecessary generics

* Rename and reorganize

* Fix weird compound condition

* Clean up
2021-07-06 11:04:59 -06:00
Daniel Rosenwasser
9d443b76aa
Update LKG to enable improved narrowing in 4.4. (#44842)
* Update LKG.

* Remove unnecessary assertions.
2021-07-01 12:21:27 -07:00
Oleksandr T
e402c1d464
feat(44799): allow auto import codefix for shorthand property assignment (#44827) 2021-06-30 16:09:42 -05:00
Oleksandr T
066796be54
feat(44736): add go-to-definition on overridden members (#44740) 2021-06-28 14:58:06 -07:00
Wenlu Wang
dc237b317e
Change static fields emits (#43114)
* use emit into iife

* Update emit

* Revert un-related changes

* Allow super in static context

* Allow this and super in static property declaration

* Add more tests

* Avoid errors

* Accept baseline

* Accept baseline

* Add decorated classes test

* Add errors

* Avoid this in emitter

* make lint happy

* Add class expression tests

* Add computed name test

* Avoid super if target below es6

* Adjust function boundary

* Add internal

* Fix minor CR issues

* accept baseline

* Update behavior

* Avoid spaces

* Make lint happy

* Avoid function boundary utils

* Update baseline

* Avoid errors

* Accept baseline

* Accept baseline

* Accept baseline

* Accept baseline

* Use substitutions

* Full coverage for super, this, merge static and private context

* Fix use-before-def in static fields

Co-authored-by: Ron Buckton <ron.buckton@microsoft.com>
2021-06-25 15:49:27 -07:00
Andrew Branch
328e888a9d
Resolve module specifiers for auto imports in completion list (in incomplete chunks) (#44713)
* Enable module specifiers for all auto imports

* Use isIncomplete

* isIncomplete continuation

* Lots of fixes

* Merged/transient symbol fixes, resolve all ambient module specifiers up front, pull as many as we want from cache

* Fix existing tests

* Start testing

* Add more tests

* Set cache attempt limit, update API baseline

* Fix a few tests

* Fix contextToken

* Split getModuleSpecifiers

* Unexport function

* Clean up importFixes

* Clean up completions

* Delete transient symbol assertion - fixing later
2021-06-25 17:26:53 -05:00
Wenlu Wang
906cbd2715
Proposal class static block support (#43370)
* Class static block (#9)

* Add types factory and parser

* Add some case

* Make class static block as a container

* Update cases

* Add visitor

* Add emitter and more compile target

* Check boundary of break and continue

* Add basic transformer

* Fix emit behavior

* Add more tests

* Add friend tests

* Update baseline

* Fix cr issues

* Accept baseline

* Add decorator and modifier check

* Add functional boundary check

* Fix conflict

* Fix computed prop name within context

* Add more tests

* Update baseline

* Avoid invalid test baseline

* Support use before initialize check

* wip

* Fix class static block context

* Fix checks

* Fix missing case

* Improve assert message

* Accept baseline

* Avoid new context

* Update diagnostic message

* Fix name collision

* Fix targets

* Avoid unnecessary files

* Add more case

* Add more test cases

* Fix strict mode function declaration

* Avoid private fields initializer if no private identifier references

* Avoid private fields and add more test case

* Add more case

* Add tests and support for related services functionality

* Fix this reference in static block

* Split parser diagnostic and binder diagnostic

Co-authored-by: Ron Buckton <ron.buckton@microsoft.com>
2021-06-25 09:24:05 -07:00