163 lines
No EOL
7 KiB
Text
163 lines
No EOL
7 KiB
Text
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'.
|
|
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.
|
|
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,10): error TS2394: Overload signature is not compatible with function implementation.
|
|
tests/cases/conformance/functions/functionOverloadErrors.ts(99,10): error TS2394: Overload signature is not compatible with function implementation.
|
|
tests/cases/conformance/functions/functionOverloadErrors.ts(103,10): 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.
|
|
|
|
|
|
==== tests/cases/conformance/functions/functionOverloadErrors.ts (14 errors) ====
|
|
//Function overload signature with initializer
|
|
function fn1(x = 3);
|
|
~~~~~
|
|
!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
|
|
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>();
|
|
~~~~~~
|
|
!!! error TS2304: Cannot find name 'Window'.
|
|
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>();
|
|
~~~~~~
|
|
!!! error TS2304: Cannot find name 'Window'.
|
|
function fn11<S extends typeof window>();
|
|
~~~~~~
|
|
!!! error TS2304: Cannot find name 'window'.
|
|
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);
|
|
~
|
|
!!! error TS2385: Overload signatures must all be public, private or protected.
|
|
f() { }
|
|
|
|
private g(s: string);
|
|
~
|
|
!!! error TS2385: Overload signatures must all be public, private or protected.
|
|
public g();
|
|
g() { }
|
|
}
|
|
|
|
//Function overloads with differing export
|
|
module M {
|
|
export function fn1();
|
|
~~~
|
|
!!! error TS2383: Overload signatures must all be exported or not exported.
|
|
function fn1(n: string);
|
|
function fn1() { }
|
|
|
|
function fn2(n: string);
|
|
~~~
|
|
!!! error TS2383: Overload signatures must all be exported or not exported.
|
|
export function fn2();
|
|
export function fn2() { }
|
|
}
|
|
|
|
//Function overloads with differing ambience
|
|
declare function dfn1();
|
|
~~~~
|
|
!!! error TS2384: Overload signatures must all be ambient or non-ambient.
|
|
function dfn1(s: string);
|
|
function dfn1() { }
|
|
|
|
function dfn2();
|
|
declare function dfn2(s: string);
|
|
~~~~
|
|
!!! error TS2384: Overload signatures must all be ambient or non-ambient.
|
|
function dfn2() { }
|
|
|
|
//Function overloads with fewer params than implementation signature
|
|
function fewerParams();
|
|
~~~~~~~~~~~
|
|
!!! error TS2394: Overload signature is not compatible with function implementation.
|
|
function fewerParams(n: string) {
|
|
}
|
|
|
|
//Function implementation whose parameter types are not assignable to all corresponding overload signature parameters
|
|
function fn13(n: string);
|
|
~~~~
|
|
!!! error TS2394: Overload signature is not compatible with function implementation.
|
|
function fn13(n: number) { }
|
|
|
|
//Function overloads where return types are not all subtype of implementation return type
|
|
function fn14(n: string): string;
|
|
~~~~
|
|
!!! error TS2394: Overload signature is not compatible with function implementation.
|
|
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);
|
|
~~~~~~
|
|
!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
|
|
function initExpr() { }
|
|
|