Repository: babel/babel (TypeScript)

Issue:
[Bug]: Wrong error name
### 💻

- [ ] Would you like to work on a fix?

### How are you using Babel?

Other (Next.js, Gatsby, vue-cli, ...)

### Input code

```js
"use strict";
let { 0 : x } = { get 0 ( ) { return super [ 0 ] = 0 ; } } ;
```

### Configuration file name

_No response_

### Configuration

_No response_

### Current and expected behavior

Running the `input.js` code should throw `TypeError`:
```js
// input.js
"use strict";
let { 0 : x } = { get 0 ( ) { return super [ 0 ] = 0 ; } } ;
```
```console
❯ node input.js
input.js:2
let { 0 : x } = { get 0 ( ) { return super [ 0 ] = 0 ; } } ;
                                                 ^

TypeError: Cannot redefine property: 0
    at get 0 [as 0] (/Users/p51lee/dev/esmeta-plrg/.test.js:2:50)
    at Object.<anonymous> (/Users/p51lee/dev/esmeta-plrg/.test.js:2:11)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47
```

However, transpilation result throws `Error`:
```js
// output.js
...
throw new Error("failed to set property");
...
```
```console
❯ node output.js
output.js:38
    throw new Error("failed to set property");
    ^

Error: failed to set property
    at _set (/Users/p51lee/dev/esmeta-plrg/.test2.js:38:11)
    at get 0 [as 0] (/Users/p51lee/dev/esmeta-plrg/.test2.js:72:14)
    at Object.<anonymous> (/Users/p51lee/dev/esmeta-plrg/.test2.js:75:8)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47
```

### Environment

[Reproduction on Babel's own REPL](https://babeljs.io/repl#?browsers=&build=&builtIns=false&corejs=3.21&spec=false&loose=false&code_lz=EQVwzgpgBGAuBOBLAxrYBuAUAGwrKA3lAAxQBcUAHlAL5QC8hUA5niVABRQCUT8eIeADsYIAA4R4UANrsAug3bpaK9EA&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&timeTravel=false&sourceType=script&lineWrap=true&presets=env%2Creact%2Cstage-2&prettier=true&targets=&version=7.20.0&externalPlugins=&assumptions=%7B%7D)

### Possible solution

Possibly it will be solved by changing the function `_set` that throws `Error("failed to set property")` to throw `TypeError` instead.

### Additional context

_No response_


Hints:
Hey @p51lee! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant [Slack community](https://babeljs.slack.com) that typically always has someone willing to help. You can sign-up [here](https://slack.babeljs.io/) for an invite.
Another helper with incorrect error type:

https://github.com/babel/babel/blob/859daa3c185d18901106d8e6c39898ba1ce8e8f4/packages/babel-helpers/src/helpers.ts#L651-L655

Should throw `ReferenceError` instead of `Error` in my opinion. (Example in [REPL](https://babeljs.io/repl/#?browsers=&build=&builtIns=false&corejs=3.21&spec=false&loose=false&code_lz=MYGwhgzhAEAa0G9oG1YF1oF5oEZoF8BuIA&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&timeTravel=false&sourceType=script&lineWrap=true&presets=env&prettier=true&targets=&version=7.20.6&externalPlugins=&assumptions=%7B%7D))

Patch:
diff --git a/packages/babel-helpers/src/helpers.ts b/packages/babel-helpers/src/helpers.ts
--- a/packages/babel-helpers/src/helpers.ts
+++ b/packages/babel-helpers/src/helpers.ts
@@ -612,7 +612,7 @@ helpers.set = helper("7.0.0-beta.0")`
   export default function _set(target, property, value, receiver, isStrict) {
     var s = set(target, property, value, receiver || target);
     if (!s && isStrict) {
-      throw new Error('failed to set property');
+      throw new TypeError('failed to set property');
     }
 
     return value;
@@ -650,7 +650,7 @@ helpers.writeOnlyError = helper("7.12.13")`
 
 helpers.classNameTDZError = helper("7.0.0-beta.0")`
   export default function _classNameTDZError(name) {
-    throw new Error("Class \\"" + name + "\\" cannot be referenced in computed property keys.");
+    throw new ReferenceError("Class \\"" + name + "\\" cannot be referenced in computed property keys.");
   }
 `;
 


Test patch:
diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/decorator-interop/input.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/decorator-interop/input.js
similarity index 100%
rename from packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/decorator-interop/input.js
rename to packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/decorator-interop/input.js
diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/decorator-interop/options.json b/packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/decorator-interop/options.json
similarity index 100%
rename from packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/decorator-interop/options.json
rename to packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/decorator-interop/options.json
diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/decorator-interop/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/decorator-interop/output.js
similarity index 100%
rename from packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/decorator-interop/output.js
rename to packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/decorator-interop/output.js
diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/general/exec.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/general/exec.js
new file mode 100644
--- /dev/null
+++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/general/exec.js
@@ -0,0 +1,5 @@
+expect(() => {
+  class Foo {
+    [Foo + 1] = 2;
+  };  
+}).toThrow(ReferenceError);
diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/general/input.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/general/input.js
new file mode 100644
--- /dev/null
+++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/general/input.js
@@ -0,0 +1,3 @@
+class Foo {
+  [Foo + 1] = 2;
+};
diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/general/options.json b/packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/general/options.json
new file mode 100644
--- /dev/null
+++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/general/options.json
@@ -0,0 +1,3 @@
+{
+  "plugins": ["proposal-class-properties"]
+}
diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/general/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/general/output.js
new file mode 100644
--- /dev/null
+++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/general/output.js
@@ -0,0 +1,8 @@
+let _ref;
+_ref = (babelHelpers.classNameTDZError("Foo"), Foo) + 1;
+class Foo {
+  constructor() {
+    babelHelpers.defineProperty(this, _ref, 2);
+  }
+}
+;
diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/edgest-case/exec.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/static-edgest-case/exec.js
similarity index 68%
rename from packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/edgest-case/exec.js
rename to packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/static-edgest-case/exec.js
--- a/packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/edgest-case/exec.js
+++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/static-edgest-case/exec.js
@@ -2,4 +2,4 @@ expect(() => {
   class A {
     static [{ x: A || 0 }.x];
   }
-}).toThrow();
+}).toThrow(ReferenceError);
diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/edgest-case/input.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/static-edgest-case/input.js
similarity index 100%
rename from packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/edgest-case/input.js
rename to packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/static-edgest-case/input.js
diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/edgest-case/options.json b/packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/static-edgest-case/options.json
similarity index 100%
rename from packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/edgest-case/options.json
rename to packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/static-edgest-case/options.json
diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/edgest-case/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/static-edgest-case/output.js
similarity index 100%
rename from packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/edgest-case/output.js
rename to packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/static-edgest-case/output.js
diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/general/exec.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/static-general/exec.js
similarity index 66%
rename from packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/general/exec.js
rename to packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/static-general/exec.js
--- a/packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/general/exec.js
+++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/static-general/exec.js
@@ -2,4 +2,4 @@ expect(() => {
   class C {
     static [C + 3] = 3;
   }
-}).toThrow();
+}).toThrow(ReferenceError);
diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/general/input.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/static-general/input.js
similarity index 100%
rename from packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/general/input.js
rename to packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/static-general/input.js
diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/general/options.json b/packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/static-general/options.json
similarity index 100%
rename from packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/general/options.json
rename to packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/static-general/options.json
diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/general/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/static-general/output.js
similarity index 100%
rename from packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/general/output.js
rename to packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/static-general/output.js
diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/loose/exec.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/static-loose/exec.js
similarity index 66%
rename from packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/loose/exec.js
rename to packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/static-loose/exec.js
--- a/packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/loose/exec.js
+++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/static-loose/exec.js
@@ -2,4 +2,4 @@ expect(() => {
   class C {
     static [C + 3] = 3;
   }
-}).toThrow();
+}).toThrow(ReferenceError);
diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/loose/input.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/static-loose/input.js
similarity index 100%
rename from packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/loose/input.js
rename to packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/static-loose/input.js
diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/loose/options.json b/packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/static-loose/options.json
similarity index 100%
rename from packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/loose/options.json
rename to packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/static-loose/options.json
diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/loose/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/static-loose/output.js
similarity index 100%
rename from packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/loose/output.js
rename to packages/babel-plugin-proposal-class-properties/test/fixtures/class-name-tdz/static-loose/output.js
diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set-loose/set-semantics-getter-defined-on-parent/exec.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set-loose/set-semantics-getter-defined-on-parent/exec.js
--- a/packages/babel-plugin-transform-classes/test/fixtures/get-set-loose/set-semantics-getter-defined-on-parent/exec.js
+++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set-loose/set-semantics-getter-defined-on-parent/exec.js
@@ -24,7 +24,7 @@ const obj = new Obj();
 // but close enough for loose.
 // expect(() => {
   expect(obj.set()).toBe(3);
-// }).toThrow();
+// }).toThrow(TypeError);
 
 expect(called).toBe(false);
 expect(Base.prototype.test).toBe(1);
diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set-loose/set-semantics-getter-defined-on-parent/input.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set-loose/set-semantics-getter-defined-on-parent/input.js
--- a/packages/babel-plugin-transform-classes/test/fixtures/get-set-loose/set-semantics-getter-defined-on-parent/input.js
+++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set-loose/set-semantics-getter-defined-on-parent/input.js
@@ -24,7 +24,7 @@ const obj = new Obj();
 // but close enough for loose.
 // expect(() => {
   expect(obj.set()).toBe(3);
-// }).toThrow();
+// }).toThrow(TypeError);
 
 expect(called).toBe(false);
 expect(Base.prototype.test).toBe(1);
diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set-loose/set-semantics-getter-defined-on-parent/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set-loose/set-semantics-getter-defined-on-parent/output.js
--- a/packages/babel-plugin-transform-classes/test/fixtures/get-set-loose/set-semantics-getter-defined-on-parent/output.js
+++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set-loose/set-semantics-getter-defined-on-parent/output.js
@@ -35,7 +35,7 @@ const obj = new Obj();
 // but close enough for loose.
 // expect(() => {
 expect(obj.set()).toBe(3);
-// }).toThrow();
+// }).toThrow(TypeError);
 
 expect(called).toBe(false);
 expect(Base.prototype.test).toBe(1);
diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set-loose/set-semantics-not-defined-on-parent-getter-on-obj/exec.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set-loose/set-semantics-not-defined-on-parent-getter-on-obj/exec.js
--- a/packages/babel-plugin-transform-classes/test/fixtures/get-set-loose/set-semantics-not-defined-on-parent-getter-on-obj/exec.js
+++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set-loose/set-semantics-not-defined-on-parent-getter-on-obj/exec.js
@@ -19,7 +19,7 @@ const obj = new Obj();
 // expect(obj.set()).toBe(3);
 expect(() => {
   obj.set();
-}).toThrow();
+}).toThrow(TypeError);
 
 expect(called).toBe(false);
 expect(Base.prototype.test).toBeUndefined();
diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set-loose/set-semantics-not-defined-on-parent-getter-on-obj/input.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set-loose/set-semantics-not-defined-on-parent-getter-on-obj/input.js
--- a/packages/babel-plugin-transform-classes/test/fixtures/get-set-loose/set-semantics-not-defined-on-parent-getter-on-obj/input.js
+++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set-loose/set-semantics-not-defined-on-parent-getter-on-obj/input.js
@@ -19,7 +19,7 @@ const obj = new Obj();
 // expect(obj.set()).toBe(3);
 expect(() => {
   obj.set();
-}).toThrow();
+}).toThrow(TypeError);
 
 expect(called).toBe(false);
 expect(Base.prototype.test).toBeUndefined();
diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set-loose/set-semantics-not-defined-on-parent-getter-on-obj/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set-loose/set-semantics-not-defined-on-parent-getter-on-obj/output.js
--- a/packages/babel-plugin-transform-classes/test/fixtures/get-set-loose/set-semantics-not-defined-on-parent-getter-on-obj/output.js
+++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set-loose/set-semantics-not-defined-on-parent-getter-on-obj/output.js
@@ -25,7 +25,7 @@ const obj = new Obj();
 // expect(obj.set()).toBe(3);
 expect(() => {
   obj.set();
-}).toThrow();
+}).toThrow(TypeError);
 expect(called).toBe(false);
 expect(Base.prototype.test).toBeUndefined();
 expect(Obj.prototype.test).toBeUndefined();
diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-getter-defined-on-parent/exec.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-getter-defined-on-parent/exec.js
--- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-getter-defined-on-parent/exec.js
+++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-getter-defined-on-parent/exec.js
@@ -21,7 +21,7 @@ Object.defineProperty(Obj.prototype, 'test', {
 const obj = new Obj();
 expect(() => {
   obj.set();
-}).toThrow();
+}).toThrow(TypeError);
 expect(called).toBe(false);
 expect(Base.prototype.test).toBe(1);
 expect(Obj.prototype.test).toBe(2);
diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-getter-defined-on-parent/input.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-getter-defined-on-parent/input.js
--- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-getter-defined-on-parent/input.js
+++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-getter-defined-on-parent/input.js
@@ -21,7 +21,7 @@ expect(() => {
   // this requires helpers to be in file (not external), so they
   // are in "strict" mode code.
   obj.set();
-}).toThrow();
+}).toThrow(TypeError);
 expect(Base.prototype.test).toBe(1);
 expect(Obj.prototype.test).toBe(2);
 expect(obj.test).toBe(2);
diff --git a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-getter-defined-on-parent/output.js b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-getter-defined-on-parent/output.js
--- a/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-getter-defined-on-parent/output.js
+++ b/packages/babel-plugin-transform-classes/test/fixtures/get-set/set-semantics-getter-defined-on-parent/output.js
@@ -38,7 +38,7 @@ expect(() => {
   // this requires helpers to be in file (not external), so they
   // are in "strict" mode code.
   obj.set();
-}).toThrow();
+}).toThrow(TypeError);
 expect(Base.prototype.test).toBe(1);
 expect(Obj.prototype.test).toBe(2);
 expect(obj.test).toBe(2);
diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-in-prop-exression/exec.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-in-prop-exression/exec.js
--- a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-in-prop-exression/exec.js
+++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-reference-in-prop-exression/exec.js
@@ -14,5 +14,5 @@ class B extends A {
 
 expect(() => {
   new B();
-}).toThrow();
+}).toThrow(ReferenceError);
 expect(called).toBe(false);
diff --git a/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-data-non-writable-defined-on-parent/exec.js b/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-data-non-writable-defined-on-parent/exec.js
--- a/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-data-non-writable-defined-on-parent/exec.js
+++ b/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-data-non-writable-defined-on-parent/exec.js
@@ -18,6 +18,6 @@ Object.setPrototypeOf(obj, Base);
 
 expect(() => {
   obj.set();
-}).toThrow();
+}).toThrow(TypeError);
 expect(Base.test).toBe(1);
 expect(obj.test).toBe(2);
diff --git a/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-getter-defined-on-parent/exec.js b/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-getter-defined-on-parent/exec.js
--- a/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-getter-defined-on-parent/exec.js
+++ b/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-getter-defined-on-parent/exec.js
@@ -18,7 +18,7 @@ Object.setPrototypeOf(obj, Base);
 
 expect(() => {
   obj.set();
-}).toThrow();
+}).toThrow(TypeError);
 expect(called).toBe(false);
 expect(Base.test).toBe(1);
 expect(obj.test).toBe(2);
diff --git a/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-getter-defined-on-parent/input.js b/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-getter-defined-on-parent/input.js
--- a/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-getter-defined-on-parent/input.js
+++ b/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-getter-defined-on-parent/input.js
@@ -18,6 +18,6 @@ expect(() => {
   // this requires helpers to be in file (not external), so they
   // are in "strict" mode code.
   obj.set();
-}).toThrow();
+}).toThrow(TypeError);
 expect(Base.test).toBe(1);
 expect(obj.test).toBe(2);
diff --git a/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-getter-defined-on-parent/output.js b/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-getter-defined-on-parent/output.js
--- a/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-getter-defined-on-parent/output.js
+++ b/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-getter-defined-on-parent/output.js
@@ -17,6 +17,6 @@ expect(() => {
   // this requires helpers to be in file (not external), so they
   // are in "strict" mode code.
   obj.set();
-}).toThrow();
+}).toThrow(TypeError);
 expect(Base.test).toBe(1);
 expect(obj.test).toBe(2);
diff --git a/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-not-defined-on-parent-data-non-writable-on-obj/exec.js b/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-not-defined-on-parent-data-non-writable-on-obj/exec.js
--- a/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-not-defined-on-parent-data-non-writable-on-obj/exec.js
+++ b/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-not-defined-on-parent-data-non-writable-on-obj/exec.js
@@ -17,7 +17,7 @@ Object.setPrototypeOf(obj, Base);
 
 expect(() => {
   obj.set();
-}).toThrow();
+}).toThrow(TypeError);
 expect(Base.test).toBeUndefined();
 expect(obj.test).toBe(2);
 
diff --git a/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-not-defined-on-parent-data-non-writable-on-obj/input.js b/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-not-defined-on-parent-data-non-writable-on-obj/input.js
--- a/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-not-defined-on-parent-data-non-writable-on-obj/input.js
+++ b/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-not-defined-on-parent-data-non-writable-on-obj/input.js
@@ -17,7 +17,7 @@ Object.setPrototypeOf(obj, Base);
 
 expect(() => {
   obj.set();
-}).toThrow();
+}).toThrow(TypeError);
 expect(Base.test).toBeUndefined();
 expect(obj.test).toBe(2);
 
diff --git a/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-not-defined-on-parent-data-non-writable-on-obj/output.js b/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-not-defined-on-parent-data-non-writable-on-obj/output.js
--- a/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-not-defined-on-parent-data-non-writable-on-obj/output.js
+++ b/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-not-defined-on-parent-data-non-writable-on-obj/output.js
@@ -16,7 +16,7 @@ Object.defineProperty(obj, 'test', {
 Object.setPrototypeOf(obj, Base);
 expect(() => {
   obj.set();
-}).toThrow();
+}).toThrow(TypeError);
 expect(Base.test).toBeUndefined();
 expect(obj.test).toBe(2);
 const desc = Object.getOwnPropertyDescriptor(obj, 'test');
diff --git a/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-not-defined-on-parent-getter-on-obj/exec.js b/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-not-defined-on-parent-getter-on-obj/exec.js
--- a/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-not-defined-on-parent-getter-on-obj/exec.js
+++ b/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-not-defined-on-parent-getter-on-obj/exec.js
@@ -16,7 +16,7 @@ Object.setPrototypeOf(obj, Base);
 
 expect(() => {
   obj.set();
-}).toThrow();
+}).toThrow(TypeError);
 expect(called).toBe(false);
 expect(Base.test).toBeUndefined();
 expect(obj.test).toBeUndefined();
diff --git a/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-not-defined-on-parent-getter-on-obj/input.js b/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-not-defined-on-parent-getter-on-obj/input.js
--- a/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-not-defined-on-parent-getter-on-obj/input.js
+++ b/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-not-defined-on-parent-getter-on-obj/input.js
@@ -15,6 +15,6 @@ expect(() => {
   // this requires helpers to be in file (not external), so they
   // are in "strict" mode code.
   obj.set();
-}).toThrow();
+}).toThrow(TypeError);
 expect(Base.test).toBeUndefined();
 expect(obj.test).toBeUndefined();
diff --git a/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-not-defined-on-parent-getter-on-obj/output.js b/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-not-defined-on-parent-getter-on-obj/output.js
--- a/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-not-defined-on-parent-getter-on-obj/output.js
+++ b/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-not-defined-on-parent-getter-on-obj/output.js
@@ -13,6 +13,6 @@ expect(() => {
   // this requires helpers to be in file (not external), so they
   // are in "strict" mode code.
   obj.set();
-}).toThrow();
+}).toThrow(TypeError);
 expect(Base.test).toBeUndefined();
 expect(obj.test).toBeUndefined();
diff --git a/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-not-defined-on-parent-setter-on-obj/exec.js b/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-not-defined-on-parent-setter-on-obj/exec.js
--- a/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-not-defined-on-parent-setter-on-obj/exec.js
+++ b/packages/babel-plugin-transform-object-super/test/fixtures/get-set/set-semantics-not-defined-on-parent-setter-on-obj/exec.js
@@ -16,7 +16,7 @@ Object.setPrototypeOf(obj, Base);
 
 expect(() => {
   obj.set();
-}).toThrow();
+}).toThrow(TypeError);
 expect(value).toBe(2);
 expect(Base.test).toBeUndefined();
 expect(obj.test).toBeUndefined();