Created
November 21, 2024 09:49
-
-
Save pbechliv/88d0efde93367fc31c61a87e0a76bfd6 to your computer and use it in GitHub Desktop.
Typescript Teaser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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