Skip to content

Conversation

@Gerrit0
Copy link
Collaborator

@Gerrit0 Gerrit0 commented Aug 17, 2018

Also turns on strictFunctionTypes, which required an update to the ComponentClass interface.

This change makes typedoc less likely to break if types change in the future since it removes type assertions which aren't currently needed.

Running grunt build_and_test will not lint files with the new no-unnecessary-type-assertion rule as it appears the plugin does not support that option. Once #836 is resolved, this should no longer be an issue. It is also important to be aware that some editor plugins (notably tslint for vscode) do not show rules which require type information.

I have added a npm run lint task which will run tslint directly and show lint errors from tslint rules which require type information and configured Travis to run this task when building.

Also turns on strictFunctionTypes, which required an update to the `ComponentClass` interface.
Copy link
Collaborator

@aciccarello aciccarello left a comment

Choose a reason for hiding this comment

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

Looks good, just curious about one type definition


export interface ComponentClass<T extends Component> extends Function {
new(owner: ComponentHost): T;
export interface ComponentClass<T extends Component, O extends ComponentHost = ComponentHost> extends Function {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why can't this type stay CompilerHost?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Turning on strictFunctionTypes requires a stronger type for the addComponent method. In particular, the application component in application.ts adds several components which expect their owner to be of type Application. This change makes it possible to specify the owner type in component.ts and thus resolves the type incompatibility.

@aciccarello aciccarello merged commit 8384a95 into TypeStrong:master Aug 17, 2018
mrkurt pushed a commit to mrkurt/typedoc that referenced this pull request Sep 19, 2018
* Enable no-unnecessary-type-assertion

Also turns on strictFunctionTypes, which required an update to the `ComponentClass` interface.
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.

2 participants