26 lines
No EOL
1.2 KiB
Text
26 lines
No EOL
1.2 KiB
Text
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'.
|
|
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'.
|
|
|
|
var n: number = p;
|
|
}
|
|
} |