mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
202 lines
5.8 KiB
Plaintext
202 lines
5.8 KiB
Plaintext
blockScopedVariablesUseBeforeDef.ts(2,13): error TS2448: Block-scoped variable 'x' used before its declaration.
|
|
blockScopedVariablesUseBeforeDef.ts(58,20): error TS2448: Block-scoped variable 'x' used before its declaration.
|
|
blockScopedVariablesUseBeforeDef.ts(65,20): error TS2448: Block-scoped variable 'x' used before its declaration.
|
|
blockScopedVariablesUseBeforeDef.ts(100,12): error TS2448: Block-scoped variable 'x' used before its declaration.
|
|
blockScopedVariablesUseBeforeDef.ts(111,28): error TS2448: Block-scoped variable 'a' used before its declaration.
|
|
blockScopedVariablesUseBeforeDef.ts(112,21): error TS2448: Block-scoped variable 'a' used before its declaration.
|
|
blockScopedVariablesUseBeforeDef.ts(122,22): error TS2448: Block-scoped variable 'a' used before its declaration.
|
|
blockScopedVariablesUseBeforeDef.ts(128,9): error TS2448: Block-scoped variable 'foo' used before its declaration.
|
|
blockScopedVariablesUseBeforeDef.ts(131,9): error TS2448: Block-scoped variable 'foo' used before its declaration.
|
|
blockScopedVariablesUseBeforeDef.ts(153,20): error TS2450: Enum 'Enum' used before its declaration.
|
|
|
|
|
|
==== blockScopedVariablesUseBeforeDef.ts (10 errors) ====
|
|
function foo0() {
|
|
let a = x;
|
|
~
|
|
!!! error TS2448: Block-scoped variable 'x' used before its declaration.
|
|
!!! related TS2728 blockScopedVariablesUseBeforeDef.ts:3:9: 'x' is declared here.
|
|
let x;
|
|
}
|
|
|
|
function foo1() {
|
|
let a = () => x;
|
|
let x;
|
|
}
|
|
|
|
function foo2() {
|
|
let a = function () { return x; }
|
|
let x;
|
|
}
|
|
|
|
function foo3() {
|
|
class X {
|
|
m() { return x;}
|
|
}
|
|
let x;
|
|
}
|
|
|
|
function foo4() {
|
|
let y = class {
|
|
m() { return x; }
|
|
};
|
|
let x;
|
|
}
|
|
|
|
function foo5() {
|
|
let x = () => y;
|
|
let y = () => x;
|
|
}
|
|
|
|
function foo6() {
|
|
function f() {
|
|
return x;
|
|
}
|
|
let x;
|
|
}
|
|
|
|
function foo7() {
|
|
class A {
|
|
a = x;
|
|
}
|
|
let x;
|
|
}
|
|
|
|
function foo8() {
|
|
let y = class {
|
|
a = x;
|
|
}
|
|
let x;
|
|
}
|
|
|
|
function foo9() {
|
|
let y = class {
|
|
static a = x;
|
|
~
|
|
!!! error TS2448: Block-scoped variable 'x' used before its declaration.
|
|
!!! related TS2728 blockScopedVariablesUseBeforeDef.ts:60:9: 'x' is declared here.
|
|
}
|
|
let x;
|
|
}
|
|
|
|
function foo10() {
|
|
class A {
|
|
static a = x;
|
|
~
|
|
!!! error TS2448: Block-scoped variable 'x' used before its declaration.
|
|
!!! related TS2728 blockScopedVariablesUseBeforeDef.ts:67:9: 'x' is declared here.
|
|
}
|
|
let x;
|
|
}
|
|
|
|
function foo11() {
|
|
function f () {
|
|
let y = class {
|
|
static a = x;
|
|
}
|
|
}
|
|
let x;
|
|
}
|
|
|
|
function foo12() {
|
|
function f () {
|
|
let y = class {
|
|
a;
|
|
constructor() {
|
|
this.a = x;
|
|
}
|
|
}
|
|
}
|
|
let x;
|
|
}
|
|
|
|
function foo13() {
|
|
let a = {
|
|
get a() { return x }
|
|
}
|
|
let x
|
|
}
|
|
|
|
function foo14() {
|
|
let a = {
|
|
a: x
|
|
~
|
|
!!! error TS2448: Block-scoped variable 'x' used before its declaration.
|
|
!!! related TS2728 blockScopedVariablesUseBeforeDef.ts:102:9: 'x' is declared here.
|
|
}
|
|
let x
|
|
}
|
|
|
|
function foo15() {
|
|
// https://github.com/microsoft/TypeScript/issues/42678
|
|
const [
|
|
a,
|
|
b,
|
|
] = ((): [number, number] => {
|
|
(() => console.log(a))(); // should error
|
|
~
|
|
!!! error TS2448: Block-scoped variable 'a' used before its declaration.
|
|
!!! related TS2728 blockScopedVariablesUseBeforeDef.ts:108:9: 'a' is declared here.
|
|
console.log(a); // should error
|
|
~
|
|
!!! error TS2448: Block-scoped variable 'a' used before its declaration.
|
|
!!! related TS2728 blockScopedVariablesUseBeforeDef.ts:108:9: 'a' is declared here.
|
|
const b = () => a; // should be ok
|
|
return [
|
|
0,
|
|
0,
|
|
];
|
|
})();
|
|
}
|
|
|
|
function foo16() {
|
|
let [a] = (() => a)();
|
|
~
|
|
!!! error TS2448: Block-scoped variable 'a' used before its declaration.
|
|
!!! related TS2728 blockScopedVariablesUseBeforeDef.ts:122:10: 'a' is declared here.
|
|
}
|
|
|
|
function foo17() {
|
|
const promise = (async () => {
|
|
promise
|
|
foo
|
|
~~~
|
|
!!! error TS2448: Block-scoped variable 'foo' used before its declaration.
|
|
!!! related TS2728 blockScopedVariablesUseBeforeDef.ts:134:11: 'foo' is declared here.
|
|
await null
|
|
promise
|
|
foo
|
|
~~~
|
|
!!! error TS2448: Block-scoped variable 'foo' used before its declaration.
|
|
!!! related TS2728 blockScopedVariablesUseBeforeDef.ts:134:11: 'foo' is declared here.
|
|
})()
|
|
|
|
const foo = 1;
|
|
}
|
|
|
|
// #30907
|
|
function wrapI1() {
|
|
const iter = (function* foo() {
|
|
iter;
|
|
yield 1;
|
|
})();
|
|
}
|
|
|
|
function wrapI2() {
|
|
const iter = (async function* foo() {
|
|
iter;
|
|
yield 1;
|
|
})();
|
|
}
|
|
|
|
function foo18() {
|
|
let a = (() => Enum.Yes)();
|
|
~~~~
|
|
!!! error TS2450: Enum 'Enum' used before its declaration.
|
|
!!! related TS2728 blockScopedVariablesUseBeforeDef.ts:154:10: 'Enum' is declared here.
|
|
enum Enum {
|
|
No = 0,
|
|
Yes = 1,
|
|
}
|
|
}
|
|
|