Symbol Magic
yarn add @sudoo/symbol
# Or
npm install @sudoo/symbol --save
Symbol should be used as return values (and more!) to express more information from functions.
import { SEmptyReturn, EmptyReturnSymbol } from "@sudoo/symbol";
export const yourFunction = (arg: any): SEmptyReturn | AwesomeObject | null => {
if (arg === null) {
return null;
}
if (arg.hasNoData) {
return EmptyReturnSymbol;
}
return arg.awesomeObject;
};
Do not use @sudoo/symbol
as required dependencies unless the project is not a package. Due to duplicated copy of package would cause type reference issue.