57 lines
1.3 KiB
Text
57 lines
1.3 KiB
Text
|
==== tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWithOptionalProperties2.ts (15 errors) ====
|
||
|
// Illegal attempts to define optional methods
|
||
|
|
||
|
var a: {
|
||
|
x()?: number; // error
|
||
|
~
|
||
|
!!! ';' expected.
|
||
|
~
|
||
|
!!! Property or signature expected.
|
||
|
}
|
||
|
|
||
|
interface I {
|
||
|
x()?: number; // error
|
||
|
~
|
||
|
!!! ';' expected.
|
||
|
~
|
||
|
!!! Property or signature expected.
|
||
|
}
|
||
|
|
||
|
class C {
|
||
|
x()?: number; // error
|
||
|
~
|
||
|
!!! Block or ';' expected.
|
||
|
~
|
||
|
!!! Unexpected token. A constructor, method, accessor, or property was expected.
|
||
|
~~~
|
||
|
!!! Function implementation expected.
|
||
|
}
|
||
|
|
||
|
interface I2<T> {
|
||
|
x()?: T; // error
|
||
|
~
|
||
|
!!! ';' expected.
|
||
|
~
|
||
|
!!! Property or signature expected.
|
||
|
}
|
||
|
|
||
|
class C2<T> {
|
||
|
x()?: T; // error
|
||
|
~
|
||
|
!!! Block or ';' expected.
|
||
|
~
|
||
|
!!! Unexpected token. A constructor, method, accessor, or property was expected.
|
||
|
~~~
|
||
|
!!! Function implementation expected.
|
||
|
}
|
||
|
|
||
|
|
||
|
var b = {
|
||
|
x()?: 1 // error
|
||
|
~
|
||
|
!!! '{' expected.
|
||
|
~
|
||
|
!!! Property assignment expected.
|
||
|
}
|
||
|
~
|
||
|
!!! ':' expected.
|