File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -176,6 +176,18 @@ interface ObjectConstructor {
176176 */
177177 seal < T > ( o : T ) : T ;
178178
179+ /**
180+ * Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
181+ * @param o Object on which to lock the attributes.
182+ */
183+ freeze < T > ( a : T [ ] ) : ReadonlyArray < T > ;
184+
185+ /**
186+ * Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
187+ * @param o Object on which to lock the attributes.
188+ */
189+ freeze < T , U > ( f : ( ...args : T [ ] ) => U ) : ( ...args : T [ ] ) => U ;
190+
179191 /**
180192 * Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
181193 * @param o Object on which to lock the attributes.
Original file line number Diff line number Diff line change 1+ tests/cases/compiler/objectFreeze.ts(5,24): error TS2345: Argument of type '123' is not assignable to parameter of type 'string'.
2+ tests/cases/compiler/objectFreeze.ts(6,2): error TS1128: Declaration or statement expected.
3+
4+
5+ ==== tests/cases/compiler/objectFreeze.ts (2 errors) ====
6+ class A {
7+ constructor(public a1: string) {
8+ }
9+ }
10+ function foo(x = new A(123)) { //should error, 123 is not string
11+ ~~~
12+ !!! error TS2345: Argument of type '123' is not assignable to parameter of type 'string'.
13+ }}
14+ ~
15+ !!! error TS1128: Declaration or statement expected.
Original file line number Diff line number Diff line change 1+ //// [objectFreeze.ts]
2+ class A {
3+ constructor ( public a1 : string ) {
4+ }
5+ }
6+ function foo ( x = new A ( 123 ) ) { //should error, 123 is not string
7+ } }
8+
9+ //// [objectFreeze.js]
10+ var A = ( function ( ) {
11+ function A ( a1 ) {
12+ this . a1 = a1 ;
13+ }
14+ return A ;
15+ } ( ) ) ;
16+ function foo ( x ) {
17+ if ( x === void 0 ) { x = new A ( 123 ) ; }
18+ }
Original file line number Diff line number Diff line change 1+ class A {
2+ constructor ( public a1 : string ) {
3+ }
4+ }
5+ function foo ( x = new A ( 123 ) ) { //should error, 123 is not string
6+ } }
You can’t perform that action at this time.
0 commit comments