mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
37 lines
842 B
TypeScript
37 lines
842 B
TypeScript
//// [tests/cases/compiler/genericAssignmentCompatWithInterfaces1.ts] ////
|
|
|
|
//// [genericAssignmentCompatWithInterfaces1.ts]
|
|
interface Comparable<T> {
|
|
compareTo(other: T): number;
|
|
}
|
|
interface I<T> {
|
|
x: Comparable<T>;
|
|
}
|
|
interface K<T> {
|
|
x: A<T>;
|
|
}
|
|
class A<T> implements Comparable<T> { compareTo(other: T) { return 1; } }
|
|
var z = { x: new A<number>() };
|
|
var a1: I<string> = { x: new A<number>() };
|
|
var a2: I<string> = function (): { x: A<number> } {
|
|
var z = { x: new A<number>() }; return z;
|
|
} ();
|
|
var a3: I<string> = z;
|
|
var a4: I<string> = <K<number>>z;
|
|
|
|
|
|
|
|
//// [genericAssignmentCompatWithInterfaces1.js]
|
|
"use strict";
|
|
class A {
|
|
compareTo(other) { return 1; }
|
|
}
|
|
var z = { x: new A() };
|
|
var a1 = { x: new A() };
|
|
var a2 = function () {
|
|
var z = { x: new A() };
|
|
return z;
|
|
}();
|
|
var a3 = z;
|
|
var a4 = z;
|