Preview:```ts
type Return = {
foo: string
}
export function x(): Return {
return {foo: "bar"}
}```
You can choose specific lines to embed by selecting them before copying the link.
15 messages · Page 1 of 1 (latest)
Preview:```ts
type Return = {
foo: string
}
export function x(): Return {
return {foo: "bar"}
}```
!ts
type Return = {
foo: string;
};
export function x(): Return {
return { foo: "bar" };
}
In these situations, I always export my type too. But I've always wondered what are the ramifications to making the Return type internal only?
Pros and cons, etc.?
Even if it's not exported explicitly, it still is implicitly because you can access it by ReturnType<typeof x>
It's probably better to export the type though if you're building some kind of library
also because of duck typing, right?
Guessing the IDE would still guide you to the correct shape