TypeScript/tests/baselines/reference/intTypeCheck.errors.txt

368 lines
11 KiB
Plaintext

==== tests/cases/compiler/intTypeCheck.ts (73 errors) ====
interface i1 {
//Property Signatures
p;
p1?;
p2?: string;
p3();
p4? ();
p5? (): void;
p6(pa1): void;
p7? (pa1, pa2): void;
}
interface i2 {
//Call Signatures
();
(): number;
(p);
(p1: string);
(p2?: string);
(...p3: any[]);
(p4: string, p5?: string);
(p6: string, ...p7: any[]);
}
interface i3 {
//Construct Signatures
new ();
new (): number;
new (p: string);
new (p2?: string);
new (...p3: any[]);
new (p4: string, p5?: string);
new (p6: string, ...p7: any[]);
}
interface i4 {
//Index Signatures
[p];
~
!!! An index signature parameter must have a type annotation.
[p1: string];
~~~~~~~~~~~~
!!! An index signature must have a type annotation.
[p2: string, p3: number];
~~
!!! An index signature must have exactly one parameter.
}
interface i5 extends i1 { }
interface i6 extends i2 { }
interface i7 extends i3 { }
interface i8 extends i4 { }
interface i9 { }
class Base { foo() { } }
interface i11 {
//Call Signatures
();
(): number;
(p);
(p1: string);
(p2?: string);
(...p3: any[]);
(p4: string, p5?: string);
(p6: string, ...p7: any[]);
//(p8?: string, ...p9: any[]);
//(p10:string, p8?: string, ...p9: any[]);
//Construct Signatures
new ();
new (): number;
new (p: string);
new (p2?: string);
new (...p3: any[]);
new (p4: string, p5?: string);
new (p6: string, ...p7: any[]);
//Index Signatures
[p];
~
!!! An index signature parameter must have a type annotation.
[p1: string];
~~~~~~~~~~~~
!!! An index signature must have a type annotation.
[p2: string, p3: number];
~~
!!! An index signature must have exactly one parameter.
//Property Signatures
p;
p1?;
p2?: string;
p3();
p4? ();
p5? (): void;
p6(pa1): void;
p7(pa1, pa2): void;
p7? (pa1, pa2): void;
~~
!!! Overload signatures must all be optional or required.
}
var anyVar: any;
//
// Property signatures
//
var obj0: i1;
var obj1: i1 = {
p: null,
p3: function ():any { return 0; },
p6: function (pa1):any { return 0; },
p7: function (pa1, pa2):any { return 0; }
};
var obj2: i1 = new Object();
~~~~
!!! Type 'Object' is not assignable to type 'i1':
!!! Property 'p' is missing in type 'Object'.
var obj3: i1 = new obj0;
~~~~~~~~
!!! Cannot use 'new' with an expression whose type lacks a call or construct signature.
var obj4: i1 = new Base;
~~~~
!!! Type 'Base' is not assignable to type 'i1':
!!! Property 'p' is missing in type 'Base'.
var obj5: i1 = null;
var obj6: i1 = function () { };
~~~~
!!! Type '() => void' is not assignable to type 'i1':
!!! Property 'p' is missing in type '() => void'.
//var obj7: i1 = function foo() { };
var obj8: i1 = <i1> anyVar;
var obj9: i1 = new <i1> anyVar;
~
!!! Expression expected.
~~~~
!!! Type 'boolean' is not assignable to type 'i1':
!!! Property 'p' is missing in type 'Boolean'.
~~
!!! Cannot find name 'i1'.
var obj10: i1 = new {};
~~~~~~
!!! Cannot use 'new' with an expression whose type lacks a call or construct signature.
//
// Call signatures
//
var obj11: i2;
var obj12: i2 = {};
~~~~~
!!! Type '{}' is not assignable to type 'i2'.
var obj13: i2 = new Object();
~~~~~
!!! Type 'Object' is not assignable to type 'i2'.
var obj14: i2 = new obj11;
~~~~~~~~~
!!! Only a void function can be called with the 'new' keyword.
var obj15: i2 = new Base;
~~~~~
!!! Type 'Base' is not assignable to type 'i2'.
var obj16: i2 = null;
var obj17: i2 = function ():any { return 0; };
//var obj18: i2 = function foo() { };
var obj19: i2 = <i2> anyVar;
var obj20: i2 = new <i2> anyVar;
~
!!! Expression expected.
~~~~~
!!! Type 'boolean' is not assignable to type 'i2'.
~~
!!! Cannot find name 'i2'.
var obj21: i2 = new {};
~~~~~~
!!! Cannot use 'new' with an expression whose type lacks a call or construct signature.
//
// Construct Signatures
//
var obj22: i3;
var obj23: i3 = {};
~~~~~
!!! Type '{}' is not assignable to type 'i3'.
var obj24: i3 = new Object();
~~~~~
!!! Type 'Object' is not assignable to type 'i3'.
var obj25: i3 = new obj22;
var obj26: i3 = new Base;
~~~~~
!!! Type 'Base' is not assignable to type 'i3'.
var obj27: i3 = null;
var obj28: i3 = function () { };
~~~~~
!!! Type '() => void' is not assignable to type 'i3'.
//var obj29: i3 = function foo() { };
var obj30: i3 = <i3> anyVar;
var obj31: i3 = new <i3> anyVar;
~
!!! Expression expected.
~~~~~
!!! Type 'boolean' is not assignable to type 'i3'.
~~
!!! Cannot find name 'i3'.
var obj32: i3 = new {};
~~~~~~
!!! Cannot use 'new' with an expression whose type lacks a call or construct signature.
//
// Index Signatures
//
var obj33: i4;
var obj34: i4 = {};
var obj35: i4 = new Object();
~~~~~
!!! Type 'Object' is not assignable to type 'i4':
!!! Index signature is missing in type 'Object'.
var obj36: i4 = new obj33;
~~~~~~~~~
!!! Cannot use 'new' with an expression whose type lacks a call or construct signature.
var obj37: i4 = new Base;
~~~~~
!!! Type 'Base' is not assignable to type 'i4':
!!! Index signature is missing in type 'Base'.
var obj38: i4 = null;
var obj39: i4 = function () { };
~~~~~
!!! Type '() => void' is not assignable to type 'i4':
!!! Index signature is missing in type '() => void'.
//var obj40: i4 = function foo() { };
var obj41: i4 = <i4> anyVar;
var obj42: i4 = new <i4> anyVar;
~
!!! Expression expected.
~~~~~
!!! Type 'boolean' is not assignable to type 'i4':
!!! Index signature is missing in type 'Boolean'.
~~
!!! Cannot find name 'i4'.
var obj43: i4 = new {};
~~~~~~
!!! Cannot use 'new' with an expression whose type lacks a call or construct signature.
//
// Interface Derived I1
//
var obj44: i5;
var obj45: i5 = {};
~~~~~
!!! Type '{}' is not assignable to type 'i5':
!!! Property 'p' is missing in type '{}'.
var obj46: i5 = new Object();
~~~~~
!!! Type 'Object' is not assignable to type 'i5':
!!! Property 'p' is missing in type 'Object'.
var obj47: i5 = new obj44;
~~~~~~~~~
!!! Cannot use 'new' with an expression whose type lacks a call or construct signature.
var obj48: i5 = new Base;
~~~~~
!!! Type 'Base' is not assignable to type 'i5':
!!! Property 'p' is missing in type 'Base'.
var obj49: i5 = null;
var obj50: i5 = function () { };
~~~~~
!!! Type '() => void' is not assignable to type 'i5':
!!! Property 'p' is missing in type '() => void'.
//var obj51: i5 = function foo() { };
var obj52: i5 = <i5> anyVar;
var obj53: i5 = new <i5> anyVar;
~
!!! Expression expected.
~~~~~
!!! Type 'boolean' is not assignable to type 'i5':
!!! Property 'p' is missing in type 'Boolean'.
~~
!!! Cannot find name 'i5'.
var obj54: i5 = new {};
~~~~~~
!!! Cannot use 'new' with an expression whose type lacks a call or construct signature.
//
// Interface Derived I2
//
var obj55: i6;
var obj56: i6 = {};
~~~~~
!!! Type '{}' is not assignable to type 'i6'.
var obj57: i6 = new Object();
~~~~~
!!! Type 'Object' is not assignable to type 'i6'.
var obj58: i6 = new obj55;
~~~~~~~~~
!!! Only a void function can be called with the 'new' keyword.
var obj59: i6 = new Base;
~~~~~
!!! Type 'Base' is not assignable to type 'i6'.
var obj60: i6 = null;
var obj61: i6 = function () { };
~~~~~
!!! Type '() => void' is not assignable to type 'i6':
!!! Type 'void' is not assignable to type 'number'.
//var obj62: i6 = function foo() { };
var obj63: i6 = <i6> anyVar;
var obj64: i6 = new <i6> anyVar;
~
!!! Expression expected.
~~~~~
!!! Type 'boolean' is not assignable to type 'i6'.
~~
!!! Cannot find name 'i6'.
var obj65: i6 = new {};
~~~~~~
!!! Cannot use 'new' with an expression whose type lacks a call or construct signature.
//
// Interface Derived I3
//
var obj66: i7;
var obj67: i7 = {};
~~~~~
!!! Type '{}' is not assignable to type 'i7'.
var obj68: i7 = new Object();
~~~~~
!!! Type 'Object' is not assignable to type 'i7'.
var obj69: i7 = new obj66;
var obj70: i7 = <i7>new Base;
~~~~~~~~~~~~
!!! Neither type 'i7' nor type 'Base' is assignable to the other.
var obj71: i7 = null;
var obj72: i7 = function () { };
~~~~~
!!! Type '() => void' is not assignable to type 'i7'.
//var obj73: i7 = function foo() { };
var obj74: i7 = <i7> anyVar;
var obj75: i7 = new <i7> anyVar;
~
!!! Expression expected.
~~~~~
!!! Type 'boolean' is not assignable to type 'i7'.
~~
!!! Cannot find name 'i7'.
var obj76: i7 = new {};
~~~~~~
!!! Cannot use 'new' with an expression whose type lacks a call or construct signature.
//
// Interface Derived I4
//
var obj77: i8;
var obj78: i8 = {};
var obj79: i8 = new Object();
~~~~~
!!! Type 'Object' is not assignable to type 'i8':
!!! Index signature is missing in type 'Object'.
var obj80: i8 = new obj77;
~~~~~~~~~
!!! Cannot use 'new' with an expression whose type lacks a call or construct signature.
var obj81: i8 = new Base;
~~~~~
!!! Type 'Base' is not assignable to type 'i8':
!!! Index signature is missing in type 'Base'.
var obj82: i8 = null;
var obj83: i8 = function () { };
~~~~~
!!! Type '() => void' is not assignable to type 'i8':
!!! Index signature is missing in type '() => void'.
//var obj84: i8 = function foo() { };
var obj85: i8 = <i8> anyVar;
var obj86: i8 = new <i8> anyVar;
~
!!! Expression expected.
~~~~~
!!! Type 'boolean' is not assignable to type 'i8':
!!! Index signature is missing in type 'Boolean'.
~~
!!! Cannot find name 'i8'.
var obj87: i8 = new {};
~~~~~~
!!! Cannot use 'new' with an expression whose type lacks a call or construct signature.