Skip to content

Instantly share code, notes, and snippets.

@ratbeard
Created April 6, 2018 17:30
Show Gist options
  • Select an option

  • Save ratbeard/bb81f32ef3a5d8abdc297d7ca93dcf4d to your computer and use it in GitHub Desktop.

Select an option

Save ratbeard/bb81f32ef3a5d8abdc297d7ca93dcf4d to your computer and use it in GitHub Desktop.
// 1 - rename type
import { IBreadcrumb, BreadcrumbFrontend, BreadcrumbData, SomeOtherNamingConvention } from 'types'
export class Breadcrumb extends Component {}
// 2 - rename component. yuck
import { Breadcrumb } from 'types'
export class BreadcrumbComponent extends Component {}
// 3 - alias import. vscode's auto-import won't know to alias and it may give confusing type error before you add the import
import { Breadcrumb as BreadcrumbType } from 'types'
export class Breadcrumb extends Component {}
// 4 - alias export
import { Breadcrumb } from 'types'
class BreadcrumbComponent extends Component {}
export { BreadcrumbComponent as Breadcrumb }
@ratbeard

ratbeard commented Apr 6, 2018

Copy link
Copy Markdown
Author

Yea #3 is too confusing. I've got this, where Breadcrumb[] is refering to the class below it and its not giving me a compile error.

interface BreadcrumbProps { 
  breadcrumbs: Breadcrumb[];
}

class Breadcrumb extends PureComponent<BreadcrumbProps> {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment