question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use with TypeScript

See original GitHub issue

Is there currently a way to use this with TypeScript? I know that there isn’t a @types package, but I’m wondering if anyone has a declaration file that they’re successfully using. I’m currently getting the error [ts] Property 'addWithJSX' does not exist on type 'Story'.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

14reactions
timkrinscommented, Dec 2, 2018

@types has a package now.

npm install @types/storybook-addon-jsx --save-dev

4reactions
rosskevincommented, Jul 2, 2018

The way to do this locally is by setting up module augmentation: https://www.typescriptlang.org/docs/handbook/declaration-merging.html

Here is the content needed in something like storybook.d.ts:

import { RenderFunction } from '@storybook/react'

declare module '@storybook/react' {
  export interface Story {
    addWithJSX(storyName: string, callback: RenderFunction): this
  }
}

Then you can use it like normal without casting to any

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - TypeScript for JavaScript Programmers
TypeScript knows the JavaScript language and will generate types for you in many cases. For example in creating a variable and assigning it...
Read more >
What is TypeScript and why should you use it? - Contentful
TypeScript extends JavaScript and improves the developer experience. It enables developers to add type safety to their projects. Moreover, ...
Read more >
How to Use TypeScript – Beginner-Friendly TS Tutorial
TypeScript is a superset of JavaScript. Superset means that it adds features on top of what JavaScript offers. TypeScript takes all the ...
Read more >
Why You Should Use Typescript for Your Next Project
TypeScript is a superset of typed JavaScript (optional) that can help build and manage large-scale JavaScript projects. It can be considered ...
Read more >
Node.js with TypeScript
tsc is the TypeScript compiler which will take our TypeScript code and compile it to JavaScript. This command will result in a new...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found