Skip to content

Allow keywords in property names on the right of import ... =Β #48274

@nicolo-ribaudo

Description

@nicolo-ribaudo

Bug Report

πŸ”Ž Search Terms

import equals declaration module reference keyword

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about import

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

Just for the syntax:

import X2 = Y.if;

A complete example:

// dep.ts
module A {}
export { A as if };
// main.ts
import * as T from "./dep"
import mod = T.if;

πŸ™ Actual behavior

This code throws that if is a reserved word, and produces a broken AST.

πŸ™‚ Expected behavior

That code should be allowed: if Y is a module namespace object that exports an if module, it's runtime behavior is well defined. If you rename if to anything else, it works.

Note that I didn't find this surprising ("surprising" because every other member expression in the language allows reserve words after .) restriction in real code, but while reading Babel's TypeScript parsing code.

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