Open haysclark opened 4 years ago
Looks like a 12.2.1 version of @types/react-syntax-highlighter would be the ideal. Sadly, there is no 12.2.1 types yet, and the last 12.2
PR for react-syntax-highlighter went stale recently and was Closed. :(
A workaround; put in a non-module .d.ts
file and reference it somehow.
declare module 'react-syntax-highlighter/dist/cjs/create-element' {
import React from 'react'
export type SyntaxHighlightNode =
| (TextNode & Partial<Record<keyof TagNode<any>, never>>)
| (TagNode<any> & Partial<Record<keyof TextNode, never>>)
export interface TextNode {
type: 'text'
value: string
}
export interface TagNode<T extends React.ElementType> {
tagName: T
properties: React.ComponentProps<T>
}
export interface CreateElementProps {
node: SyntaxHighlightNode
stylesheet: import('react-syntax-highlighter').SyntaxHighlighterProps['customStyle']
style?: React.CSSProperties
useInlineStyles?: boolean
key: string | number
}
export default function createElement(props: CreateElementProps): string | JSX.Element
}
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!
@Jessidhia thanks!
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!
At the risk of sounding like I have no idea what I'm doing, @Jessidhia could you elaborate on a good way to "reference it somehow"? Does it just need to be in the source tree with other storybook files or does that require some webpack configuration manipulation?
A workaround; put in a non-module
.d.ts
file and reference it somehow.
At the risk of sounding like I have no idea what I'm doing, @Jessidhia could you elaborate on a good way to "reference it somehow"? Does it just need to be in the source tree with other storybook files or does that require some webpack configuration manipulation?
A workaround; put in a non-module
.d.ts
file and reference it somehow.
Hi, I just added a file in my project with the path src/types/defs/react-syntax-highlighter.d.ts
and included the contents from @Jessidhia's answer and it worked without any issues. No need to include it or reference it anywhere else, but not sure if your setup will need additional effort for any reason
@types/react-syntax-highlighter
is up to version 13.5.0 now: https://www.npmjs.com/package/@types/react-syntax-highlighter
Does this include the necessary fixes? Can Storybook itself be upgraded to use the latest version? The workaround from above is fine for now, but it would be nice to fix this properly.
I've also encountered this issue, @kaiyoma I can confirm the latest version of @types/react-syntax-highlighter
does not have necessary type definitions for create-element
([definition].(https://github.com/DefinitelyTyped/DefinitelyTyped/blob/a84a573295f22d04985033735efe6cb31a70f6bb/types/react-syntax-highlighter/index.d.ts))
Issue still going on. atomDark does not have proper types
Guys any update on this ?? I'm still having the issue.
Type error: Could not find a declaration file for module 'react-syntax-highlighter'.
500 years later, and am already on 15.5.0, still no. type?????
If you ended up here by searching for 'Could not find a declaration file for module 'react-syntax-highlighter/dist/esm/languages/prism/javascript' like me, I seem to have gotten around this problem by installing @types/react-syntax-highlighter and adding this at the top of the file where i had the errors:
/// <reference path="path/to/node_modules/@types/react-syntax-highlighter/index.d.ts" />
We're using react-syntax-highlighter in our stories though, so it's a different situation than the one posted by OP
The helpful hint from TS seems to work for me:
npm i --save-dev @types/react-syntax-highlighter
Describe the bug I'm using
6.0.0-rc.14
with Typescript and I have (and would like to keep) 'no-implicitly-any' enabled in mytsconfig.json
. After adding a some components from@storybook/addon-docs/blocks
I start to getimplicitly has an 'any' type.
error when type-checking my project. (viatsc --no-emit
).To Reproduce Steps to reproduce the behavior:
npx sb@next init
.tsconfig.json
should have the following setting enabled:6.0.0-rc.14
inpackage.json
of following devDependencies:Add a simple MyComponent via 'MyComponent.tsc`.
export default { title: "Components/MyComponent", components: { MyComponent }, parameters: { docs: { page: () => ( <>
A Title
A description. `} /> </> ), }, }, };
export const Basic =
Basic.args = {};