57 lines
No EOL
1.3 KiB
Text
57 lines
No EOL
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 is missing or not immediately following the declaration.
|
|
}
|
|
|
|
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 is missing or not immediately following the declaration.
|
|
}
|
|
|
|
|
|
var b = {
|
|
x()?: 1 // error
|
|
~
|
|
!!! '{' expected.
|
|
~
|
|
!!! Property assignment expected.
|
|
}
|
|
~
|
|
!!! ':' expected. |