Skip to content

Commit

Permalink
Merge pull request #20268 from emberjs/type-safe-intern
Browse files Browse the repository at this point in the history
[CLEANUP] Make intern utility type safe
  • Loading branch information
chriskrycho authored Nov 16, 2022
2 parents 792ca6c + 3076f8c commit 8497a5b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/@ember/-internals/utils/lib/intern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
@private
@return {String} interned version of the provided string
*/
export default function intern(str: string): string {
let obj: Record<string, number> = {};
export default function intern<S extends string>(str: S): S {
let obj: Record<S, number> = Object.create(null);
obj[str] = 1;
for (let key in obj) {
if (key === str) {
Expand Down

0 comments on commit 8497a5b

Please sign in to comment.