mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
Merge pull request #9083 from zhengbli/i6853
Check use before declaration if both the use and decalration are not in module file
This commit is contained in:
commit
7bb739fa40
@ -562,7 +562,8 @@ namespace ts {
|
||||
const declarationFile = getSourceFileOfNode(declaration);
|
||||
const useFile = getSourceFileOfNode(usage);
|
||||
if (declarationFile !== useFile) {
|
||||
if (modulekind || (!compilerOptions.outFile && !compilerOptions.out)) {
|
||||
if ((modulekind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) ||
|
||||
(!compilerOptions.outFile && !compilerOptions.out)) {
|
||||
// nodes are in different files and order cannot be determines
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
/// <reference path="..\compiler\program.ts"/>
|
||||
/// <reference path="..\compiler\commandLineParser.ts"/>
|
||||
|
||||
/// <reference path='breakpoints.ts' />
|
||||
/// <reference path='outliningElementsCollector.ts' />
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
tests/cases/compiler/file1.ts(2,1): error TS2448: Block-scoped variable 'c' used before its declaration.
|
||||
|
||||
|
||||
==== tests/cases/compiler/file1.ts (1 errors) ====
|
||||
|
||||
c;
|
||||
~
|
||||
!!! error TS2448: Block-scoped variable 'c' used before its declaration.
|
||||
|
||||
==== tests/cases/compiler/file2.ts (0 errors) ====
|
||||
const c = 0;
|
||||
@ -1,10 +1,13 @@
|
||||
error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
tests/cases/compiler/a.ts(2,1): error TS2448: Block-scoped variable 'a' used before its declaration.
|
||||
|
||||
|
||||
!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
|
||||
==== tests/cases/compiler/a.ts (0 errors) ====
|
||||
==== tests/cases/compiler/a.ts (1 errors) ====
|
||||
let b = 30;
|
||||
a = 10;
|
||||
~
|
||||
!!! error TS2448: Block-scoped variable 'a' used before its declaration.
|
||||
==== tests/cases/compiler/b.js (0 errors) ====
|
||||
let a = 10;
|
||||
b = 30;
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
tests/cases/compiler/file1.ts(2,1): error TS2448: Block-scoped variable 'l' used before its declaration.
|
||||
|
||||
|
||||
==== tests/cases/compiler/file1.ts (1 errors) ====
|
||||
|
||||
l;
|
||||
~
|
||||
!!! error TS2448: Block-scoped variable 'l' used before its declaration.
|
||||
|
||||
==== tests/cases/compiler/file2.ts (0 errors) ====
|
||||
const l = 0;
|
||||
Loading…
x
Reference in New Issue
Block a user