Skip to content

add package @storybook/addon-knobs - #17399

Merged
sandersn merged 1 commit into
DefinitelyTyped:masterfrom
joscha:joscha/add-@storybook/addon-knobs
Jun 22, 2017
Merged

sandersn merged 1 commit into
DefinitelyTyped:masterfrom
joscha:joscha/add-@storybook/addon-knobs

Conversation

@joscha

@joscha joscha commented Jun 22, 2017 •

Copy link
Copy Markdown
Contributor
  • Use a meaningful title for the pull request. Include the name of the package modified.

  • Test the change in your own code. (Compile and run.)

  • Follow the advice from the readme.

  • Avoid common mistakes.

  • Run npm run lint package-name (or tsc if no tslint.json is present).

  • The package does not provide its own types, and you can not add them. It has been decided to move away from providing the types within the package as there is no owner using TS and the types were outdated most of the time, see Typescript Support storybookjs/storybook#1166 and Add typings for links add-on storybookjs/storybook#1154

  • If this is for an NPM package, match the name. If not, do not conflict with the name of an NPM package.

  • Create it with dts-gen --dt, not by basing it on an existing project. (Isn't possible at the time, opened Allow scoped packages microsoft/dts-gen#63 which is merged, but has not been released, yet /cc @RyanCavanaugh)

  • tslint.json should be present, and tsconfig.json should have noImplicitAny, noImplicitThis, and strictNullChecks set to true.

/cc @ndelangen
references #16970, storybookjs/storybook#1339

@dt-bot

dt-bot commented Jun 22, 2017

Copy link
Copy Markdown
Member

types/storybook__addon-knobs/index.d.ts

Checklist


// TODO: Once TS2.3 is released,
// https://github.com/Microsoft/TypeScript/issues/14819 should be fixed.
// Then, upgrade this package's typescript version to 2.3 and

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

2.3 is released so you can do this TODO.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Might be nice to do it for @storybook/react too

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@sandersn Is there an example of a scoped package that has done this already? Do you think we can do it as a follow-up and do both packages at once?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I just tried removing the wrappers, but now get:

/Users/joscha/Development/DefinitelyTyped/types/storybook__addon-knobs/index.d.ts
ERROR: 10:32  expect  TypeScript compile error: Cannot find module '@storybook/react'.

/Users/joscha/Development/DefinitelyTyped/types/storybook__addon-knobs/storybook__addon-knobs-tests.tsx
ERROR: 2:27   expect  TypeScript compile error: Cannot find module '@storybook/react'.
ERROR: 14:8   expect  TypeScript compile error: Cannot find module '@storybook/addon-knobs'.

I have used /// <reference types="storybook__react" /> at the top of the file, but for some reason it still is not picked up correctly. Any idea what I might be doing wrong?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Tried a rm -rf node_modules and clean install to make sure its not an outdated dtslint version.

Full command:

$ npm run lint storybook__addon-knobs

> [email protected] lint /Users/joscha/Development/DefinitelyTyped
> dtslint types "storybook__addon-knobs"

Installing to /Users/joscha/Development/DefinitelyTyped/node_modules/dtslint/typescript-installs/2.3...
npm notice created a lockfile as package-lock.json. You should commit this file.

Installed!
/Users/joscha/Development/DefinitelyTyped/types/storybook__addon-knobs/index.d.ts
ERROR: 8:32  expect  TypeScript compile error: Cannot find module '@storybook/react'.

/Users/joscha/Development/DefinitelyTyped/types/storybook__addon-knobs/storybook__addon-knobs-tests.tsx
ERROR: 4:27  expect  TypeScript compile error: Cannot find module '@storybook/react'.
ERROR: 16:8  expect  TypeScript compile error: Cannot find module '@storybook/addon-knobs'.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] lint: `dtslint types "storybook__addon-knobs"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/joscha/.npm/_logs/2017-06-22T21_00_18_487Z-debug.log

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think @Andy-MS is the better one to ask since I think he made the name-mangling-lookup change.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

See #17434.

@sandersn

Copy link
Copy Markdown
Contributor

Let's merge this as-is while we figure out the name-mangled lookup on our end.

@joscha

joscha commented Jun 22, 2017

Copy link
Copy Markdown
Contributor Author

Thank you @sandersn ❤️ !


function object<T>(name: string, value: T): T;

function select<T>(name: string, options: { [s: string]: T }, value: string): T;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There should be one more argument "groupName"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

PRs accepted.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Opened #24797

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.

4 participants