Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save willmendesneto/407c4076df3d98a04be95bf455a83172 to your computer and use it in GitHub Desktop.
Save willmendesneto/407c4076df3d98a04be95bf455a83172 to your computer and use it in GitHub Desktop.
// Link for example in Typescript playground
// https://www.typescriptlang.org/play?#code/GYVwdgxgLglg9mABAcwKZQMIODZAKAWAChFTEJtcB+ALkQG9iznEBDAB3dVYCdXJUtRAGcoPGGGQBuJi1L8YAW1awEQ0eMkyScxABs4rACYTkAFVQAPKOrGntu8nHA26YEIoBGqHg91QAC1RFQTp6AG0AazoNUwBdOn4ATwBfRAAfRHc9PT9SFOIASjoANzgYIwZZUgowUQYOLl5+CFREAF5EAHI9CVQugBo2MCUVeCROrvYeOGQeVGFhQcRA4LbO7L0hg2NTC2sO7oAZQxNJADpL5YoXQ4BGNM7anGQMzPoU7WqnOrg9VHOBnwjW4fAEQwUylUYCGqxC21OeysUCGNzAUEK2gKRGIoEg0JQ6CwYBeACZCDoapRkEJGJSWCDmgJbJppN9mJCxmoYnYtOyyDszuZkSz7PyqS4hO4vD48iw4aEGFEeayEsNUhksiAcnLscVEGUKlV6bV6oywa1Ds9qOdzS02lQqN1emB+nLTVBhqMCU9qVRbSMoeNEI7utNZvNFl13Qh6gqrX7zvHQ5sY3VPYKkQdfSSbZnJPtPaGuiddhcrmn6mjPTmXv7qyGnXcvibY38AUC8HbwV6gwhYUF4fpEQXkajnOjMcRsbjwNBg2hMNSAMwU5jWmlhcVsTig+2ivn0jmBrlgA9so8CkfC6znuXrieuLUy3zbhW05UiXnINXJNKZVNvj1UpykqOkH3TBpdyZS1JhdfoIRPH0wxmOYFiWAc1kOTYETLG8a2Oa9LnOa5H3uR4fheRsGE+YhvlNdtAVmLtoItVBEO9cZMKHfN8PHFwpyIFIgA
function getConfig(
config?: {
appearance?: string;
animation?: string;
loadingText?: string;
count?: number;
theme?: {[k: string]: any} | null;
}
): void {
const {appearance = 'line', animation = 'progress', theme = null, loadingText = 'Loading...', count = 1} = config || {};
console.log(appearance, animation, theme, loadingText, count);
}
function getConfig2(
config?: {
appearance?: string;
animation?: string;
loadingText?: string;
count?: number;
theme?: {[k: string]: any} | null;
}
): void {
const appearance = config?.appearance ?? 'line';
const animation = config?.animation ?? 'progress';
const theme = config?.theme ?? null;
const loadingText = config?.loadingText ?? 'Loading...';
const count = config?.count ?? 1;
console.log(appearance, animation, theme, loadingText, count);
}
function getConfig3(
config?: {
appearance?: string;
animation?: string;
loadingText?: string;
count?: number;
theme?: {[k: string]: any} | null;
}
): void {
const {appearance = 'line', animation = 'progress', theme = null, loadingText = 'Loading...', count = 1} = config ?? {};
console.log(appearance, animation, theme, loadingText, count);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment