Skip to content

Instantly share code, notes, and snippets.

@fabd
Last active January 15, 2020 09:54
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 fabd/f17c422b5f48d3fdf3493c3f22c66572 to your computer and use it in GitHub Desktop.
Save fabd/f17c422b5f48d3fdf3493c3f22c66572 to your computer and use it in GitHub Desktop.
console.log() helper function in TypeScript
// first attempt : but why?
const log = (...args: [any?, ...any[]]) => { console.log.apply(console, args) }
// better : use console.log() signature
const log = (msg?: any, ...params: any[]) => { console.log.apply(console, [msg, params]) }
// test
log('document is %o', document)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment