webpack / webpack.js.org

Repository for webpack documentation and more!
https://webpack.js.org
Creative Commons Attribution 4.0 International
2.21k stars 3.31k forks source link

Writer's guide - Types notation #3333

Open montogeek opened 4 years ago

montogeek commented 4 years ago

Some time ago a writes guide was created that specifies how to add types notations to our documentation, but later some users found it confusing, an alternative is to use TypeScript notation which has better standardization process and it is more known by the community.

Another alternative is to use TypeScript documentation from webpack source code directly (it would be a fun AST ride, maybe).

montogeek commented 4 years ago

Related: https://github.com/webpack/webpack.js.org/pull/3323

EugeneHlushko commented 4 years ago

If this doesnt get traction, i suggest adding a small outline to the types in the docs somewhere or as i suggested earlier, a tooltip when hover types

rishabh3112 commented 4 years ago

@EugeneHlushko Typescript notations are less confusing and should be used in my opinion.

Another alternative is to use TypeScript documentation from webpack source code directly (it would be a fun AST ride, maybe).

Major part of the code in the webpack source code in written in javascript with commented types, thus extracting the types from there wouldn't be a nice idea.

chenxsan commented 4 years ago

I agree with @rishabh3112 here. We can see the two version here https://github.com/webpack/webpack.js.org/pull/3706#issuecomment-619119074, the TypeScript one is much better. Also, when user reading docs, they won't read the writers guide first to figure out the difference. So it would be better to choose the popular notations.

We might use details/summary here:

Click to see Options types
type Entry =
  | string
  | [string]
  | {
      key:
        | string
        | [string]
        | {
            import: string | [string]
            dependOn: string | [string]
            filename: string
          }
    }
  | (() =>
      | string
      | [string]
      | {
          key:
            | string
            | [string]
            | {
                import: string | [string]
                dependOn: string | [string]
                filename: string
              }
        })