Skip to content

Commit 8a5ee2d

Browse files
authored
fix(typescript): not compatible with strict mode (react-page#1105)
1 parent 40342ef commit 8a5ee2d

File tree

203 files changed

+1292
-989
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

203 files changed

+1292
-989
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
declare module 'react-github-fork-ribbon' {
2+
const Component: React.FC<{
3+
href: string;
4+
target: string;
5+
position: 'left' | 'right' | 'left-bottom' | 'right-bottom';
6+
color: 'red' | 'orange' | 'black' | 'green';
7+
}>;
8+
export default Component;
9+
}

examples/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"@types/react-syntax-highlighter": "^13.5.0",
4040
"babel-plugin-styled-components": "^1.11.1",
4141
"raw-loader": "4.0.1",
42-
"react-admin": "^3.14.2"
42+
"react-admin": "^3.14.2",
43+
"@types/styled-components": "^5.1.15"
4344
}
4445
}

examples/pages/_app.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ import '@react-page/plugins-video/lib/index.css';
1313
import '@react-page/plugins-image/lib/index.css';
1414
import '@react-page/plugins-slate/lib/index.css';
1515
import 'katex/dist/katex.min.css';
16+
import type { AppProps } from 'next/app';
1617

17-
function MyApp({ Component, pageProps }) {
18+
function MyApp({ Component, pageProps }: AppProps) {
1819
return <Component {...pageProps} />;
1920
}
2021

examples/pages/_document.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import React from 'react';
2+
import type { DocumentContext } from 'next/document';
23
import Document, { Html, Head, Main, NextScript } from 'next/document';
34

45
import { ServerStyleSheet } from 'styled-components';
56
import { ServerStyleSheets } from '@material-ui/core/styles';
67

78
export default class MyDocument extends Document {
8-
static async getInitialProps(ctx) {
9+
static async getInitialProps(ctx: DocumentContext) {
910
const styledComponentsSheet = new ServerStyleSheet();
1011
const materialUiSheets = new ServerStyleSheets();
1112
const originalRenderPage = ctx.renderPage;

examples/pages/empty.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import React, { useState } from 'react';
55
import PageLayout from '../components/PageLayout';
66
import { cellPlugins } from '../plugins/cellPlugins';
77

8-
const LANGUAGES: Options['languages'] = [
8+
const LANGUAGES = [
99
{
1010
lang: 'en',
1111
label: 'English',
@@ -17,7 +17,7 @@ const LANGUAGES: Options['languages'] = [
1717
];
1818

1919
export default function Empty() {
20-
const [value, setValue] = useState<Value>(null);
20+
const [value, setValue] = useState<Value | null>(null);
2121

2222
return (
2323
<PageLayout>

examples/pages/examples/bare.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const cellPlugins = [slate(), image];
88

99
// Bare without page layout for bundle size debugging
1010
const Bare = () => {
11-
const [value] = useState<Value>(null);
11+
const [value] = useState<Value | null>(null);
1212

1313
return (
1414
<>

examples/pages/examples/cellSpacing.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,10 @@ export default function CellSpacing() {
110110
cellPlugins={cellPlugins}
111111
value={state.value}
112112
onChange={(value) => setState((s) => ({ ...s, value }))}
113-
cellSpacing={{ x: state.cellSpacingX, y: state.cellSpacingY }}
113+
cellSpacing={{
114+
x: state.cellSpacingX ?? 0,
115+
y: state.cellSpacingY ?? 0,
116+
}}
114117
/>
115118
</div>
116119
</PageLayout>

examples/pages/examples/conditionalForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const customPlugin: CellPlugin<{
4545
const cellPlugins = [customPlugin];
4646

4747
export default function SimpleExample() {
48-
const [value, setValue] = useState<Value>(null);
48+
const [value, setValue] = useState<Value | null>(null);
4949

5050
return (
5151
<PageLayout>

examples/pages/examples/constraints.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const aPlugin: CellPlugin = {
3535
const cellPlugins = [slate(), image, aPlugin];
3636

3737
export default function SimpleExample() {
38-
const [value, setValue] = useState<Value>(null);
38+
const [value, setValue] = useState<Value | null>(null);
3939

4040
return (
4141
<PageLayout>

examples/pages/examples/customEditorChildren.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { cellPlugins } from '../../plugins/cellPlugins';
1111
import { Button } from '@material-ui/core';
1212
import { Add } from '@material-ui/icons';
1313

14-
const LANGUAGES: Options['languages'] = [
14+
const LANGUAGES = [
1515
{
1616
lang: 'en',
1717
label: 'English',
@@ -71,7 +71,7 @@ function Toolbar() {
7171
}
7272

7373
export default function Example() {
74-
const [value, setValue] = useState<Value>(null);
74+
const [value, setValue] = useState<Value | null>(null);
7575

7676
return (
7777
<PageLayout>

examples/pages/examples/customToolbar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const cellPlugins = [slate(), image, customContentPlugin];
1111

1212
// Custom bottom toolbar example with collapse/restore functionality.
1313
const customToolbarExample = () => {
14-
const [value, setValue] = React.useState<Value>(null);
14+
const [value, setValue] = React.useState<Value | null>(null);
1515

1616
const [useCustom, setUseCustom] = useState(true);
1717
// make sure that you memoize custom components property to avoid unnesseary rerenders

examples/pages/examples/decorateplugins.tsx

Lines changed: 43 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15,48 +15,54 @@ type Styling = {
1515
paddingTop?: number;
1616
border?: CSSProperties['border'];
1717
};
18-
const pluginsWithMargin = cellPlugins.map<CellPlugin<Styling>>((p) => ({
19-
...p,
20-
cellStyle: (data) => ({
21-
paddingLeft: data.paddingLeft,
22-
paddingRight: data.paddingRight,
23-
paddingTop: data.paddingTop,
24-
paddingBottom: data.paddingBottom,
25-
border: data.border,
26-
}),
27-
controls: [
28-
{
29-
title: 'Main',
30-
controls: p.controls,
31-
},
32-
{
33-
title: 'Styling',
34-
controls: {
35-
type: 'autoform',
36-
columnCount: 3,
37-
schema: {
38-
properties: {
39-
paddingLeft: {
40-
type: 'number',
18+
const pluginsWithMargin = cellPlugins.map<CellPlugin<Styling>>(
19+
(p: CellPlugin) => ({
20+
...p,
21+
cellStyle: (data) => ({
22+
paddingLeft: data.paddingLeft,
23+
paddingRight: data.paddingRight,
24+
paddingTop: data.paddingTop,
25+
paddingBottom: data.paddingBottom,
26+
border: data.border,
27+
}),
28+
controls: [
29+
...(p.controls
30+
? [
31+
{
32+
title: 'Main',
33+
controls: p.controls,
4134
},
42-
paddingRight: {
43-
type: 'number',
44-
},
45-
paddingBottom: {
46-
type: 'number',
47-
},
48-
paddingTop: {
49-
type: 'number',
50-
},
51-
border: {
52-
type: 'string',
35+
]
36+
: []),
37+
{
38+
title: 'Styling',
39+
controls: {
40+
type: 'autoform',
41+
columnCount: 3,
42+
schema: {
43+
properties: {
44+
paddingLeft: {
45+
type: 'number',
46+
},
47+
paddingRight: {
48+
type: 'number',
49+
},
50+
paddingBottom: {
51+
type: 'number',
52+
},
53+
paddingTop: {
54+
type: 'number',
55+
},
56+
border: {
57+
type: 'string',
58+
},
5359
},
5460
},
5561
},
5662
},
57-
},
58-
],
59-
}));
63+
],
64+
})
65+
);
6066
export default function DecoratedPlugins() {
6167
const [value, setValue] = useState<Value>(demo);
6268

examples/pages/examples/i18n.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import React, { useState, useCallback } from 'react';
55
import { cellPlugins } from '../../plugins/cellPlugins';
66
import PageLayout from '../../components/PageLayout';
77
import { Button } from '@material-ui/core';
8-
const LANGUAGES: Options['languages'] = [
8+
const LANGUAGES = [
99
{
1010
lang: 'en',
1111
label: 'English',
@@ -27,8 +27,8 @@ const TRANSLATIONS: { [key: string]: string } = {
2727
export default function Home() {
2828
const [value, setValue] = useState<Value>(demo);
2929
const reset = () => setValue(demo);
30-
const uiTranslator = useCallback((label?: string) => {
31-
if (TRANSLATIONS[label] !== undefined) {
30+
const uiTranslator = useCallback((label?: string | null) => {
31+
if (label && TRANSLATIONS[label] !== undefined) {
3232
return TRANSLATIONS[label];
3333
}
3434
return `${label}(to translate)`;

examples/pages/examples/multipleEditors.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import PageLayout from '../../components/PageLayout';
2424
const cellPlugins = [slate(), image];
2525

2626
export default function SimpleExample() {
27-
const [value, setValue] = useState<Value>(null);
28-
const [value2, setValue2] = useState<Value>(null);
27+
const [value, setValue] = useState<Value | null>(null);
28+
const [value2, setValue2] = useState<Value | null>(null);
2929

3030
return (
3131
<PageLayout>

examples/pages/examples/nestedPlugins.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ const deeplyNestedA: CellPlugin = {
118118
const cellPlugins = [fullSlate, image, aPlugin, anotherPlugin, deeplyNestedA];
119119

120120
export default function NestedPluginsExample() {
121-
const [value, setValue] = useState<Value>(null);
121+
const [value, setValue] = useState<Value | null>(null);
122122
const [readOnly, setReadOnly] = useState(false);
123123

124124
return (

examples/pages/examples/reactadmin.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
12
// The editor core
23
import {
34
Card,
@@ -6,6 +7,7 @@ import {
67
CardContent,
78
Typography,
89
} from '@material-ui/core';
10+
import type { Record as RecordType } from 'ra-core';
911
import type { CellPlugin } from '@react-page/editor';
1012
import slate, {
1113
DEFAULT_SLATE_PLUGIN_ID,
@@ -76,7 +78,7 @@ const dataProvider = fakeDataProvider({
7678
/**
7779
* This is an example of a slate link plugin that uses react admin to select the target
7880
*/
79-
const PostIdSelector = (props) => (
81+
const PostIdSelector = (props: any) => (
8082
// pass the props
8183
<RaSelectReferenceInputField
8284
optionText="title"
@@ -113,7 +115,7 @@ const postLinkPlugin = pluginFactories.createComponentPlugin<{
113115
// this code here lives primarly in your frontend, you would create the link however you like
114116
// and you would probably read more data from your datasource
115117
// this is just a simple example. The link dofes actually not work in our example, but you should get the idea
116-
Component: (props) => (
118+
Component: (props: any) => (
117119
<Link href={'/posts/' + props.postId}>
118120
<a>{props.children}</a>
119121
</Link>
@@ -132,7 +134,7 @@ const customSlate = slate((def) => ({
132134
},
133135
}));
134136

135-
const ProductIdSelector = (props) => (
137+
const ProductIdSelector = (props: any) => (
136138
// pass the props
137139
<RaSelectReferenceInputField
138140
{...props}
@@ -146,7 +148,7 @@ const ProductTeaser: React.FC<{ productId: string }> = ({ productId }) => {
146148
// this component would live in your frontend
147149
// you won't load data from admin here, but from the public frontend api
148150
// for this example, we use the dataprovider, but in real-live-applications, that would not be the case
149-
const [product, setProduct] = useState(null);
151+
const [product, setProduct] = useState<RecordType | null>(null);
150152
useEffect(() => {
151153
dataProvider
152154
.getOne('products', { id: productId })
@@ -174,7 +176,7 @@ const recommendedProducts: CellPlugin<{
174176
}> = {
175177
id: 'recommendedProducts',
176178
title: 'Recommended Products',
177-
Renderer: (props) => (
179+
Renderer: (props: any) => (
178180
<div>
179181
<h3>{props.data.title}</h3>
180182
<div
@@ -184,7 +186,7 @@ const recommendedProducts: CellPlugin<{
184186
gap: 10,
185187
}}
186188
>
187-
{props.data.productIds?.map((id) => (
189+
{props.data.productIds?.map((id: string) => (
188190
<ProductTeaser productId={id} key={id} />
189191
))}
190192
</div>
@@ -220,7 +222,7 @@ const ourCellPlugins = [
220222
...cellPlugins.filter((p) => p.id !== DEFAULT_SLATE_PLUGIN_ID),
221223
];
222224

223-
const PostList = (props) => {
225+
const PostList = (props: any) => {
224226
return (
225227
<List {...props}>
226228
<Datagrid>
@@ -233,7 +235,7 @@ const PostList = (props) => {
233235
);
234236
};
235237

236-
export const PostEdit = (props) => (
238+
export const PostEdit = (props: any) => (
237239
<Edit title="Edit a Post" {...props}>
238240
<SimpleForm label="summary">
239241
<TextInput disabled source="id" />
@@ -247,7 +249,7 @@ export const PostEdit = (props) => (
247249
</Edit>
248250
);
249251

250-
export const PostCreate = (props) => (
252+
export const PostCreate = (props: any) => (
251253
<Create title="Create a Post" {...props}>
252254
<SimpleForm label="summary">
253255
<TextInput source="id" />
@@ -262,7 +264,7 @@ const posts = {
262264
edit: PostEdit,
263265
};
264266

265-
const ProductList = (props) => {
267+
const ProductList = (props: any) => {
266268
return (
267269
<List {...props}>
268270
<Datagrid>
@@ -276,7 +278,7 @@ const ProductList = (props) => {
276278
);
277279
};
278280

279-
export const ProductEdit = (props) => (
281+
export const ProductEdit = (props: any) => (
280282
<Edit title="Edit a Product" {...props}>
281283
<SimpleForm label="summary">
282284
<TextInput disabled source="id" />
@@ -287,7 +289,7 @@ export const ProductEdit = (props) => (
287289
</Edit>
288290
);
289291

290-
export const ProductCreate = (props) => (
292+
export const ProductCreate = (props: any) => (
291293
<Create title="Create a Product" {...props}>
292294
<SimpleForm label="summary">
293295
<TextInput source="id" />

examples/pages/examples/sidebarPosition.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import PageLayout from '../../components/PageLayout';
2424
const cellPlugins = [slate(), image];
2525

2626
export default function SimpleExample() {
27-
const [value, setValue] = useState<Value>(null);
27+
const [value, setValue] = useState<Value | null>(null);
2828

2929
const [sidebarPosition, setSidebarPosition] =
3030
useState<Options['sidebarPosition']>('rightAbsolute');

examples/pages/examples/simple.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import PageLayout from '../../components/PageLayout';
2424
const cellPlugins = [slate(), image];
2525

2626
export default function SimpleExample() {
27-
const [value, setValue] = useState<Value>(null);
27+
const [value, setValue] = useState<Value | null>(null);
2828

2929
return (
3030
<PageLayout>

0 commit comments

Comments
 (0)