mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 03:23:08 -06:00
[Release-2.0] Fix 9782: do not report blocked-scope-used-before-declaration error in ambient context (#9789) (#9830)
* Do not report block-scoped-used-before-declaration in ambient context * Add tests and baselines
This commit is contained in:
parent
2a26beb9d8
commit
80db0f2f16
@ -974,7 +974,7 @@ namespace ts {
|
||||
|
||||
Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined");
|
||||
|
||||
if (!isBlockScopedNameDeclaredBeforeUse(<Declaration>getAncestor(declaration, SyntaxKind.VariableDeclaration), errorLocation)) {
|
||||
if (!isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(<Declaration>getAncestor(declaration, SyntaxKind.VariableDeclaration), errorLocation)) {
|
||||
error(errorLocation, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationNameToString(declaration.name));
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,9 @@
|
||||
=== tests/cases/compiler/test.d.ts ===
|
||||
|
||||
declare var S: typeof A; // no error
|
||||
>S : Symbol(S, Decl(test.d.ts, 1, 11))
|
||||
>A : Symbol(A, Decl(test.d.ts, 2, 13))
|
||||
|
||||
declare const A: number;
|
||||
>A : Symbol(A, Decl(test.d.ts, 2, 13))
|
||||
|
||||
@ -0,0 +1,9 @@
|
||||
=== tests/cases/compiler/test.d.ts ===
|
||||
|
||||
declare var S: typeof A; // no error
|
||||
>S : number
|
||||
>A : number
|
||||
|
||||
declare const A: number;
|
||||
>A : number
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
// @filename: test.d.ts
|
||||
|
||||
declare var S: typeof A; // no error
|
||||
declare const A: number;
|
||||
Loading…
x
Reference in New Issue
Block a user