Skip to content

Commit afcb5a8

Browse files
JLHwungliuxingbaoyu
andauthoredNov 29, 2023
Apply toPropertyKey on decorator context name (#16139)
* refactor: extract toPrimitive and toProeprtyKey to single helpers * update test fixtures * apply toPropertyKey for decorator context name * fix: allow BigIntLiteral in ClassMethod.key * Add 2021-12 test cases * copy paste to other versions * Suppress TS error * Update packages/babel-helpers/src/helpers/toPrimitive.ts Co-authored-by: liuxingbaoyu <[email protected]> * update generated helpers * update test fixtures --------- Co-authored-by: liuxingbaoyu <[email protected]>
1 parent 00bdf18 commit afcb5a8

File tree

180 files changed

+3769
-103
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

180 files changed

+3769
-103
lines changed
 

‎packages/babel-helpers/src/helpers-generated.ts

+12-4
Large diffs are not rendered by default.

‎packages/babel-helpers/src/helpers.ts

-25
Original file line numberDiff line numberDiff line change
@@ -865,31 +865,6 @@ helpers.skipFirstGeneratorNext = helper("7.0.0-beta.0")`
865865
}
866866
`;
867867

868-
helpers.toPrimitive = helper("7.1.5")`
869-
export default function _toPrimitive(
870-
input,
871-
hint /*: "default" | "string" | "number" | void */
872-
) {
873-
if (typeof input !== "object" || input === null) return input;
874-
var prim = input[Symbol.toPrimitive];
875-
if (prim !== undefined) {
876-
var res = prim.call(input, hint || "default");
877-
if (typeof res !== "object") return res;
878-
throw new TypeError("@@toPrimitive must return a primitive value.");
879-
}
880-
return (hint === "string" ? String : Number)(input);
881-
}
882-
`;
883-
884-
helpers.toPropertyKey = helper("7.1.5")`
885-
import toPrimitive from "toPrimitive";
886-
887-
export default function _toPropertyKey(arg) {
888-
var key = toPrimitive(arg, "string");
889-
return typeof key === "symbol" ? key : String(key);
890-
}
891-
`;
892-
893868
/**
894869
* Add a helper that will throw a useful error if the transform fails to detect the class
895870
* property assignment, so users know something failed.

0 commit comments

Comments
 (0)
Please sign in to comment.