Skip to content

🎥 Make videos programmatically with React

mark props as const to enable enums

Jonny Burger28a7afbff027
diff --git a/packages/cli/src/codemods/update-default-props.ts b/packages/cli/src/codemods/update-default-props.ts
index b7e39a0410..57fc7a9b63 100644
--- a/packages/cli/src/codemods/update-default-props.ts
+++ b/packages/cli/src/codemods/update-default-props.ts
@@ -129,6 +129,7 @@ export const updateDefaultProps = async ({
const newFile =
input.substring(0, startPos) +
stringifyDefaultProps(newDefaultProps) +
+ ' as const' +
input.substring(endPos);
const configFilePath = await resolveConfigFile();
@@ -148,6 +149,7 @@ export const updateDefaultProps = async ({
filepath: 'test.tsx',
plugins: [],
endOfLine: 'auto',
+ printWidth: 70,
});
return prettified;
};
diff --git a/packages/cli/src/test/snapshots/root-after.tsx b/packages/cli/src/test/snapshots/root-after.tsx
index 4e47c416eb..f0188ba8e2 100644
--- a/packages/cli/src/test/snapshots/root-after.tsx
+++ b/packages/cli/src/test/snapshots/root-after.tsx
@@ -31,10 +31,12 @@ export const Root: React.FC = () => {
height={1080}
width={1080}
id="Comp3"
- defaultProps={{
- abc: 'def',
- newDate: new Date('2022-01-02T00:00:00.000Z'),
- }}
+ defaultProps={
+ {
+ abc: 'def',
+ newDate: new Date('2022-01-02T00:00:00.000Z'),
+ } as const
+ }
/>
</>
);