Skip to content

Commit

Permalink
alex/consistent-object-types: consistent object types
Browse files Browse the repository at this point in the history
  • Loading branch information
SomeHats committed May 22, 2024
1 parent abc8521 commit cfe5af9
Show file tree
Hide file tree
Showing 131 changed files with 712 additions and 415 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ module.exports = {
'error',
{ name: 'structuredClone', message: 'Use structuredClone from @tldraw/util instead' },
],
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
},
parser: '@typescript-eslint/parser',
parserOptions: {
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/components/ArticleDetails.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Article } from '@/types/content-types'
import { Icon } from './Icon'

type ArticleDetailsProps = {
interface ArticleDetailsProps {
article: Article
}

Expand Down
2 changes: 1 addition & 1 deletion apps/docs/components/ArticleNavLinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ArticleLinks } from '@/types/content-types'
import Link from 'next/link'
import { Icon } from './Icon'

type ArticleNavLinksProps = {
interface ArticleNavLinksProps {
links: ArticleLinks
}

Expand Down
4 changes: 2 additions & 2 deletions apps/docs/components/Autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import './Autocomplete.css'
import { Icon } from './Icon'
import { Spinner } from './Spinner'

export type DropdownOption = {
export interface DropdownOption {
label: string
value: string
group?: string
}

type AutocompleteProps = {
interface AutocompleteProps {
customUI?: React.ReactNode
groups?: string[]
groupsToIcon?: {
Expand Down
5 changes: 4 additions & 1 deletion apps/docs/scripts/functions/getApiMarkdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ import {
} from '@microsoft/api-extractor-model'
import { MarkdownWriter, formatWithPrettier, getPath, getSlug } from '../utils'

type Result = { markdown: string; keywords: string[] }
interface Result {
markdown: string
keywords: string[]
}

const REPO_URL = 'https://github.com/tldraw/tldraw/blob/main/'

Expand Down
15 changes: 9 additions & 6 deletions apps/docs/types/content-types.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
export type InputCategory = {
export interface InputCategory {
id: string
title: string
description: string
groups: InputGroup[]
hero: string | null
}

export type InputSection = {
export interface InputSection {
id: string
title: string
description: string
Expand All @@ -15,7 +15,7 @@ export type InputSection = {
sidebar_behavior: 'show-links' | 'show-title' | 'hidden' | 'reference'
}

export type InputGroup = {
export interface InputGroup {
id: string
}

Expand Down Expand Up @@ -150,7 +150,7 @@ export type ArticleLink = Pick<
'id' | 'title' | 'description' | 'categoryId' | 'sectionId' | 'path'
>

export type ArticleLinks = {
export interface ArticleLinks {
prev: ArticleLink | null
next: ArticleLink | null
}
Expand Down Expand Up @@ -184,7 +184,7 @@ export type SidebarContentLink =
| SidebarContentCategoryLink
| SidebarContentArticleLink

export type SidebarContentList = {
export interface SidebarContentList {
sectionId: string | null
categoryId: string | null
articleId: string | null
Expand All @@ -197,4 +197,7 @@ export type SidebarContentList = {
/** A table keyed by slug of articles. */
export type Articles = Record<string, Article>

export type GeneratedContent = { sections: Section[]; articles: Articles }
export interface GeneratedContent {
sections: Section[]
articles: Articles
}
2 changes: 1 addition & 1 deletion apps/docs/types/search-types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type SearchResult = {
export interface SearchResult {
type: 'article' | 'category' | 'section' | 'heading'
id: string
subtitle: string
Expand Down
2 changes: 1 addition & 1 deletion apps/dotcom-worker/src/lib/AlarmScheduler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { exhaustiveSwitchError, hasOwnProperty } from '@tldraw/utils'

type AlarmOpts = {
interface AlarmOpts {
overwrite: 'always' | 'if-sooner'
}

Expand Down
2 changes: 1 addition & 1 deletion apps/dotcom-worker/src/lib/TLDrawDurableObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const MAX_CONNECTIONS = 50

// increment this any time you make a change to this type
const CURRENT_DOCUMENT_INFO_VERSION = 0
type DocumentInfo = {
interface DocumentInfo {
version: number
slug: string
}
Expand Down
2 changes: 1 addition & 1 deletion apps/dotcom-worker/src/lib/routes/createRoomSnapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { getR2KeyForSnapshot } from '../r2'
import { Environment } from '../types'
import { validateSnapshot } from '../utils/validateSnapshot'

export type R2Snapshot = {
export interface R2Snapshot {
parent_slug: CreateSnapshotRequestBody['parent_slug']
drawing: RoomSnapshot
}
Expand Down
2 changes: 1 addition & 1 deletion apps/dotcom-worker/src/lib/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// https://developers.cloudflare.com/analytics/analytics-engine/

// This type isn't available in @cloudflare/workers-types yet
export type Analytics = {
export interface Analytics {
writeDataPoint(data: {
blobs?: string[]
doubles?: number[]
Expand Down
2 changes: 1 addition & 1 deletion apps/dotcom-worker/src/lib/utils/validateSnapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { TLRecord } from '@tldraw/tlschema'
import { schema } from '@tldraw/tlsync'
import { Result, objectMapEntries } from '@tldraw/utils'

type SnapshotRequestBody = {
interface SnapshotRequestBody {
schema: SerializedSchema
snapshot: SerializedStore<TLRecord>
}
Expand Down
2 changes: 1 addition & 1 deletion apps/dotcom/src/components/DocumentName/DocumentName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { FORK_PROJECT_ACTION } from '../../utils/sharing'
import { SAVE_FILE_COPY_ACTION } from '../../utils/useFileSystem'
import { getShareUrl } from '../ShareMenu'

type NameState = {
interface NameState {
readonly name: string | null
readonly isEditing: boolean
}
Expand Down
2 changes: 1 addition & 1 deletion apps/dotcom/src/components/ShareMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const SHARE_CURRENT_STATE = {
} as const
type ShareCurrentState = (typeof SHARE_CURRENT_STATE)[keyof typeof SHARE_CURRENT_STATE]

type ShareState = {
interface ShareState {
state: ShareCurrentState
qrCodeDataUrl: string
url: string
Expand Down
2 changes: 1 addition & 1 deletion apps/dotcom/src/components/SnapshotsEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const components: TLComponents = {
},
}

type SnapshotEditorProps = {
interface SnapshotEditorProps {
schema: SerializedSchema
records: TLRecord[]
}
Expand Down
2 changes: 1 addition & 1 deletion apps/dotcom/src/utils/remote-sync/remote-sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class RemoteSyncError extends Error {
}

/** @public */
export type UseSyncClientConfig = {
export interface UseSyncClientConfig {
uri: string
roomId?: string
userPreferences?: Signal<TLUserPreferences>
Expand Down
2 changes: 1 addition & 1 deletion apps/examples/e2e/tests/fixtures/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { PageMenu } from './menus/PageMenu'
import { StylePanel } from './menus/StylePanel'
import { Toolbar } from './menus/Toolbar'

type Fixtures = {
interface Fixtures {
toolbar: Toolbar
stylePanel: StylePanel
actionsMenu: ActionsMenu
Expand Down
2 changes: 1 addition & 1 deletion apps/examples/src/examples.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ComponentType } from 'react'

export type Example = {
export interface Example {
title: string
description: string
details: string
Expand Down
4 changes: 2 additions & 2 deletions apps/examples/src/examples/pdf-editor/PdfPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { useState } from 'react'
import { AssetRecordType, Box, TLAssetId, TLShapeId, createShapeId } from 'tldraw'
import tldrawPdf from './assets/tldraw.pdf'

export type PdfPage = {
export interface PdfPage {
src: string
bounds: Box
assetId: TLAssetId
shapeId: TLShapeId
}

export type Pdf = {
export interface Pdf {
name: string
pages: PdfPage[]
source: string | ArrayBuffer
Expand Down
2 changes: 1 addition & 1 deletion apps/examples/src/examples/slideshow/SlidesManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { atom, computed, structuredClone, uniqueId } from 'tldraw'
export const SLIDE_SIZE = { x: 0, y: 0, w: 1600, h: 900 }
export const SLIDE_MARGIN = 100

type Slide = {
interface Slide {
id: string
index: number
name: string
Expand Down
2 changes: 1 addition & 1 deletion apps/health-worker/src/discord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const RED = 14692657
const ORANGE = 16213767

// docs: https://birdie0.github.io/discord-webhooks-guide/index.html
export type DiscordPayload = {
export interface DiscordPayload {
username: string
content: string
embeds: APIEmbed[]
Expand Down
4 changes: 2 additions & 2 deletions apps/huppy/pages/deliveries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { GetServerSideProps } from 'next'
import { useEffect, useState } from 'react'
import { getAppOctokit } from '../src/octokit'

type Props = {
interface Props {
deliveries: {
id: number
guid: string
Expand Down Expand Up @@ -39,7 +39,7 @@ export const getServerSideProps: GetServerSideProps<Props> = async (context) =>
return { props: { deliveries: deliveries.data, cursor } }
}

type SelectedDelivery = {
interface SelectedDelivery {
id: number
data?: unknown
}
Expand Down
2 changes: 1 addition & 1 deletion apps/huppy/src/ctx.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { App, Octokit } from 'octokit'

export type Ctx = {
export interface Ctx {
app: App
octokit: Octokit
installationToken: string
Expand Down
4 changes: 2 additions & 2 deletions apps/huppy/src/flows/collectClaSignatures.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ const CLA_SIGNATURES_BRANCH = 'cla-signees'

const pullRequestActionsToCheck = ['opened', 'synchronize', 'reopened', 'edited']

type Signing = {
interface Signing {
githubId: number
signedAt: string
signedVersion: 1
signingComment: string
}
type SigneeInfo = {
interface SigneeInfo {
unsigned: Set<string>
signees: Map<string, { signing: Signing; fileSha: string }>
total: number
Expand Down
2 changes: 1 addition & 1 deletion apps/vscode/editor/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const TldrawWrapper = () => {
)
}

export type TLDrawInnerProps = {
export interface TLDrawInnerProps {
assetSrc: string
fileContents: string
uri: string
Expand Down
2 changes: 1 addition & 1 deletion apps/vscode/editor/src/utils/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { uniqueId } from 'tldraw'
import type { VscodeMessagePairs } from '../../../messages'
import { vscode } from './vscode'

type SimpleRpcOpts = {
interface SimpleRpcOpts {
timeout: number
}
class SimpleRpcError extends Error {
Expand Down
11 changes: 7 additions & 4 deletions packages/dotcom-shared/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { SerializedSchema, SerializedStore, TLRecord } from 'tldraw'

export type Snapshot = {
export interface Snapshot {
schema: SerializedSchema
snapshot: SerializedStore<TLRecord>
}

export type CreateRoomRequestBody = {
export interface CreateRoomRequestBody {
origin: string
snapshot: Snapshot
}

export type CreateSnapshotRequestBody = {
export interface CreateSnapshotRequestBody {
schema: SerializedSchema
snapshot: SerializedStore<TLRecord>
parent_slug?: string | undefined
Expand All @@ -26,4 +26,7 @@ export type CreateSnapshotResponseBody =
message: string
}

export type GetReadonlySlugResponseBody = { slug: string; isLegacy: boolean }
export interface GetReadonlySlugResponseBody {
slug: string
isLegacy: boolean
}

0 comments on commit cfe5af9

Please sign in to comment.