Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extracting some fixes to the types from #482 #553

Merged
merged 1 commit into from
Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/toolpad-app/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ const buildEnvVars = {
module.exports = {
reactStrictMode: true,

eslint: {
// We're running this as part of the monorepo eslint
ignoreDuringBuilds: true,
},

// build-time env vars
env: buildEnvVars,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function CodeComponentEditorContent({ theme, codeComponentNode }: CodeComponentE

usePageTitle(`${codeComponentNode.name} | Toolpad editor`);

const updateInputExtern = React.useCallback((newInput) => {
const updateInputExtern = React.useCallback((newInput: string) => {
const editor = editorRef.current;
if (!editor) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,13 @@ function ConnectionEditorContent<P>({
const domApi = useDomApi();

const handleConnectionChange = React.useCallback(
(connectionParams) => {
(Object.keys(connectionParams) as (keyof P)[]).forEach((propName) => {
if (typeof propName !== 'string' || !connectionParams[propName]) {
return;
}
domApi.setNodeNamespacedProp(
connectionNode,
'attributes',
'params',
appDom.createSecret(connectionParams),
);
});
(connectionParams: P | null) => {
domApi.setNodeNamespacedProp(
connectionNode,
'attributes',
'params',
appDom.createSecret(connectionParams),
);
},
[connectionNode, domApi],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ function QueryNodeEditorDialog<Q, P>({
const dataSourceId = input.attributes.dataSource?.value;
const dataSource = (dataSourceId && dataSources[dataSourceId]) || null;

const handleConnectionChange = React.useCallback((newConnectionId) => {
const handleConnectionChange = React.useCallback((newConnectionId: NodeId | null) => {
setInput((existing) =>
update(existing, {
attributes: update(existing.attributes, {
connectionId: appDom.createConst(newConnectionId),
connectionId: newConnectionId ? appDom.createConst(newConnectionId) : undefined,
}),
}),
);
Expand Down Expand Up @@ -446,7 +446,7 @@ export default function QueryEditor() {
}, []);

const handleCreated = React.useCallback(
(node) => {
(node: appDom.QueryNode) => {
domApi.addNode(node, page, 'queries');
setDialogState({ nodeId: node.id });
},
Expand Down
2 changes: 1 addition & 1 deletion packages/toolpad-app/src/components/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const Anchor = styled('a')({});

interface NextLinkComposedProps
extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'href'>,
Omit<NextLinkProps, 'href' | 'as'> {
Omit<NextLinkProps, 'href' | 'as' | 'onClick' | 'onMouseEnter'> {
to: NextLinkProps['href'];
linkAs?: NextLinkProps['as'];
href?: NextLinkProps['href'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function QueryEditor({
);

const handleSpreadsheetChange = React.useCallback(
(event, newValue: GoogleDriveFile | null) => {
(event: React.SyntheticEvent<Element, Event>, newValue: GoogleDriveFile | null) => {
const query: GoogleSheetsApiQuery = {
...value.query,
sheetName: null,
Expand All @@ -77,7 +77,7 @@ function QueryEditor({
);

const handleSheetChange = React.useCallback(
(event, newValue: GoogleSheet | null) => {
(event: React.SyntheticEvent<Element, Event>, newValue: GoogleSheet | null) => {
const query: GoogleSheetsApiQuery = {
...value.query,
sheetName: newValue?.properties?.title ?? null,
Expand Down
3 changes: 2 additions & 1 deletion packages/toolpad-components/src/DataGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
gridColumnsTotalWidthSelector,
gridColumnPositionsSelector,
gridDensityRowHeightSelector,
GridSelectionModel,
} from '@mui/x-data-grid-pro';
import * as React from 'react';
import { useNode, createComponent } from '@mui/toolpad-core';
Expand Down Expand Up @@ -241,7 +242,7 @@ const DataGridComponent = React.forwardRef(function DataGridComponent(
);

const onSelectionModelChange = React.useCallback(
(ids) => {
(ids: GridSelectionModel) => {
onSelectionChange(ids.length > 0 ? rows.find((row) => row.id === ids[0]) : null);
},
[rows, onSelectionChange],
Expand Down
4 changes: 2 additions & 2 deletions packages/toolpad-core/src/runtime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ function PlaceholderWrapper(props: PlaceholderWrapperProps) {
export interface NodeRuntimeWrapperProps {
children: React.ReactElement;
nodeId: string;
componentConfig: ComponentConfig<unknown>;
componentConfig: ComponentConfig<any>;
}

export interface NodeFiberHostProps {
children: React.ReactElement;
[RUNTIME_PROP_NODE_ID]: string;
componentConfig: ComponentConfig<unknown>;
componentConfig: ComponentConfig<any>;
nodeError?: RuntimeError | null;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/toolpad-core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export type BindableAttrValue<V> =
export type ConstantAttrValues<P> = { [K in keyof P]: ConstantAttrValue<P[K]> };

export type BindableAttrValues<P> = {
readonly [K in keyof P]?: BindableAttrValue<P[K]>;
readonly [K in keyof P & string]?: BindableAttrValue<P[K]>;
};

export type SlotType = 'single' | 'multiple';
Expand Down