Skip to content

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

@DanielRosenwasser

Description

@DanielRosenwasser

Take the following code.

var type;
var string;
var Foo;

type Foo = string;

Now add a newline between type Foo:

var type;
var string;
var Foo;

type
Foo = 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
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions