🎥 Make videos programmatically with React
fix types
Jonny Burger111aad5a2609
diff --git a/packages/core/src/Composition.tsx b/packages/core/src/Composition.tsxindex 965db50d02..0792751569 100644--- a/packages/core/src/Composition.tsx+++ b/packages/core/src/Composition.tsx@@ -40,7 +40,7 @@ export type StillProps<Schema extends z.ZodTypeAny, Props> = {} & CompProps<Props> &PropsIfHasProps<Schema, Props>;-type CompositionProps<Schema extends z.ZodTypeAny, Props> = StillProps<+export type CompositionProps<Schema extends z.ZodTypeAny, Props> = StillProps<Schema,Props> & {@@ -75,7 +75,7 @@ export const Composition = <Schema extends z.ZodTypeAny, Props>({useContext(CompositionManager);const video = useVideo();- const lazy = useLazyComponent(compProps);+ const lazy = useLazyComponent<Props>(compProps as CompProps<Props>);const nonce = useNonce();const environment = useRemotionEnvironment();@@ -121,7 +121,7 @@ export const Composition = <Schema extends z.ZodTypeAny, Props>({id,folderName,component: lazy,- defaultProps,+ defaultProps: defaultProps as z.infer<Schema> & Props,nonce,parentFolderName: parentName,});diff --git a/packages/core/src/Still.tsx b/packages/core/src/Still.tsxindex 693a4fbc8f..13fd152383 100644--- a/packages/core/src/Still.tsx+++ b/packages/core/src/Still.tsx@@ -1,5 +1,6 @@+import React from 'react';import type {z} from 'zod';-import type {StillProps} from './Composition.js';+import type {CompositionProps, StillProps} from './Composition.js';import {Composition} from './Composition.js';/**@@ -7,8 +8,14 @@ import {Composition} from './Composition.js';* @see [Documentation](https://www.remotion.dev/docs/still)*/-export const Still = <T extends z.ZodTypeAny, Props>(- props: StillProps<T, Props>+export const Still = <Schema extends z.ZodTypeAny, Props>(+ props: StillProps<Schema, Props>) => {- return <Composition fps={1} durationInFrames={1} {...props} />;+ const newProps: CompositionProps<Schema, Props> = {+ ...props,+ durationInFrames: 1,+ fps: 1,+ };+ // @ts-expect-error TypeScript does not understand it, but should still fail on type mismatch+ return React.createElement(Composition<Schema, Props>, newProps);};diff --git a/packages/core/src/props-if-has-props.ts b/packages/core/src/props-if-has-props.tsindex 869d4c02b3..af9a982fce 100644--- a/packages/core/src/props-if-has-props.ts+++ b/packages/core/src/props-if-has-props.ts@@ -7,12 +7,18 @@ export type PropsIfHasProps<? {} extends Props? {// Neither props nor schema specified- defaultProps?: z.infer<Schema> & Props;+ defaultProps?: Props;}: {// Only props specifieddefaultProps: Props;}+ : {} extends Props+ ? {+ // Only schema specified+ defaultProps: z.infer<Schema>;+ }: {+ // Props and schema specifieddefaultProps: z.infer<Schema> & Props;};diff --git a/packages/lambda/src/shared/constants.ts b/packages/lambda/src/shared/constants.tsindex 321e951289..b0ea32aa58 100644--- a/packages/lambda/src/shared/constants.ts+++ b/packages/lambda/src/shared/constants.ts@@ -9,7 +9,7 @@ import type {StillImageFormat,VideoImageFormat,} from '@remotion/renderer';-import type {VideoConfig} from 'remotion';+import type {AnyCompMetadata} from 'remotion';import type {ChunkRetry} from '../functions/helpers/get-retry-stats';import type {EnhancedErrorInfo} from '../functions/helpers/write-lambda-error';import type {AwsRegion} from '../pricing/aws-regions';@@ -388,7 +388,7 @@ type Discriminated =export type RenderMetadata = Discriminated & {siteId: string;- videoConfig: VideoConfig;+ videoConfig: AnyCompMetadata;startedDate: number;totalChunks: number;estimatedTotalLambdaInvokations: number;diff --git a/packages/player/src/Player.tsx b/packages/player/src/Player.tsxindex 32a88bf695..a7498ed66d 100644--- a/packages/player/src/Player.tsx+++ b/packages/player/src/Player.tsx@@ -66,8 +66,8 @@ export type PlayerProps<Schema extends z.ZodTypeAny, Props> = {renderFullscreenButton?: RenderFullscreenButton;alwaysShowControls?: boolean;schema?: Schema;-} & PropsIfHasProps<Schema, Props> &- CompProps<Props>;+} & CompProps<Props> &+ PropsIfHasProps<Schema, Props>;export const componentOrNullIfLazy = <Props,>(props: CompProps<Props>