symToStr
Get the name of a symbol as typed string.
import { symToStr } from "tsafe/symToStr";
declare const foo: any;
//str is of type "foo" and str === "foo"
const str = symToStr({ foo });Without symToStr
symToStrexport const myFunctionX = () => {};
export const name = "myFunctionX";If you happen to rename `myFunctionX` into something else it is easy to forget to rename the exported name as well.
With symToStr
symToStrimport { symToStr } from "tsafe/symToStr";
export const myFunctionX = () => {};
export const name = symToStr({ myFunctionX });
// ^name is of type "myFunctionX"Last updated
Was this helpful?