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

Docs: Add best practices for modules to support Typescript #200

Open
NickBolles opened this issue Nov 20, 2019 · 3 comments
Open

Docs: Add best practices for modules to support Typescript #200

NickBolles opened this issue Nov 20, 2019 · 3 comments
Labels
documentation The issue or pull request related to the documentation good first issue Good for newcomers

Comments

@NickBolles
Copy link

Is your feature request related to a problem? Please describe.
I'm always frustrated when... a module doesn't have clear typescript instructions and/or doesn't have typings

Describe the solution you'd like
A guide to module authors on the best way to implement typings into a module.

Describe alternatives you've considered
Dealing with it and figuring it out myself for each package.

Additional context
I'm currently trying to add types to the auth-module, pull request

I'm basing this PR off of the axios-module, but it would be nice if we had a bit more of a step by step process for module authors to take.

  • It would be nice to link to a typescript specific guide from here (or maybe just include it on that page too) - https://nuxtjs.org/guide/modules

  • Steps would look something like

  1. Add a types/index.d.ts file
  2. Create your types (cover a few scenarios - component options, component instance etc. Some of which are already covered)
  3. Add "types": "types/index.d.ts", to your package.json
  4. Add the types directory to your NPM file, this varies, but something like
  "files": [
    "lib",
    "types"
  ],
  1. Include an example! - create an example boilerplate for module authors to copy and paste
    ...anything else?
@NickBolles NickBolles added the feature request Feature request label Nov 20, 2019
@kevinmarrec
Copy link
Contributor

@NickBolles For now there's already https://typescript.nuxtjs.org/cookbook/modules.html

@nuxt/typescript-build is itself a Nuxt module and is written in TypeScript while exporting the Options interface : https://github.com/nuxt/typescript/blob/master/packages/typescript-build/src/index.ts

About the steps, IMO an intermediate TypeScript developer already knows how to provide types for a package. Still a module author documentation is relevant.

@kevinmarrec kevinmarrec added documentation The issue or pull request related to the documentation and removed feature request Feature request labels Nov 22, 2019
@NickBolles
Copy link
Author

@kevinmarrec that cookbook link is for a Typescript - runtime module. What I'm suggesting is for modules such as auth-module, which is written in javascript. Often the authors of these modules don't want to or aren't used to typescript types.

Probably not a big use case. but 🤷‍♂

@kevinmarrec
Copy link
Contributor

Will add a documentation for modules authors.

@kevinmarrec kevinmarrec added the good first issue Good for newcomers label Dec 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation The issue or pull request related to the documentation good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants