Skip to content

Commit

Permalink
[helpers ts conversion] temporal dead zone (#16520)
Browse files Browse the repository at this point in the history
Co-authored-by: Nicolò Ribaudo <hello@nicr.dev>
  • Loading branch information
amjed-98 and nicolo-ribaudo committed May 22, 2024
1 parent 960dacf commit 9b3667a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* @minVersion 7.5.5 */

export default function _tdzError(name) {
export default function _tdzError(name: string): never {
throw new ReferenceError(name + " is not defined - temporal dead zone");
}
8 changes: 0 additions & 8 deletions packages/babel-helpers/src/helpers/temporalRef.js

This file was deleted.

8 changes: 8 additions & 0 deletions packages/babel-helpers/src/helpers/temporalRef.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* @minVersion 7.0.0-beta.0 */

import undef from "./temporalUndefined.ts";
import err from "./tdz.ts";

export default function _temporalRef<T>(val: T, name: string) {
return val === undef ? err(name) : val;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

// This function isn't mean to be called, but to be used as a reference.
// We can't use a normal object because it isn't hoisted.
export default function _temporalUndefined() {}
export default function _temporalUndefined(this: never): void {}

0 comments on commit 9b3667a

Please sign in to comment.