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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type of function makeDecorator from lib/addons #5534

Merged
merged 2 commits into from
Feb 11, 2019
Merged

Fix type of function makeDecorator from lib/addons #5534

merged 2 commits into from
Feb 11, 2019

Conversation

gaetanmaisse
Copy link
Member

@gaetanmaisse gaetanmaisse commented Feb 10, 2019

What I did

Fix type of function makeDecorator from lib/addons.

MakeDecoratorResult is type of object returned by makeDecorator and not makeDecorator itself.
This fix also helps a lot in addons TS migration because correct types are now inferred 馃槂.

Also remove some any typings linked to makeDecorator in addon/cssresources

@@ -67,7 +67,7 @@ export const withCssResources = makeDecorator({
skipIfNoParametersOrOptions: true,
allowDeprecatedUsage: false,

wrapper: (getStory: any, context: any, { options, parameters }: any) => {
wrapper: (getStory, context, { options, parameters }) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems unrelated to your PR, but good catch anyways 馃憤

Copy link
Member Author

Choose a reason for hiding this comment

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

Just found it when I was looking for makeDecorator usage, so I cleaned it ;)

name,
parameterName,
wrapper,
skipIfNoParametersOrOptions = false,
allowDeprecatedUsage = false,
}: MakeDecoratorOptions) => {
}: MakeDecoratorOptions): MakeDecoratorResult => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch 馃憤

@@ -31,13 +31,13 @@ interface MakeDecoratorOptions {
wrapper: StoryWrapper;
}

export const makeDecorator: MakeDecoratorResult = ({
export const makeDecorator = ({
name,
parameterName,
wrapper,
skipIfNoParametersOrOptions = false,
allowDeprecatedUsage = false,
Copy link
Contributor

Choose a reason for hiding this comment

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

Both skipIfNoParametersOrOptions and allowDeprecatedUsage have default values set here, so you shouldn't have to set those in the tests explicitly. But I leave it up to you.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I understand why I had to explicitly set them in test, just because they are not declared as optional in MakeDecoratorOptions. I will make them optional and revert my changes on tests.

`MakeDecoratorResult` is type of object returned by `makeDecorator` and not `makeDecorator` itself.
This fix also helps a lot in addons TS migration because correct types are now inferred.

Make `allowDeprecatedUsage` and `skipIfNoParametersOrOptions` as they have default value in `makeDecorator`
@codecov
Copy link

codecov bot commented Feb 10, 2019

Codecov Report

Merging #5534 into next will not change coverage.
The diff coverage is 50%.

Impacted file tree graph

@@          Coverage Diff          @@
##            next   #5534   +/-   ##
=====================================
  Coverage   33.1%   33.1%           
=====================================
  Files        638     638           
  Lines       9264    9264           
  Branches    1340    1318   -22     
=====================================
  Hits        3067    3067           
  Misses      5571    5571           
  Partials     626     626
Impacted Files Coverage 螖
addons/cssresources/src/index.ts 0% <0%> (酶) 猬嗭笍
lib/addons/src/make-decorator.ts 100% <100%> (酶) 猬嗭笍

Continue to review full report at Codecov.

Legend - Click here to learn more
螖 = absolute <relative> (impact), 酶 = not affected, ? = missing data
Powered by Codecov. Last update d9cd83c...61ed20e. Read the comment docs.

@ndelangen ndelangen added the bug label Feb 11, 2019
@ndelangen ndelangen self-assigned this Feb 11, 2019
@ndelangen ndelangen merged commit ef090d4 into storybookjs:next Feb 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants