Skip to content

Commit

Permalink
Replace interfaces to types
Browse files Browse the repository at this point in the history
They are almost the same, but interfaces has fewer features than types. Excellent explanation here
https://www.youtube.com/watch?v=oiFo2z8ILNo
  • Loading branch information
sztadii committed Jun 23, 2024
1 parent dd61d0c commit 8b54726
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion src/components-connected/album-ratings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useCallback } from 'react'

import { useAlbumRatings } from 'src/stores/music-store'

interface AlbumRatingsProps {
type AlbumRatingsProps = {
albumId: string
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/error-boundary.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Component, ErrorInfo, ReactNode } from 'react'

interface ErrorBoundaryProps {
type ErrorBoundaryProps = {
children: ReactNode
fallback: ReactNode
}

interface ErrorBoundaryState {
type ErrorBoundaryState = {
hasError: boolean
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/tooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Tooltip as MUITooltip } from '@mui/material'
import { ReactNode } from 'react'

interface TooltipProps {
type TooltipProps = {
title: string
/**
* In some cases, we may want to disable the tooltip,
Expand Down
70 changes: 35 additions & 35 deletions src/services/music-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ export async function findTopAlbums(limit = 10): Promise<TopAlbumsResponse> {
}

// Generated by https://transform.tools/json-to-typescript
export interface TopAlbumsResponse {
export type TopAlbumsResponse = {
feed: Feed
}

interface Feed {
type Feed = {
author: Author
entry: Entry[]
updated: Updated
Expand All @@ -24,20 +24,20 @@ interface Feed {
id: Id2
}

interface Author {
type Author = {
name: Name
uri: Uri
}

interface Name {
type Name = {
label: string
}

interface Uri {
type Uri = {
label: string
}

interface Entry {
type Entry = {
'im:name': ImName
'im:image': ImImage[]
'im:itemCount': ImItemCount
Expand All @@ -52,134 +52,134 @@ interface Entry {
'im:releaseDate': ImReleaseDate
}

interface ImName {
type ImName = {
label: string
}

interface ImImage {
type ImImage = {
label: string
attributes: Attributes
}

interface Attributes {
type Attributes = {
height: string
}

interface ImItemCount {
type ImItemCount = {
label: string
}

interface ImPrice {
type ImPrice = {
label: string
attributes: Attributes2
}

interface Attributes2 {
type Attributes2 = {
amount: string
currency: string
}

interface ImContentType {
type ImContentType = {
'im:contentType': ImContentType2
attributes: Attributes4
}

interface ImContentType2 {
type ImContentType2 = {
attributes: Attributes3
}

interface Attributes3 {
type Attributes3 = {
term: string
label: string
}

interface Attributes4 {
type Attributes4 = {
term: string
label: string
}

interface Rights {
type Rights = {
label: string
}

interface Title {
type Title = {
label: string
}

interface Link {
type Link = {
attributes: Attributes5
}

interface Attributes5 {
type Attributes5 = {
rel: string
type: string
href: string
}

interface Id {
type Id = {
label: string
attributes: Attributes6
}

interface Attributes6 {
type Attributes6 = {
'im:id': string
}

interface ImArtist {
type ImArtist = {
label: string
attributes?: Attributes7
}

interface Attributes7 {
type Attributes7 = {
href: string
}

interface Category {
type Category = {
attributes: Attributes8
}

interface Attributes8 {
type Attributes8 = {
'im:id': string
term: string
scheme: string
label: string
}

interface ImReleaseDate {
type ImReleaseDate = {
label: string
attributes: Attributes9
}

interface Attributes9 {
type Attributes9 = {
label: string
}

interface Updated {
type Updated = {
label: string
}

interface Rights2 {
type Rights2 = {
label: string
}

interface Title2 {
type Title2 = {
label: string
}

interface Icon {
type Icon = {
label: string
}

interface Link2 {
type Link2 = {
attributes: Attributes10
}

interface Attributes10 {
type Attributes10 = {
rel: string
type?: string
href: string
}

interface Id2 {
type Id2 = {
label: string
}
2 changes: 1 addition & 1 deletion src/stores/store-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ReactNode } from 'react'
import { RecoilRoot } from 'recoil'
import { RecoilURLSyncJSON } from 'recoil-sync'

interface StoreProviderProps {
type StoreProviderProps = {
children: ReactNode
}

Expand Down

0 comments on commit 8b54726

Please sign in to comment.