Skip to content

Instantly share code, notes, and snippets.

@pbechliv
Created November 21, 2024 09:49
Show Gist options
  • Save pbechliv/88d0efde93367fc31c61a87e0a76bfd6 to your computer and use it in GitHub Desktop.
Save pbechliv/88d0efde93367fc31c61a87e0a76bfd6 to your computer and use it in GitHub Desktop.
Typescript Teaser
// Have fun!
// Try to improve the typings used in this code.
class Bar {
getData(): any {
return { id: 1, name: "Sample Data" }; // Simulating a response
}
processData(data: any, callback: Function): void {
// Process the data
const processed = { ...data, processed: true };
callback(processed);
}
}
const bar = new Bar();
const callback = (data: any): void => {
console.log(`Processed Data: ${JSON.stringify(data)}`);
};
const data = bar.getData();
bar.processData(data, callback);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment