d33127ad34
In effect this fixes #62. Also - Changes the error message for get accessors lacking return expressions. - Actually checks for return expressions instead of return statements for get-accessors. - Removes fancy quotes. - Corrects errors in the compiler caught by the new check. - Simplified `checkAndAggregateReturnTypes` by extracting it out to `visitReturnStatements`.
61 lines
No EOL
1.6 KiB
Text
61 lines
No EOL
1.6 KiB
Text
==== tests/cases/compiler/unknownSymbols1.ts (14 errors) ====
|
|
var x = asdf;
|
|
~~~~
|
|
!!! Cannot find name 'asdf'.
|
|
var y: asdf;
|
|
~~~~
|
|
!!! Cannot find name 'asdf'.
|
|
|
|
function foo(x: asdf, y: number): asdf { }
|
|
~~~~
|
|
!!! Cannot find name 'asdf'.
|
|
~~~~
|
|
!!! A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement.
|
|
~~~~
|
|
!!! Cannot find name 'asdf'.
|
|
function foo2() {
|
|
return asdf;
|
|
~~~~
|
|
!!! Cannot find name 'asdf'.
|
|
}
|
|
|
|
var z = <asdf>x; // should be an error
|
|
~~~~
|
|
!!! Cannot find name 'asdf'.
|
|
|
|
class C<T> {
|
|
foo: asdf;
|
|
~~~~
|
|
!!! Cannot find name 'asdf'.
|
|
bar: C<asdf>;
|
|
~~~~
|
|
!!! Cannot find name 'asdf'.
|
|
}
|
|
|
|
class C2 implements asdf { }
|
|
~~~~
|
|
!!! Cannot find name 'asdf'.
|
|
interface I extends adsf { }
|
|
~~~~
|
|
!!! Cannot find name 'adsf'.
|
|
|
|
class C3 { constructor(x: any) { } }
|
|
class C4 extends C3 {
|
|
constructor() {
|
|
super(asdf);
|
|
~~~~
|
|
!!! Cannot find name 'asdf'.
|
|
}
|
|
}
|
|
|
|
var x2 = this.asdf; // no error, this is any
|
|
|
|
class C5 {
|
|
constructor() {
|
|
this.asdf = asdf;
|
|
~~~~
|
|
!!! Property 'asdf' does not exist on type 'C5'.
|
|
~~~~
|
|
!!! Cannot find name 'asdf'.
|
|
}
|
|
} |