mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
51 lines
922 B
TypeScript
51 lines
922 B
TypeScript
//// [tests/cases/compiler/assignmentCompatWithOverloads.ts] ////
|
|
|
|
//// [assignmentCompatWithOverloads.ts]
|
|
function f1(x: string): number { return null; }
|
|
|
|
function f2(x: string): string { return null; }
|
|
|
|
function f3(x: number): number { return null; }
|
|
|
|
function f4(x: string): string;
|
|
|
|
function f4(x: number): number;
|
|
|
|
function f4(x: any): any { return undefined; }
|
|
|
|
var g: (s1: string) => number;
|
|
|
|
g = f1; // OK
|
|
|
|
g = f2; // Error
|
|
|
|
g = f3; // Error
|
|
|
|
g = f4; // Error
|
|
|
|
class C {
|
|
constructor(x: string);
|
|
constructor(x: any) {}
|
|
}
|
|
|
|
var d: new(x: number) => void;
|
|
|
|
d = C; // Error
|
|
|
|
//// [assignmentCompatWithOverloads.js]
|
|
"use strict";
|
|
function f1(x) { return null; }
|
|
function f2(x) { return null; }
|
|
function f3(x) { return null; }
|
|
function f4(x) { return undefined; }
|
|
var g;
|
|
g = f1; // OK
|
|
g = f2; // Error
|
|
g = f3; // Error
|
|
g = f4; // Error
|
|
class C {
|
|
constructor(x) { }
|
|
}
|
|
var d;
|
|
d = C; // Error
|