Skip to content

TS didnot transform foo.return from dot notation to bracket notation when targeting "ES5" #53309

@AnnAngela

Description

@AnnAngela

Bug Report

🔎 Search Terms

I searched es5 dot notation but no relative issue.

🕗 Version & Regression Information

  • This is a crash
  • This changed between versions ______ and _______
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about notation
  • I was unable to test this on prior versions because _______

After ts 5.0, the target: ES3 configuration has been deprecated, but when I tried to configured the target as ES5, I noticed that the foo.return syntax was not transformed to bracket notation as required by the ECMAScript 5.1 Specification.

According to Section 11.2.1, the dot notation should use IdentifierName. However, Section 7.6 forbids using ReservedWord as IdentifierName. Furthermore, Section 7.6.1.1 lists the return as a Keywords which is a type of ReservedWord in Section 7.6.1.

⏯ Playground Link

Playground link with relevant code

💻 Code

const foo = {
    return: "foo",
};
console.info(foo.return);

🙁 Actual behavior

Output: console.info(foo.return);

🙂 Expected behavior

Output: console.info(foo["return"]);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions