File: functionArgShadowing.errors.txt

package info (click to toggle)
node-typescript 4.9.5%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 533,908 kB
  • sloc: javascript: 2,018,330; makefile: 7; sh: 1
file content (28 lines) | stat: -rw-r--r-- 1,455 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
tests/cases/compiler/functionArgShadowing.ts(4,8): error TS2403: Subsequent variable declarations must have the same type.  Variable 'x' must be of type 'A', but here has type 'B'.
tests/cases/compiler/functionArgShadowing.ts(5,8): error TS2339: Property 'bar' does not exist on type 'A'.
tests/cases/compiler/functionArgShadowing.ts(10,7): error TS2403: Subsequent variable declarations must have the same type.  Variable 'p' must be of type 'number', but here has type 'string'.


==== tests/cases/compiler/functionArgShadowing.ts (3 errors) ====
    class A { foo() { } }
    class B { bar() { } }
    function foo(x: A) {
       var x: B = new B();
           ~
!!! error TS2403: Subsequent variable declarations must have the same type.  Variable 'x' must be of type 'A', but here has type 'B'.
!!! related TS6203 tests/cases/compiler/functionArgShadowing.ts:3:14: 'x' was also declared here.
         x.bar(); // the property bar does not exist on a value of type A
           ~~~
!!! error TS2339: Property 'bar' does not exist on type 'A'.
    }
     
    class C {
    	constructor(public p: number) {
    		var p: string;
    		    ~
!!! error TS2403: Subsequent variable declarations must have the same type.  Variable 'p' must be of type 'number', but here has type 'string'.
!!! related TS6203 tests/cases/compiler/functionArgShadowing.ts:9:14: 'p' was also declared here.
    
    		var n: number = p;
    	}
    }