Skip to content

Use before definition errors should not be reported in ambient contexts #9782

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
mhegazy opened this issue Jul 17, 2016 · 1 comment
Closed
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@mhegazy
Copy link
Contributor

mhegazy commented Jul 17, 2016

// test.d.ts

declare var S: typeof A; // error TS2448: Block-scoped variable 'A' used before its declaration.
declare const A: number;  

Errors make sense only in non-ambient context.

@mhegazy mhegazy added the Bug A bug in TypeScript label Jul 17, 2016
@mhegazy mhegazy added this to the TypeScript 2.0.1 milestone Jul 17, 2016
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Jul 19, 2016
@mhegazy mhegazy closed this as completed Jul 19, 2016
@mihailik
Copy link
Contributor

mihailik commented Jul 20, 2016

I would argue there should not be an error here too:

var S: typeof A;
const A: number;

We're not using A variable, we're using its type. And the type is known regardless of the order of the statements.

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 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