2014-09-12 22:35:07 +02:00
tests/cases/conformance/functions/functionOverloadErrors.ts(2,14): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
tests/cases/conformance/functions/functionOverloadErrors.ts(44,25): error TS2304: Cannot find name 'Window'.
tests/cases/conformance/functions/functionOverloadErrors.ts(50,25): error TS2304: Cannot find name 'Window'.
tests/cases/conformance/functions/functionOverloadErrors.ts(51,32): error TS2304: Cannot find name 'window'.
2014-09-18 02:05:45 +02:00
tests/cases/conformance/functions/functionOverloadErrors.ts(65,13): error TS2385: Overload signatures must all be public, private or protected.
tests/cases/conformance/functions/functionOverloadErrors.ts(68,13): error TS2385: Overload signatures must all be public, private or protected.
2014-09-12 22:35:07 +02:00
tests/cases/conformance/functions/functionOverloadErrors.ts(75,21): error TS2383: Overload signatures must all be exported or not exported.
tests/cases/conformance/functions/functionOverloadErrors.ts(79,14): error TS2383: Overload signatures must all be exported or not exported.
tests/cases/conformance/functions/functionOverloadErrors.ts(85,18): error TS2384: Overload signatures must all be ambient or non-ambient.
tests/cases/conformance/functions/functionOverloadErrors.ts(90,18): error TS2384: Overload signatures must all be ambient or non-ambient.
tests/cases/conformance/functions/functionOverloadErrors.ts(94,1): error TS2394: Overload signature is not compatible with function implementation.
tests/cases/conformance/functions/functionOverloadErrors.ts(99,1): error TS2394: Overload signature is not compatible with function implementation.
tests/cases/conformance/functions/functionOverloadErrors.ts(103,1): error TS2394: Overload signature is not compatible with function implementation.
tests/cases/conformance/functions/functionOverloadErrors.ts(116,19): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
2014-07-31 01:27:13 +02:00
==== tests/cases/conformance/functions/functionOverloadErrors.ts (14 errors) ====
2014-07-13 01:04:16 +02:00
//Function overload signature with initializer
function fn1(x = 3);
~~~~~
2014-09-12 00:19:57 +02:00
!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
2014-07-13 01:04:16 +02:00
function fn1() { }
//Multiple function overload signatures that are identical
function fn2a();
function fn2a();
function fn2a() {
}
function fn2b(n: number[]);
function fn2b(n: Array<number>);
function fn2b() {
}
//Multiple function overload signatures that differ only by return type
function fn3(x: string): string;
function fn3(y: string): number;
function fn3(): any {
return null;
}
//Function overload with rest param and another with only an optional parameter
function fn6(...t: any[]);
function fn6(x?: any);
function fn6() { }
//Function overload with rest param and another with only optional parameters
function fn7(...t: any[]);
function fn7(x?: any, y?: any, z?: any);
function fn7() { }
//Function overloads that differ only by type parameter name
function fn8<T>(n: string);
function fn8<S>(n: string);
function fn8() { }
//Function overloads that differ only by type parameter name when used in parameter type annotations
function fn9<T>(n: T);
function fn9<S>(n: S);
function fn9() { }
//Function overloads that differ only by type parameter constraints
function fn10<T extends Window>();
~~~~~~
2014-09-12 00:19:57 +02:00
!!! error TS2304: Cannot find name 'Window'.
2014-07-13 01:04:16 +02:00
function fn10<S extends Date>();
function fn10() { }
// (actually OK)
//Function overloads that differ only by type parameter constraints where constraints are structually identical
function fn11<T extends Window>();
~~~~~~
2014-09-12 00:19:57 +02:00
!!! error TS2304: Cannot find name 'Window'.
2014-07-13 01:04:16 +02:00
function fn11<S extends typeof window>();
~~~~~~
2014-09-12 00:19:57 +02:00
!!! error TS2304: Cannot find name 'window'.
2014-07-13 01:04:16 +02:00
function fn11() { }
//Function overloads that differ only by type parameter constraints where constraints include infinitely recursive type reference
interface List<T> {
parents: List<List<T>>;
}
function fn12<T extends List<List<any>>>();
function fn12<T extends List<any>>();
function fn12() { }
//Function overloads that differ by accessibility
class cls {
public f();
private f(s: string);
~
2014-09-18 02:05:45 +02:00
!!! error TS2385: Overload signatures must all be public, private or protected.
2014-07-13 01:04:16 +02:00
f() { }
private g(s: string);
~
2014-09-18 02:05:45 +02:00
!!! error TS2385: Overload signatures must all be public, private or protected.
2014-07-13 01:04:16 +02:00
public g();
g() { }
}
//Function overloads with differing export
module M {
export function fn1();
2014-07-22 21:09:25 +02:00
~~~
2014-09-12 00:19:57 +02:00
!!! error TS2383: Overload signatures must all be exported or not exported.
2014-07-13 01:04:16 +02:00
function fn1(n: string);
function fn1() { }
function fn2(n: string);
2014-07-22 21:09:25 +02:00
~~~
2014-09-12 00:19:57 +02:00
!!! error TS2383: Overload signatures must all be exported or not exported.
2014-07-13 01:04:16 +02:00
export function fn2();
export function fn2() { }
}
//Function overloads with differing ambience
declare function dfn1();
~~~~
2014-09-12 00:19:57 +02:00
!!! error TS2384: Overload signatures must all be ambient or non-ambient.
2014-07-13 01:04:16 +02:00
function dfn1(s: string);
function dfn1() { }
function dfn2();
declare function dfn2(s: string);
~~~~
2014-09-12 00:19:57 +02:00
!!! error TS2384: Overload signatures must all be ambient or non-ambient.
2014-07-13 01:04:16 +02:00
function dfn2() { }
//Function overloads with fewer params than implementation signature
function fewerParams();
~~~~~~~~~~~~~~~~~~~~~~~
2014-09-12 00:19:57 +02:00
!!! error TS2394: Overload signature is not compatible with function implementation.
2014-07-13 01:04:16 +02:00
function fewerParams(n: string) {
}
//Function implementation whose parameter types are not assignable to all corresponding overload signature parameters
function fn13(n: string);
~~~~~~~~~~~~~~~~~~~~~~~~~
2014-09-12 00:19:57 +02:00
!!! error TS2394: Overload signature is not compatible with function implementation.
2014-07-13 01:04:16 +02:00
function fn13(n: number) { }
//Function overloads where return types are not all subtype of implementation return type
function fn14(n: string): string;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2014-09-12 00:19:57 +02:00
!!! error TS2394: Overload signature is not compatible with function implementation.
2014-07-13 01:04:16 +02:00
function fn14() {
return 3;
}
//Function overloads where return types are different infinitely recursive type reference
function fn15<T extends List<List<any>>>(): T;
function fn15<T extends List<any>>(): T;
function fn15() {
return undefined;
}
//Function overloads which use initializer expressions
function initExpr(n = 13);
~~~~~~
2014-09-12 00:19:57 +02:00
!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
2014-07-13 01:04:16 +02:00
function initExpr() { }