57 lines
1.5 KiB
Plaintext
57 lines
1.5 KiB
Plaintext
==== tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWithOptionalProperties2.ts (15 errors) ====
|
|
// Illegal attempts to define optional methods
|
|
|
|
var a: {
|
|
x()?: number; // error
|
|
~
|
|
!!! error TS1005: ';' expected.
|
|
~
|
|
!!! error TS1131: Property or signature expected.
|
|
}
|
|
|
|
interface I {
|
|
x()?: number; // error
|
|
~
|
|
!!! error TS1005: ';' expected.
|
|
~
|
|
!!! error TS1131: Property or signature expected.
|
|
}
|
|
|
|
class C {
|
|
x()?: number; // error
|
|
~
|
|
!!! error TS1144: Block or ';' expected.
|
|
~
|
|
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
|
|
~
|
|
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
|
|
}
|
|
|
|
interface I2<T> {
|
|
x()?: T; // error
|
|
~
|
|
!!! error TS1005: ';' expected.
|
|
~
|
|
!!! error TS1131: Property or signature expected.
|
|
}
|
|
|
|
class C2<T> {
|
|
x()?: T; // error
|
|
~
|
|
!!! error TS1144: Block or ';' expected.
|
|
~
|
|
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
|
|
~
|
|
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
|
|
}
|
|
|
|
|
|
var b = {
|
|
x()?: 1 // error
|
|
~
|
|
!!! error TS1005: '{' expected.
|
|
~
|
|
!!! error TS1136: Property assignment expected.
|
|
}
|
|
~
|
|
!!! error TS1005: ':' expected. |