To set the return type of a function as a in TypeScript, you simply use the Promise<T> syntax, where T is the type of the value that the promise resolves to.
We need a helper fetchUser(id) that calls an endpoint and returns the user object. How would you write its signature so callers know it returns a Promise<User>?
If you write an async function without an explicit return type, what type does TypeScript assign to it?
Write a tiny function that waits two seconds then resolves with a number; show the full TypeScript signature.
A legacy function currently returns a plain User. We now need to fetch the user from a DB asynchronously. How would you refactor it and make sure its exported type is Promise<User>?
During a code review you see a function returning a Promise but its return type is typed as any. What issues can this cause and how would you correct it?
Our service layer mixes callbacks and promises. Describe how you would enforce that all public functions declare Promise<T> return types.
Our API gateway composes data from three microservices, each returning Promise<T>. How would you design the function signatures to propagate errors while keeping type safety?
We’re adding a generic fetch<T>(url): Promise<T> wrapper. Discuss the trade‑offs of using a generic Promise return versus concrete types throughout a large codebase.
Some functions now return Promise<void> but callers treat the resolved value as data. How would you detect and prevent such mismatches at compile time?
We’re migrating a huge JavaScript repo to TypeScript and want every async function to explicitly declare a Promise return type. Outline a strategy—including lint rules, codemods, and cross‑team coordination—to enforce this without breaking builds.
Multiple teams share a library where some functions return native promises and others return custom thenables. How would you standardize the return type across the library and what impact would that have on downstream services?
When designing a shared SDK used by several products, how would you version and evolve the Promise‑based APIs to maintain backward compatibility while improving type safety?