Skip to content

Commit

Permalink
Remove bigint from Object.freeze in es5.d.ts
Browse files Browse the repository at this point in the history
`BigInt` isn't resolved whenever `lib < es2020`, but it's not an error
when `target < es2020`. I have a few ideas for improving this situation
but for the RC I'm going to remove `bigint` from Object.freeze's
signature.
  • Loading branch information
sandersn committed May 13, 2022
1 parent 0414dee commit 4c6e802
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/es5.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ interface ObjectConstructor {
* 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 {[idx: string]: U | null | undefined | object}, U extends string | bigint | number | boolean | symbol>(o: T): Readonly<T>;
freeze<T extends {[idx: string]: U | null | undefined | object}, U extends string | number | boolean | symbol>(o: T): Readonly<T>;

/**
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
Expand Down
13 changes: 13 additions & 0 deletions tests/baselines/reference/contextualSignatureInObjectFreeze.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//// [contextualSignatureInObjectFreeze.ts]
// #49101

Object.freeze({
f: function () { }
})


//// [contextualSignatureInObjectFreeze.js]
// #49101
Object.freeze({
f: function () { }
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
=== tests/cases/compiler/contextualSignatureInObjectFreeze.ts ===
// #49101

Object.freeze({
>Object.freeze : Symbol(ObjectConstructor.freeze, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>freeze : Symbol(ObjectConstructor.freeze, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))

f: function () { }
>f : Symbol(f, Decl(contextualSignatureInObjectFreeze.ts, 2, 15))

})

16 changes: 16 additions & 0 deletions tests/baselines/reference/contextualSignatureInObjectFreeze.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
=== tests/cases/compiler/contextualSignatureInObjectFreeze.ts ===
// #49101

Object.freeze({
>Object.freeze({ f: function () { }}) : Readonly<{ f: () => void; }>
>Object.freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
>Object : ObjectConstructor
>freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
>{ f: function () { }} : { f: () => void; }

f: function () { }
>f : () => void
>function () { } : () => void

})

7 changes: 7 additions & 0 deletions tests/cases/compiler/contextualSignatureInObjectFreeze.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// #49101
// @target: es2020
// @lib: es2019

Object.freeze({
f: function () { }
})

0 comments on commit 4c6e802

Please sign in to comment.