Test that type parameters used in constraints are passed along

This commit is contained in:
Andrew Casey 2017-08-16 16:54:57 -07:00
parent fe015ef30f
commit 0c8d85fbc4
2 changed files with 43 additions and 1 deletions

View File

@ -574,6 +574,13 @@ namespace A {
[#|t1.toString();
t2.toString();|]
}
}`);
// Confirm that the constraint is preserved.
testExtractMethod("extractMethod15",
`function F<T>(t1: T) {
function F<U extends T[]>(t2: U) {
[#|t2.toString();|]
}
}`);
});
@ -590,7 +597,7 @@ namespace A {
path: "/a.ts",
content: t.source
};
const host = projectSystem.createServerHost([f]);
const host = projectSystem.createServerHost([f, projectSystem.libFile]);
const projectService = projectSystem.createProjectService(host);
projectService.openClientFile(f.path);
const program = projectService.inferredProjects[0].getLanguageService().getProgram();

View File

@ -0,0 +1,35 @@
// ==ORIGINAL==
function F<T>(t1: T) {
function F<U extends T[]>(t2: U) {
t2.toString();
}
}
// ==SCOPE::function 'F'==
function F<T>(t1: T) {
function F<U extends T[]>(t2: U) {
newFunction();
function newFunction() {
t2.toString();
}
}
}
// ==SCOPE::function 'F'==
function F<T>(t1: T) {
function F<U extends T[]>(t2: U) {
newFunction<U>(t2);
}
function newFunction<U extends T[]>(t2: U) {
t2.toString();
}
}
// ==SCOPE::global scope==
function F<T>(t1: T) {
function F<U extends T[]>(t2: U) {
newFunction<T, U>(t2);
}
}
function newFunction<T, U extends T[]>(t2: U) {
t2.toString();
}