Skip to content

Should not issue error on property assignments to function/class declarations in block scopes. #16271

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

Closed
DanielRosenwasser opened this issue Jun 5, 2017 · 2 comments
Labels
Bug A bug in TypeScript Domain: JavaScript The issue relates to JavaScript specifically
Milestone

Comments

@DanielRosenwasser
Copy link
Member

Reported by @OliverJAsh in #16239:

{
class Foo {}
Foo.bar = 1; // error

const Foo2 = () => {};
Foo2.bar = 1; // error

function FooBar() {}
FooBar.bar = 1; // error
}

None of these should error in JS checking. This may have to do with how we resolve function declarations in block bodies (i.e. we look them up in the containing function scope, not the block scope.

@DanielRosenwasser DanielRosenwasser added Bug A bug in TypeScript Salsa labels Jun 5, 2017
@OliverJAsh
Copy link
Contributor

Thanks @DanielRosenwasser. Note the Foo2 example (function expression) also errors in the root scope.

@mhegazy mhegazy self-assigned this Feb 2, 2018
@mhegazy mhegazy added this to the TypeScript 2.8 milestone Feb 2, 2018
@mhegazy mhegazy modified the milestones: TypeScript 2.8, TypeScript 2.9 Mar 9, 2018
@mhegazy mhegazy modified the milestones: TypeScript 3.0, Future Jul 2, 2018
@weswigham weswigham added the Domain: JavaScript The issue relates to JavaScript specifically label Nov 29, 2018
@jakebailey
Copy link
Member

Just looking at ancient issues; this one was fixed by #38031 (and I believe is tested there by nature of the tests having no errors).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: JavaScript The issue relates to JavaScript specifically
Projects
None yet
Development

No branches or pull requests

5 participants