Skip to content

How to add a new prop to eject component in the TypeScript project #9883

Answered by slorber
jcubic asked this question in Q&A
Discussion options

You must be logged in to vote

To be honest I'm not a fan of the CodeSandbox UX lately, and only use StackBlitz now.

You can use TS interface declaration merging feature to "enhance" the existing theme props types and add yours. Normally all our theme components export a Props interface.

This compiles with:

declare module "@theme/CodeBlock" {
  export interface Props {
    readonly theme: PrismTheme;
  }
}

https://codesandbox.io/p/devbox/exciting-mountain-fmh3z6?file=%2Fsrc%2Fpages%2Findex.tsx%3A62%2C2&workspaceId=cfc1fcc6-71a5-4f69-aa36-2cb4bfd3697d

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@jcubic
Comment options

@slorber
Comment options

@jcubic
Comment options

@slorber
Comment options

Answer selected by jcubic
@jcubic
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants