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

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

Closed
DanielRosenwasser opened this issue May 2, 2015 · 0 comments
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@DanielRosenwasser
Copy link
Member

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
@DanielRosenwasser DanielRosenwasser changed the title Type aliases override ASI rules Legal JS is interpreted incorrectly in the presence of the 'type' keyword May 2, 2015
@DanielRosenwasser DanielRosenwasser changed the title Legal JS is interpreted incorrectly in the presence of the 'type' keyword Legal JS is interpreted incorrectly in the presence of certain keywords May 2, 2015
@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label May 4, 2015
@mhegazy mhegazy added this to the TypeScript 1.6 milestone May 6, 2015
@DanielRosenwasser DanielRosenwasser added the Fixed A PR has been merged for this issue label Jun 8, 2015
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

3 participants