Skip to content
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

Word "constructor" should not trigger auto list #2690

Merged
merged 2 commits into from
Jun 11, 2024
Merged

Conversation

JiuqingSong
Copy link
Collaborator

To repro:

  1. type "constructor"
  2. type SPACE
    Expect: nothing special happens
    Actual: it converts "constructor" into a list with text "function Object() { [native code] } "

This is because we have code like this:

const map = {
  key: value
};

const value =map[input];

If input is some predefined property name such as "constructor", "valueOf", "toString", it will return a function object which is treated as a valid result, which should not.

Fix: use Map instead of Record here.
Future work: Check all other places where Record is used. Possibly find a eslint rule to disable it at all.

@JiuqingSong JiuqingSong merged commit 39f2d34 into master Jun 11, 2024
7 checks passed
@JiuqingSong JiuqingSong deleted the u/jisong/fixrecord branch June 11, 2024 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants