mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-12-12 11:50:54 -06:00
parent
b065902a99
commit
4fac5f26dc
@ -1711,7 +1711,9 @@ namespace ts {
|
||||
function checkResolvedBlockScopedVariable(result: Symbol, errorLocation: Node): void {
|
||||
Debug.assert(!!(result.flags & SymbolFlags.BlockScopedVariable || result.flags & SymbolFlags.Class || result.flags & SymbolFlags.Enum));
|
||||
// Block-scoped variables cannot be used before their definition
|
||||
const declaration = forEach(result.declarations, d => isBlockOrCatchScoped(d) || isClassLike(d) || (d.kind === SyntaxKind.EnumDeclaration) ? d : undefined);
|
||||
const declaration = find(
|
||||
result.declarations,
|
||||
d => isBlockOrCatchScoped(d) || isClassLike(d) || (d.kind === SyntaxKind.EnumDeclaration) || isInJSFile(d) && !!getJSDocEnumTag(d));
|
||||
|
||||
if (declaration === undefined) return Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined");
|
||||
|
||||
|
||||
13
tests/baselines/reference/enumTagUseBeforeDefCrash.symbols
Normal file
13
tests/baselines/reference/enumTagUseBeforeDefCrash.symbols
Normal file
@ -0,0 +1,13 @@
|
||||
=== tests/cases/conformance/jsdoc/bug27134.js ===
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
var foo = { };
|
||||
>foo : Symbol(foo, Decl(bug27134.js, 3, 3))
|
||||
|
||||
/**
|
||||
* @type {foo}
|
||||
*/
|
||||
var s;
|
||||
>s : Symbol(s, Decl(bug27134.js, 8, 3))
|
||||
|
||||
14
tests/baselines/reference/enumTagUseBeforeDefCrash.types
Normal file
14
tests/baselines/reference/enumTagUseBeforeDefCrash.types
Normal file
@ -0,0 +1,14 @@
|
||||
=== tests/cases/conformance/jsdoc/bug27134.js ===
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
var foo = { };
|
||||
>foo : typeof foo
|
||||
>{ } : {}
|
||||
|
||||
/**
|
||||
* @type {foo}
|
||||
*/
|
||||
var s;
|
||||
>s : number
|
||||
|
||||
13
tests/cases/conformance/jsdoc/enumTagUseBeforeDefCrash.ts
Normal file
13
tests/cases/conformance/jsdoc/enumTagUseBeforeDefCrash.ts
Normal file
@ -0,0 +1,13 @@
|
||||
// @noEmit: true
|
||||
// @allowJs: true
|
||||
// @checkJs: true
|
||||
// @Filename: bug27134.js
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
var foo = { };
|
||||
|
||||
/**
|
||||
* @type {foo}
|
||||
*/
|
||||
var s;
|
||||
Loading…
x
Reference in New Issue
Block a user