Skip to content

Splited declarations + added params jsdoc for intellisense. #5

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

Closed
wants to merge 2 commits into from
Closed

Conversation

MichalLytek
Copy link
Contributor

Fixed #4 intellisense issue.

* Compile a Pug template and render it with locals to html string.
* @param {(Options & LocalsObject)} options Pug Options and rendering locals
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please move the @param into the one comment above and remove the duplicate type declaration (it's not needed)?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@blakeembrey the type is not needed, but at least for typedoc you need to have different param descriptions for different overloads afaik (you can click through the overloads)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There has to be comments section for each overload declarations to have intelisense on overloads:
#4 (comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@felixfbecker Ok, cool - so I guess we have to duplicate the params?

I'd still love to figure out how to not duplicate things. I don't think it's that important to have docs on every single overload as long the main one you see does.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, just took a look and yeah, that sucks. I'm going to submit an issue to TypeScript if it's not already tracked. Surprised I hadn't noticed this before really.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typings has to be usefull, not look nice on github repository 😜 It's better to duplicate than have no info about params or function you are using.

Copy link
Member

@blakeembrey blakeembrey Sep 13, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not about looking nice, and it is already useful. It's more about maintaining something. Although this isn't a big use-case, there's dozens of other people with huge definitions who are trying to maintain them. If it takes a cumulative 5 minutes extra each time to update all definitions because we repeated ourselves, that's 100s of hours over a long enough duration and, of course, the probability that each change could introduce a bug because a new contributor doesn't realise duplication is required or we forget ourselves and become inconsistent.

I found and commented on microsoft/TypeScript#407.

Copy link
Member

@blakeembrey blakeembrey Sep 13, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In any case, it's the same reason you wouldn't duplicate the type arguments into each param documentation. It's n*2 locations you need to fix every time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you gonna merge this pull request? We can wait a few months until TypeScript team solve this problem.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's 1000 other definitions where this isn't used. I don't think it's a valuable addition, as anyone using the tooling would understand how this works today, and the future improvements from TypeScript will also be a welcome addition.

However, the issue here is also that the types need to be removed from JSDoc.

@@ -84,7 +110,7 @@ declare namespace pug {
/**
* An object that can have multiple properties of any type.
*/
export interface AnyObject {
export interface LocalsObject {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like an unnecessary breaking change to me

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AnyObject isn't meaningful - you don't know what is the function of object you are passing to as a param of render() or other function. LocalsObject means it's the object holding locals variables to render the view from template.

@MichalLytek
Copy link
Contributor Author

Closing as I made a PR to npm @types repo:
DefinitelyTyped/DefinitelyTyped/pull/12278

@MichalLytek MichalLytek deleted the pr-5 branch November 13, 2016 14:40
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

Successfully merging this pull request may close these issues.

3 participants