Handel call and construct signatures
This commit is contained in:
parent
72df02cbbd
commit
60395565e6
12
src/lib/es5.d.ts
vendored
12
src/lib/es5.d.ts
vendored
|
@ -182,6 +182,18 @@ interface ObjectConstructor {
|
|||
*/
|
||||
freeze<T>(a: T[]): ReadonlyArray<T>;
|
||||
|
||||
/**
|
||||
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
|
||||
* @param o Object on which to lock the attributes.
|
||||
*/
|
||||
freeze<T extends (...args: any[]) => any>(f: T): T;
|
||||
|
||||
/**
|
||||
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
|
||||
* @param o Object on which to lock the attributes.
|
||||
*/
|
||||
freeze<T extends new (...args: any[]) => any>(c: T): T;
|
||||
|
||||
/**
|
||||
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
|
||||
* @param o Object on which to lock the attributes.
|
||||
|
|
|
@ -1,18 +1,22 @@
|
|||
tests/cases/compiler/objectFreeze.ts(5,1): error TS2542: Index signature in type 'ReadonlyArray<number>' only permits reading.
|
||||
tests/cases/compiler/objectFreeze.ts(8,3): error TS2540: Cannot assign to 'b' because it is a constant or a read-only property.
|
||||
tests/cases/compiler/objectFreeze.ts(9,1): error TS2542: Index signature in type 'ReadonlyArray<number>' only permits reading.
|
||||
tests/cases/compiler/objectFreeze.ts(12,3): error TS2540: Cannot assign to 'b' because it is a constant or a read-only property.
|
||||
|
||||
|
||||
==== tests/cases/compiler/objectFreeze.ts (2 errors) ====
|
||||
const f = Object.freeze(function foo(a: number, b: string) { return false; });
|
||||
f(1, "") === false;
|
||||
|
||||
class C { constructor(a: number) { } }
|
||||
const c = Object.freeze(C);
|
||||
new c(1);
|
||||
|
||||
const a = Object.freeze([1, 2, 3]);
|
||||
a[0] = 1;
|
||||
a[0] = a[2].toString();
|
||||
~~~~
|
||||
!!! error TS2542: Index signature in type 'ReadonlyArray<number>' only permits reading.
|
||||
|
||||
const o = Object.freeze({ a: 1, b: "string" });
|
||||
o.b = "another";
|
||||
o.b = o.a.toString();
|
||||
~
|
||||
!!! error TS2540: Cannot assign to 'b' because it is a constant or a read-only property.
|
||||
|
|
@ -2,17 +2,28 @@
|
|||
const f = Object.freeze(function foo(a: number, b: string) { return false; });
|
||||
f(1, "") === false;
|
||||
|
||||
class C { constructor(a: number) { } }
|
||||
const c = Object.freeze(C);
|
||||
new c(1);
|
||||
|
||||
const a = Object.freeze([1, 2, 3]);
|
||||
a[0] = 1;
|
||||
a[0] = a[2].toString();
|
||||
|
||||
const o = Object.freeze({ a: 1, b: "string" });
|
||||
o.b = "another";
|
||||
o.b = o.a.toString();
|
||||
|
||||
|
||||
//// [objectFreeze.js]
|
||||
var f = Object.freeze(function foo(a, b) { return false; });
|
||||
f(1, "") === false;
|
||||
var C = (function () {
|
||||
function C(a) {
|
||||
}
|
||||
return C;
|
||||
}());
|
||||
var c = Object.freeze(C);
|
||||
new c(1);
|
||||
var a = Object.freeze([1, 2, 3]);
|
||||
a[0] = 1;
|
||||
a[0] = a[2].toString();
|
||||
var o = Object.freeze({ a: 1, b: "string" });
|
||||
o.b = "another";
|
||||
o.b = o.a.toString();
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
const f = Object.freeze(function foo(a: number, b: string) { return false; });
|
||||
f(1, "") === false;
|
||||
|
||||
class C { constructor(a: number) { } }
|
||||
const c = Object.freeze(C);
|
||||
new c(1);
|
||||
|
||||
const a = Object.freeze([1, 2, 3]);
|
||||
a[0] = 1;
|
||||
a[0] = a[2].toString();
|
||||
|
||||
const o = Object.freeze({ a: 1, b: "string" });
|
||||
o.b = "another";
|
||||
o.b = o.a.toString();
|
||||
|
|
Loading…
Reference in a new issue