1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
//// [localTypes4.ts]
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 {
interface T { }
return undefined;
}
}
function f3() {
// Type parameters and top-level local types are in same declaration space
function f<T>() {
interface 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;
}
}
//// [localTypes4.js]
function f1() {
// Type parameters are in scope in parameters and return types
function f(x) {
return undefined;
}
}
function f2() {
// Local types are not in scope in parameters and return types
function f(x) {
return undefined;
}
}
function f3() {
// Type parameters and top-level local types are in same declaration space
function f() {
return undefined;
}
}
function f4() {
var v;
v.x = 10;
if (true) {
var v_1;
v_1.x = "hello";
}
else {
v.x = 20;
}
}
|