From 4c6e802772dbfbccfe5d8b86150366533729da61 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Fri, 13 May 2022 14:45:42 -0700 Subject: [PATCH] Remove bigint from Object.freeze in es5.d.ts `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. --- src/lib/es5.d.ts | 2 +- .../contextualSignatureInObjectFreeze.js | 13 +++++++++++++ .../contextualSignatureInObjectFreeze.symbols | 13 +++++++++++++ .../contextualSignatureInObjectFreeze.types | 16 ++++++++++++++++ .../contextualSignatureInObjectFreeze.ts | 7 +++++++ 5 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/contextualSignatureInObjectFreeze.js create mode 100644 tests/baselines/reference/contextualSignatureInObjectFreeze.symbols create mode 100644 tests/baselines/reference/contextualSignatureInObjectFreeze.types create mode 100644 tests/cases/compiler/contextualSignatureInObjectFreeze.ts diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 75b9539cc75..26ba191eb69 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -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(o: T): Readonly; + freeze(o: T): Readonly; /** * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. diff --git a/tests/baselines/reference/contextualSignatureInObjectFreeze.js b/tests/baselines/reference/contextualSignatureInObjectFreeze.js new file mode 100644 index 00000000000..e25ef7ab247 --- /dev/null +++ b/tests/baselines/reference/contextualSignatureInObjectFreeze.js @@ -0,0 +1,13 @@ +//// [contextualSignatureInObjectFreeze.ts] +// #49101 + +Object.freeze({ + f: function () { } +}) + + +//// [contextualSignatureInObjectFreeze.js] +// #49101 +Object.freeze({ + f: function () { } +}); diff --git a/tests/baselines/reference/contextualSignatureInObjectFreeze.symbols b/tests/baselines/reference/contextualSignatureInObjectFreeze.symbols new file mode 100644 index 00000000000..68e9d81c600 --- /dev/null +++ b/tests/baselines/reference/contextualSignatureInObjectFreeze.symbols @@ -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)) + +}) + diff --git a/tests/baselines/reference/contextualSignatureInObjectFreeze.types b/tests/baselines/reference/contextualSignatureInObjectFreeze.types new file mode 100644 index 00000000000..3d40afe1f08 --- /dev/null +++ b/tests/baselines/reference/contextualSignatureInObjectFreeze.types @@ -0,0 +1,16 @@ +=== tests/cases/compiler/contextualSignatureInObjectFreeze.ts === +// #49101 + +Object.freeze({ +>Object.freeze({ f: function () { }}) : Readonly<{ f: () => void; }> +>Object.freeze : { (a: T[]): readonly T[]; (f: T): T; (o: T): Readonly; (o: T): Readonly; } +>Object : ObjectConstructor +>freeze : { (a: T[]): readonly T[]; (f: T): T; (o: T): Readonly; (o: T): Readonly; } +>{ f: function () { }} : { f: () => void; } + + f: function () { } +>f : () => void +>function () { } : () => void + +}) + diff --git a/tests/cases/compiler/contextualSignatureInObjectFreeze.ts b/tests/cases/compiler/contextualSignatureInObjectFreeze.ts new file mode 100644 index 00000000000..1f2c561c13d --- /dev/null +++ b/tests/cases/compiler/contextualSignatureInObjectFreeze.ts @@ -0,0 +1,7 @@ +// #49101 +// @target: es2020 +// @lib: es2019 + +Object.freeze({ + f: function () { } +})