Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declare a module must satisfy a given type #60667

Closed
6 tasks done
nfroidure opened this issue Dec 3, 2024 · 2 comments
Closed
6 tasks done

Declare a module must satisfy a given type #60667

nfroidure opened this issue Dec 3, 2024 · 2 comments

Comments

@nfroidure
Copy link

nfroidure commented Dec 3, 2024

πŸ” Search Terms

I'd like for in a framework to be able to guide users while they create some standard components.

βœ… Viability Checklist

⭐ Suggestion

It could be something like:

declare module 'src/commands/*.ts' satifies/extends {
  name: string;
  definition: CommandDefinition;
  default: Command;
}

When editing the module, users will have typescript errors until the module is validating the types declares.

πŸ“ƒ Motivating Example

Improving the developer experience is a major issue for framework authors, I think it would significantly improve framework usages. I need it for helping users declaring handlers that will always have the same shape but I think frameworks like NextJS/React etc... would benefit from it too.

πŸ’» Use Cases

  1. What do you want to use this for? Developer experience
  2. What shortcomings exist with current approaches?
    Currently the only way I know to do this is to use satisfies for each export of each module which relies on developers attention and is error prone:
export const x ... satifies MyModuleType[x];
export const y ... satifies MyModuleType[y];
  1. What workarounds are you using in the meantime?
    There is no alternative atm afaik.
@MartinJohns
Copy link
Contributor

Duplicate of #38511.

@nfroidure
Copy link
Author

Thanks @MartinJohns closing then and commenting there ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants