microsoft / microsoft/TypeScript

JS Intellisense not detecting ES6 Symbol properties assigned after Initialization

Open
#43,317 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Domain: JavaScript
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

  • VS Code Version: 1.54.3
  • OS Version: Windows 10 Pro, version 20H2, build 19042.804

Steps to Reproduce:

  1. Initialize a Symbol
  2. Initialize an empty object literal
  3. Assign the object a function, using the symbol as its property

The following code also demonstrates some of the steps to reproduce:

const symKey = Symbol();


/** @namespace */
var objLiteral = {
    literalPublicFn1() {},

    /**
     * You found the secret fn!
     */
    [symKey]() {},
};


/** @namespace */
var objAssigned = {};

/** @memberof objAssigned */
objAssigned.laterPublicFn1 = function() {};

/** 
 * You found the secret fn!
 * @memberof objAssigned 
 * */
objAssigned[symKey] = function () {}

For both objects, the string properties are picked up by Intellisense and autocompleted as expected. However, Intellisense only provides function info for the symbol on the objLiteral object, where the symbol property was declared as part of the literal. For the objAssigned object, where the symbol property was assigned after initialization, no function info is provided.

In other words, intellisense works when calling objLiteral[symKey]() but not when calling objAssigned[symKey]()

Does this issue occur when all extensions are disabled?: Yes

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the JavaScript reproduction in the issue and investigate the TypeScript language-service handling of computed Symbol properties assigned after object initialization. Compare IntelliSense for objLiteralsymKey with objAssignedsymKey, and consider the issue complete when both provide the function information shown for the literal case.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript, vscode
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.