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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CardMediaTypeMap interface not exported #15923

Closed
HanjoHagemeierHCL opened this issue May 28, 2019 · 6 comments · Fixed by #17354
Closed

CardMediaTypeMap interface not exported #15923

HanjoHagemeierHCL opened this issue May 28, 2019 · 6 comments · Fixed by #17354
Labels
component: card This is the name of the generic UI component, not the React module! typescript

Comments

@HanjoHagemeierHCL
Copy link

In the Material-UI version v4.0.1 is the CardMediaTypeMap interface not exported.

@eps1lon
Copy link
Member

eps1lon commented May 29, 2019

What do you need it for?

@HanjoHagemeierHCL
Copy link
Author

HanjoHagemeierHCL commented May 29, 2019

I have wrapped the CardMedia component. In the history i have use the version 3.9.3 and with this version it work's but not for the new version 4.0.1.

Example comp:

import { Theme, createStyles, withStyles } from '@material-ui/core/styles';
import CardMedia from '@material-ui/core/CardMedia';

const styles = (theme: Theme) => createStyles({
});

export default withStyles(styles)(CardMedia);
export * from '@material-ui/core/CardMedia';

I got the following typescript error.

Default export of the module has or is using private name 'CardMediaTypeMap'.

@impleri
Copy link

impleri commented Aug 20, 2019

I am getting this in 4.3.2 when using CardMedia as a defaultProp to another component. Example:

import CardMedia, { CardMediaProps } from '@material-ui/core/CardMedia';
import React, { ComponentType, PureComponent } from 'react';

interface SomeComponentProps {
  CardMediaComponent: ComponentType<CardMediaProps>;
}

export class SomeComponent extends PureComponent<SomeComponentProps> {
  public static defaultProps = {
    CardMediaComponent: CardMedia,
  };

  public render() {
    const { CardMediaComponent, ...props } = this.props;

    return <CardMediaComponent {...props } />;
  }
}

The error is :

error TS4026: Public static property 'defaultProps' of exported class has or is using name 'CardMediaTypeMap' from external module ".../node_modules/@material-ui/core/CardMedia/CardMedia" but cannot be named.

@impleri
Copy link

impleri commented Aug 27, 2019

Workaround is not to declare it as a defaultProp. Works fine when being passed as a prop.

@oliviertassinari oliviertassinari added component: card This is the name of the generic UI component, not the React module! and removed component: CardMedia labels Sep 8, 2019
@oliviertassinari
Copy link
Member

The type is exported since #17354.

@trusktr
Copy link

trusktr commented Dec 21, 2019

I've opened a request to fix issues like these in TypeScript by bringing declaration files to parity with language features. microsoft/TypeScript#35822

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: card This is the name of the generic UI component, not the React module! typescript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants