TypeScript: interface > type

This commit is contained in:
Rob Watson 2021-09-28 19:51:08 +02:00
parent f237823b65
commit 0cdc728587
3 changed files with 16 additions and 16 deletions

View File

@ -4,43 +4,43 @@ import { Thumbnails } from './Waveform/Thumbnails';
import { Canvas as WaveformCanvas } from './Waveform/Canvas'; import { Canvas as WaveformCanvas } from './Waveform/Canvas';
import { canvasXToFrame, mouseEventToCanvasX } from './Waveform/Helpers'; import { canvasXToFrame, mouseEventToCanvasX } from './Waveform/Helpers';
type Props = { interface Props {
audioContext: AudioContext; audioContext: AudioContext;
}; }
// Audio corresponds to media.Audio. // Audio corresponds to media.Audio.
export type Audio = { export interface Audio {
bytes: number; bytes: number;
channels: number; channels: number;
frames: number; frames: number;
sampleRate: number; sampleRate: number;
}; }
// Video corresponds to media.Video. // Video corresponds to media.Video.
export type Video = { export interface Video {
bytes: number; bytes: number;
thumbnailWidth: number; thumbnailWidth: number;
thumbnailHeight: number; thumbnailHeight: number;
durationMillis: number; durationMillis: number;
}; }
// MediaSet corresponds to media.MediaSet. // MediaSet corresponds to media.MediaSet.
export type MediaSet = { export interface MediaSet {
id: string; id: string;
source: string; source: string;
audio: Audio; audio: Audio;
video: Video; video: Video;
}; }
export type Selection = { export interface Selection {
x1: number; x1: number;
x2: number; x2: number;
}; }
type ZoomSettings = { interface ZoomSettings {
startFrame: number; startFrame: number;
endFrame: number; endFrame: number;
}; }
const defaultZoomSettings: ZoomSettings = { startFrame: 0, endFrame: 0 }; const defaultZoomSettings: ZoomSettings = { startFrame: 0, endFrame: 0 };

View File

@ -3,12 +3,12 @@ import { CanvasLogicalWidth, CanvasLogicalHeight } from '../Waveform';
const maxPeakValue = 32_768; const maxPeakValue = 32_768;
type Props = { interface Props {
peaks: number[][] | null; peaks: number[][] | null;
strokeStyle: string; strokeStyle: string;
fillStyle: string; fillStyle: string;
style: React.CSSProperties; style: React.CSSProperties;
}; }
// Canvas is a generic component that renders a waveform to a canvas. // Canvas is a generic component that renders a waveform to a canvas.
// //

View File

@ -7,13 +7,13 @@ import {
} from '../Waveform'; } from '../Waveform';
import { mouseEventToCanvasX } from './Helpers'; import { mouseEventToCanvasX } from './Helpers';
type Props = { interface Props {
peaks: number[][] | null; peaks: number[][] | null;
numFrames: number; numFrames: number;
style: React.CSSProperties; style: React.CSSProperties;
onSelectionStart: (x1: number) => void; onSelectionStart: (x1: number) => void;
onSelectionChange: (selection: Selection) => void; onSelectionChange: (selection: Selection) => void;
}; }
enum Mode { enum Mode {
Normal, Normal,