mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-09 07:55:10 -05:00
do not resolve parameters/type parameters if it is requested from restricted locations
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
})();
|
||||
@@ -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'.
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
})();
|
||||
Reference in New Issue
Block a user