46 lines
687 B
TypeScript
46 lines
687 B
TypeScript
//// [objectTypesWithOptionalProperties2.ts]
|
|
// Illegal attempts to define optional methods
|
|
|
|
var a: {
|
|
x()?: number; // error
|
|
}
|
|
|
|
interface I {
|
|
x()?: number; // error
|
|
}
|
|
|
|
class C {
|
|
x()?: number; // error
|
|
}
|
|
|
|
interface I2<T> {
|
|
x()?: T; // error
|
|
}
|
|
|
|
class C2<T> {
|
|
x()?: T; // error
|
|
}
|
|
|
|
|
|
var b = {
|
|
x()?: 1 // error
|
|
}
|
|
|
|
//// [objectTypesWithOptionalProperties2.js]
|
|
// Illegal attempts to define optional methods
|
|
var a;
|
|
var C = (function () {
|
|
function C() {
|
|
}
|
|
C.prototype.x = ;
|
|
return C;
|
|
})();
|
|
var C2 = (function () {
|
|
function C2() {
|
|
}
|
|
C2.prototype.x = ;
|
|
return C2;
|
|
})();
|
|
var b = {
|
|
x: function () { }, 1: // error
|
|
};
|