-
Notifications
You must be signed in to change notification settings - Fork 12.8k
JS autocomplete doesn't work for object literal shorthands #41259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
If you don't mind, I'd like to work with this issue. FYI @andrewbranch |
Sounds good @orange4glace, let me know if you get stuck. You have about a month and a half before we need to get a fix in. |
@andrewbranch Thanks for the reply! I have one question for this. /// <reference path='fourslash.ts' />
//// var [x/*variable1*/
//// var [x, y/*variable2*/
//// var [./*variable3*/
//// var [x, ...z/*variable4*/
//// var {x/*variable5*/
//// var {x, y/*variable6*/
//// function func1({ a/*parameter1*/
//// function func2({ a, b/*parameter2*/
~
Getting Global Autocompletion
verify.completions({ marker: test.markers(), exact: undefined }); As l understood, the parenthesis var [x/*variable1*/
var [x, y/*variable2*/
var [./*variable3*/
var [x, ...z/*variable4*/
var {x/*variable5*/
var {x, y/*variable6*/
function func1({ a/*parameter1*/
function func2({ a, b/*parameter2*/
'}' expected.ts(1005)
41259.ts(15, 16): The parser expected to find a '}' to match the '{' token here.
41259.ts(13, 16): The parser expected to find a '}' to match the '{' token here. I'm curious that,
I'm very new to this community and anything that can be helped would be much appreciated! |
We definitely want test cases that have syntax errors because they reflect half-written code as though a user is actively editing, and we want completions to work in those cases. That said, any particular assertion in a test like this might become wrong and need to be updated. What completion is showing up there? |
With my modified version, it autocompletes global symbols at, ....
var {x, y/*variable6*/
function func1({ a/*parameter1*/
function func2({ a, b/*parameter2*/
~
Global symbols Autocompletion whereas with Typescript v4.0.5, it autocompletes nothing. (Playground) Currently, the compiler parses the testcase code like this, /* Statement #0 Starts (VariableStatement) */
var [x
/* Statement #1 Starts (VariableStatement) */
var [x, y
/* Statement #2 Starts (VariableStatement) */
var [.
/* Statement #3 Starts (VariableStatement) */
var [x, ...z
/* Statement #4 Starts (VariableStatement) */
var {x
var {x, y
function func1/* Statement #5 Starts (ExpressionStatement) */({ a
function func2({ a, b The opening bracket |
I think that’s probably alright. Can you go ahead and open a draft PR so we can make a playground build? |
Sure! I've just opened it. :) |
…ds (#41539) * fix: #41259 * fix: #41259 * fix: fourslash * fix: remove nested if * fix: change tc result for #41259 * fix: less restrictive shorthand completion rules * fix: use typeMembers to find out whether properties are empty * fix: typo * fix: lint * fix: exclude Object in completion * fix: test * fix: testcase tidy up * fix: apply completions for unclosed literal and missing comma * fix: ignore auto-imports * fix: use exact to ensure the order of completions * fix: use exact to ensure the order of completions * fix: add new lines so it can easy to be distinguished
TS Template added by @mjbvz
TypeScript Version: 4.1.0-dev.20201026
Search Terms
Steps to Reproduce:
GIF file to better demonstrate:

Does this issue occur when all extensions are disabled?: Yes
The text was updated successfully, but these errors were encountered: