TypeScript/tests/baselines/reference/localTypes4.errors.txt
Anders Hejlsberg 5eff0a5fae Adding tests
2015-05-26 12:03:13 -07:00

53 lines
1.7 KiB
Plaintext

tests/cases/conformance/types/localTypes/localTypes4.ts(10,19): error TS2304: Cannot find name 'T'.
tests/cases/conformance/types/localTypes/localTypes4.ts(10,23): error TS2304: Cannot find name 'T'.
tests/cases/conformance/types/localTypes/localTypes4.ts(18,16): error TS2300: Duplicate identifier 'T'.
tests/cases/conformance/types/localTypes/localTypes4.ts(19,19): error TS2300: Duplicate identifier 'T'.
==== tests/cases/conformance/types/localTypes/localTypes4.ts (4 errors) ====
function f1() {
// Type parameters are in scope in parameters and return types
function f<T>(x: T): T {
return undefined;
}
}
function f2() {
// Local types are not in scope in parameters and return types
function f(x: T): T {
~
!!! error TS2304: Cannot find name 'T'.
~
!!! error TS2304: Cannot find name 'T'.
interface T { }
return undefined;
}
}
function f3() {
// Type parameters and top-level local types are in same declaration space
function f<T>() {
~
!!! error TS2300: Duplicate identifier 'T'.
interface T { }
~
!!! error TS2300: Duplicate identifier 'T'.
return undefined;
}
}
function f4() {
// Local types are block scoped
interface T { x: number }
let v: T;
v.x = 10;
if (true) {
interface T { x: string }
let v: T;
v.x = "hello";
}
else {
v.x = 20;
}
}