-
Notifications
You must be signed in to change notification settings - Fork 6.8k
build: more type information for docs #6947
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code-wise LGTM, but I'm wondering about how are we going to enforce that we add all the necessary typings?
@@ -94,7 +94,7 @@ export class MdFormField implements AfterViewInit, AfterContentInit, AfterConten | |||
|
|||
/** @deprecated Use `color` instead. */ | |||
@Input() | |||
get dividerColor() { return this.color; } | |||
get dividerColor(): 'primary' | 'accent' | 'warn' { return this.color; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have the ThemePalette
type for this already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I wanted to use that as well, but it also includes undefined
as a possible value, which is not valid here.
tools/dgeni/common/decorators.ts
Outdated
import {PropertyMemberDoc} from 'dgeni-packages/typescript/api-doc-types/PropertyMemberDoc'; | ||
import {MemberDoc} from 'dgeni-packages/typescript/api-doc-types/MemberDoc'; | ||
|
||
const SELECTOR_BLACKLIST = new Set([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some inconsistent spacing here.
import {ClassExportDoc} from 'dgeni-packages/typescript/api-doc-types/ClassExportDoc'; | ||
import {PropertyMemberDoc} from 'dgeni-packages/typescript/api-doc-types/PropertyMemberDoc'; | ||
import { | ||
NormalizedMethodMemberDoc, normalizeMethodParameters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The normalizeMethodParameters
should be on a separate line.
486bc66
to
2d132f9
Compare
@crisbeto Addressed your feedback and rebased on top of the sort members commit. Regarding the enforcement: Good point, I have a TSLint rule in mind. We can base those rules on top of the existing rules like |
2d132f9
to
a97f7f5
Compare
9b70ae2
to
745357e
Compare
745357e
to
861c81d
Compare
@jelbourn Rebased this one. Please have another look. |
a64eb21
to
ae76648
Compare
tools/dgeni/common/decorators.ts
Outdated
|
||
export function isProperty(doc: MemberDoc) { | ||
if (doc instanceof PropertyMemberDoc || | ||
// The latest Dgeni version no longer treats getters or setters as properties. In theory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"In theory those" -> "From a user perspective, these"
import {CategorizedPropertyMemberDoc} from '../processors/categorizer'; | ||
|
||
/** | ||
* Accessors are not parsed properly within the latest dgeni-packages package. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an issue to link for this? What about the accessors isn't parsed correctly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only reported this on Slack if I recall. Created an issue for it now: angular/dgeni-packages#246
member.kind === SyntaxKind.SetAccessor) | ||
.filter((member: any) => member.name && (member.name as any).text === propertyDoc.name) | ||
.forEach((member: GetAccessorDeclaration|SetAccessorDeclaration) => { | ||
if (member.type) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add comment that explains how you extract the type
classDeclaration.members | ||
.filter((member: any) => member.kind === SyntaxKind.GetAccessor || | ||
member.kind === SyntaxKind.SetAccessor) | ||
.filter((member: any) => member.name && (member.name as any).text === propertyDoc.name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If member
is any
, why do you need to use as any
on member.name
?
// If the current property document doesn't have any description set and the current | ||
// TypeScript has a symbol from the TypeChecker, we can try to find a documentation | ||
// comment on that symbol. | ||
if (!propertyDoc.description && (member as any).symbol) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you need the as any
here, is GetAccessorDeclaration|SetAccessorDeclaration
the right type for member?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this is the correct type. It just looks like TypeScript isn't exposing the symbol
property in their typings. The same is happening on Dgeni as well (see here)
* Upgrades dgeni and dgeni-packages to the latest available version (including TypeScript support; and newer TypeScript version for AST) * More warnings if type information is missing on public TypeScript symbol * Adds missing explicit type declarations to all components * Types are now being displayed for accessors and properties (this was broken before somehow) * Rewrote the Dgeni setup in TypeScript for type safety and better integration into the gulp workflow.
66114b9
to
52e4712
Compare
@jelbourn Addressed your feedback. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Note: Most of the things inside of the existing Dgeni setup is the same as before and I didn't look into other improvements there (e.g logic simplification) because the PR is big enough already.