Skip to content

Commit

Permalink
buncha fixes for typescript problems
Browse files Browse the repository at this point in the history
  • Loading branch information
rusackas committed Feb 15, 2024
1 parent 753ef69 commit 1605664
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 22 deletions.
5 changes: 3 additions & 2 deletions superset-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@
"@visx/axis": "^3.8.0",
"@visx/grid": "^3.5.0",
"@visx/responsive": "^3.0.0",
"@visx/scale": "^3.0.0",
"@visx/xychart": "^3.0.0",
"@visx/scale": "^3.5.0",
"@visx/tooltip": "^3.0.0",
"@visx/xychart": "^3.5.1",
"abortcontroller-polyfill": "^1.1.9",
"ace-builds": "^1.4.14",
"antd": "4.10.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ export interface LoadableRenderer<Props>
extends React.ComponentClass<Props & LoadableRendererProps>,
Loadable.LoadableComponent {}

export default function createLoadableRenderer<
Props,
Exports extends { [key: string]: any },
>(options: Loadable.OptionsWithMap<Props, Exports>): LoadableRenderer<Props> {
const LoadableRenderer = Loadable.Map(options) as LoadableRenderer<Props>;

export default function createLoadableRenderer<Props, Exports extends { [key: string]: any }>(
options: Loadable.OptionsWithMap<Props, Exports>,
): LoadableRenderer<Props> {
const LoadableRenderer = Loadable.Map<Props, Exports>(options) as LoadableRenderer<Props>;

// Extends the behavior of LoadableComponent to provide post-render listeners
class CustomLoadableRenderer extends LoadableRenderer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ interface ChartPluginConfig<
* Loaders of the form `() => import('foo')` may return esmodules
* which require the value to be extracted as `module.default`
* */
function sanitizeLoader<T>(
function sanitizeLoader<T extends object>(
loader: PromiseOrValueLoader<ValueOrModuleWithValue<T>>,
): PromiseOrValueLoader<T> {
return () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,18 @@ export default function makeApi<
...requestOptions,
method,
endpoint,
searchParams: undefined as URLSearchParams | undefined,
postPayload: undefined as FormData | undefined,
jsonPayload: undefined as JsonObject | undefined,
};
if (requestType === 'search') {
requestConfig.searchParams = payload as SupersetPayload;
requestConfig.searchParams = payload as URLSearchParams;
} else if (requestType === 'rison') {
requestConfig.endpoint = `${endpoint}?q=${rison.encode(payload)}`;
} else if (requestType === 'form') {
requestConfig.postPayload = payload as SupersetPayload;
requestConfig.postPayload = payload as FormData;
} else {
requestConfig.jsonPayload = payload as SupersetPayload;
requestConfig.jsonPayload = payload as JsonObject;
}

let result: JsonValue | Response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,7 @@ export class Switchboard {
/**
* Defines a method that can be "called" from the other side by sending an event.
*/
defineMethod<A extends {} = any, R = any>(
methodName: string,
executor: Method<A, R>,
) {
defineMethod<A extends {}, R = any>(methodName: string, executor: Method<A, R>) {
this.methods[methodName] = executor;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,7 @@ function useInstance<D extends object>(instance: TableInstance<D>) {
);

const useStickyWrap = (renderer: TableRenderer) => {
// @ts-ignore
const { width, height } =
const { width, height }: { width?: number, height?: number } =
useMountedMemo(getTableSize, [getTableSize]) || sticky;
// only change of data should trigger re-render
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,12 @@ class WordCloud extends React.PureComponent<
},
});

createEncoder = this.wordCloudEncoderFactory.createSelector();
createEncoder = (encoding?: Partial<WordCloudEncoding>) => {
const selector = this.wordCloudEncoderFactory.createSelector();

// @ts-ignore
return selector(encoding as any);
};

constructor(props: FullWordCloudProps) {
super(props);
Expand Down Expand Up @@ -158,8 +163,7 @@ class WordCloud extends React.PureComponent<
update() {
const { data, encoding } = this.props;

// @ts-ignore
const encoder = this.createEncoder(encoding);
const encoder: Encoder<WordCloudEncodingConfig> = this.createEncoder(encoding);
encoder.setDomainFromDataset(data);

const sortedData = [...data].sort(
Expand Down
3 changes: 1 addition & 2 deletions superset-frontend/src/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,7 @@ const CustomModal = ({
if (React.isValidElement(footer)) {
// If a footer component is provided inject a closeModal function
// so the footer can provide a "close" button if desired
// @ts-ignore
FooterComponent = React.cloneElement(footer, { closeModal: onHide });
FooterComponent = React.cloneElement(footer, { closeModal: onHide } as Partial<unknown>);
}
const modalFooter = isNil(FooterComponent)
? [
Expand Down

0 comments on commit 1605664

Please sign in to comment.