Skip to content

Legal JS is interpreted incorrectly in the presence of certain keywords #2995

Description

Take the following code.

vartype;varstring;varFoo;typeFoo=string;

Now add a newline between type Foo:

vartype;varstring;varFoo;typeFoo=string;

Still valid, but should have a completely different meaning now. In the first, we have a type alias, while in the second, we have a lone identifier and a declaration.


Here's actually a few contexts where we do the wrong thing:

  • type aliases (see the example above)
  • namespaces/internal modules:
namespace// this is the identifier 'namespace'm// this is the identifier 'm'{}// this is a block body
  • declared modules
declare// this is the identifier 'declare'module// this is the identifier 'module'"my external module"// this is just a string{}// this is a block body

Metadata

Metadata

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions