do not resolve parameters/type parameters if it is requested from restricted locations

This commit is contained in:
Vladimir Matveev
2015-11-17 13:27:52 -08:00
parent 13bc120fe2
commit e0a8af00a7
7 changed files with 195 additions and 7 deletions

View File

@@ -0,0 +1,44 @@
tests/cases/compiler/parameterNamesInTypeParameterList.ts(1,30): error TS2304: Cannot find name 'a'.
tests/cases/compiler/parameterNamesInTypeParameterList.ts(5,30): error TS2304: Cannot find name 'a'.
tests/cases/compiler/parameterNamesInTypeParameterList.ts(9,30): error TS2304: Cannot find name 'a'.
tests/cases/compiler/parameterNamesInTypeParameterList.ts(14,22): error TS2304: Cannot find name 'a'.
tests/cases/compiler/parameterNamesInTypeParameterList.ts(17,22): error TS2304: Cannot find name 'a'.
tests/cases/compiler/parameterNamesInTypeParameterList.ts(20,22): error TS2304: Cannot find name 'a'.
==== tests/cases/compiler/parameterNamesInTypeParameterList.ts (6 errors) ====
function f0<T extends typeof a>(a: T) {
~
!!! error TS2304: Cannot find name 'a'.
a.b;
}
function f1<T extends typeof a>({a}: {a:T}) {
~
!!! error TS2304: Cannot find name 'a'.
a.b;
}
function f2<T extends typeof a>([a]: T[]) {
~
!!! error TS2304: Cannot find name 'a'.
a.b;
}
class A {
m0<T extends typeof a>(a: T) {
~
!!! error TS2304: Cannot find name 'a'.
a.b
}
m1<T extends typeof a>({a}: {a:T}) {
~
!!! error TS2304: Cannot find name 'a'.
a.b
}
m2<T extends typeof a>([a]: T[]) {
~
!!! error TS2304: Cannot find name 'a'.
a.b
}
}

View File

@@ -0,0 +1,53 @@
//// [parameterNamesInTypeParameterList.ts]
function f0<T extends typeof a>(a: T) {
a.b;
}
function f1<T extends typeof a>({a}: {a:T}) {
a.b;
}
function f2<T extends typeof a>([a]: T[]) {
a.b;
}
class A {
m0<T extends typeof a>(a: T) {
a.b
}
m1<T extends typeof a>({a}: {a:T}) {
a.b
}
m2<T extends typeof a>([a]: T[]) {
a.b
}
}
//// [parameterNamesInTypeParameterList.js]
function f0(a) {
a.b;
}
function f1(_a) {
var a = _a.a;
a.b;
}
function f2(_a) {
var a = _a[0];
a.b;
}
var A = (function () {
function A() {
}
A.prototype.m0 = function (a) {
a.b;
};
A.prototype.m1 = function (_a) {
var a = _a.a;
a.b;
};
A.prototype.m2 = function (_a) {
var a = _a[0];
a.b;
};
return A;
})();

View File

@@ -0,0 +1,17 @@
tests/cases/compiler/typeParametersAndParametersInComputedNames.ts(6,10): error TS2304: Cannot find name 'T'.
tests/cases/compiler/typeParametersAndParametersInComputedNames.ts(6,13): error TS2304: Cannot find name 'a'.
==== tests/cases/compiler/typeParametersAndParametersInComputedNames.ts (2 errors) ====
function foo<T>(a: T) : string {
return "";
}
class A {
[foo<T>(a)]<T>(a: T) {
~
!!! error TS2304: Cannot find name 'T'.
~
!!! error TS2304: Cannot find name 'a'.
}
}

View File

@@ -0,0 +1,21 @@
//// [typeParametersAndParametersInComputedNames.ts]
function foo<T>(a: T) : string {
return "";
}
class A {
[foo<T>(a)]<T>(a: T) {
}
}
//// [typeParametersAndParametersInComputedNames.js]
function foo(a) {
return "";
}
var A = (function () {
function A() {
}
A.prototype[foo(a)] = function (a) {
};
return A;
})();