File: targetTypeTest1.errors.txt

package info (click to toggle)
node-typescript 5.0.4%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 459,140 kB
  • sloc: javascript: 1,972,754; makefile: 6; sh: 1
file content (78 lines) | stat: -rw-r--r-- 2,151 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
tests/cases/compiler/targetTypeTest1.ts(19,18): error TS2384: Overload signatures must all be ambient or non-ambient.


==== tests/cases/compiler/targetTypeTest1.ts (1 errors) ====
    declare class Point
    {
          constructor(x: number, y: number);
          public x: number;
          public y: number;
          public add(dx: number, dy: number): Point;
          static origin: Point;
    
    }
    
    // Type provided by extern declaration
    // Because Point is a constructor function, this is inferred
    // to be Point and return type is inferred to be void
    function Point(x, y) {
        this.x = x;
        this.y = y;
    }
    
    declare function EF1(a:number, b:number):number;
                     ~~~
!!! error TS2384: Overload signatures must all be ambient or non-ambient.
    
    function EF1(a,b) { return a+b; }
    
    var x = EF1(1,2);
    
    // Point.origin declared as type Point
    Point.origin = new Point(0, 0);
    
    // Point.prototype declared as type Point
    // this inferred as Point because of obj.prop assignment
    // dx, dy, and return type inferred using target typing
    Point.prototype.add = function(dx, dy) {
        return new Point(this.x + dx, this.y + dy);
    };
    
    var f : number = 5;
    
    // Object literal type inferred using target typing
    // this in function add inferred to be type of object literal (i.e. Point)
    // dx, dy, and return type of add inferred using target typing
    Point.prototype = {
        x: 0,
        y: 0,
        add: function(dx, dy) {
            return new Point(this.x + dx, this.y + dy);
        }
    };
    
    declare var z;
    z = function(a: number) {
        a
    }
    
    declare class C {
        constructor(a:number, b:number);
    	public a : number;
    	public b: number;    
    	C1M1(c:number,d:number):number;
    } 
    
    function C(a,b) {
    	this.a=a;
    	this.b=b;
    }
    
    C.prototype = 
    	{	a:0,
    		b:0, 
    		C1M1: function(c,d) {     
    				return (this.a + c) + (this.b + d);
    			}
    	};