microsoft / microsoft/TypeScript
JS Intellisense not detecting ES6 Symbol properties assigned after Initialization
Nobody has claimed this yet.
- 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:
- Initialize a Symbol
- Initialize an empty object literal
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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