Skip to content

Commit edfa858

Browse files
Merge pull request opendatahub-io#1637 from christianvogt/no-implicit-any
set frontend tsconfig noImplicitAny = true and fix up all errors
2 parents c0b4348 + 77b57e5 commit edfa858

File tree

69 files changed

+197
-170
lines changed

Some content is hidden

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

69 files changed

+197
-170
lines changed

frontend/jest.config.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,8 @@ module.exports = {
2323
testEnvironment: 'jest-environment-jsdom',
2424

2525
// include projects from node_modules as required
26-
transformIgnorePatterns: [
27-
'node_modules/(?!yaml)',
28-
],
26+
transformIgnorePatterns: ['node_modules/(?!yaml)'],
2927

3028
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
3129
snapshotSerializers: [],
32-
3330
};

frontend/package-lock.json

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@
7777
},
7878
"devDependencies": {
7979
"@babel/core": "^7.21.0",
80+
"@types/dompurify": "^2.2.6",
81+
"@types/lodash-es": "^4.17.8",
8082
"@types/node": "^17.0.29",
8183
"@types/react": "^18.0.24",
8284
"@types/react-dom": "^18.0.8",

frontend/src/__tests__/integration/pages/clusterSettings/ClusterSettings.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { Meta, StoryFn } from '@storybook/react';
2+
import { Meta, StoryFn, StoryObj } from '@storybook/react';
33
import { rest } from 'msw';
44
import { within } from '@storybook/testing-library';
55
import { mockClusterSettings } from '~/__mocks__/mockClusterSettings';
@@ -20,7 +20,7 @@ export default {
2020

2121
const Template: StoryFn<typeof ClusterSettings> = (args) => <ClusterSettings {...args} />;
2222

23-
export const Default = {
23+
export const Default: StoryObj = {
2424
render: Template,
2525

2626
play: async ({ canvasElement }) => {

frontend/src/__tests__/integration/pages/modelServing/ModelServingGlobal.stories.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22

3-
import { StoryFn, Meta } from '@storybook/react';
3+
import { StoryFn, Meta, StoryObj } from '@storybook/react';
44
import { rest } from 'msw';
55
import { within, userEvent } from '@storybook/testing-library';
66
import { expect } from '@storybook/jest';
@@ -51,7 +51,7 @@ const Template: StoryFn<typeof ModelServingGlobal> = (args) => (
5151
</Routes>
5252
);
5353

54-
export const EditModel = {
54+
export const EditModel: StoryObj = {
5555
render: Template,
5656

5757
parameters: {
@@ -72,7 +72,7 @@ export const EditModel = {
7272
},
7373
};
7474

75-
export const DeleteModel = {
75+
export const DeleteModel: StoryObj = {
7676
render: Template,
7777

7878
parameters: {
@@ -92,7 +92,7 @@ export const DeleteModel = {
9292
},
9393
};
9494

95-
export const DeployModel = {
95+
export const DeployModel: StoryObj = {
9696
render: Template,
9797

9898
parameters: {

frontend/src/__tests__/integration/pages/modelServing/ServingRuntimeList.stories.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22

3-
import { StoryFn, Meta } from '@storybook/react';
3+
import { StoryFn, Meta, StoryObj } from '@storybook/react';
44
import { rest } from 'msw';
55
import { userEvent, within } from '@storybook/testing-library';
66
import { Route } from 'react-router-dom';
@@ -130,7 +130,7 @@ const Template: StoryFn<typeof ServingRuntimeList> = (args) => {
130130
);
131131
};
132132

133-
export const ListAvailableModels = {
133+
export const ListAvailableModels: StoryObj = {
134134
render: Template,
135135

136136
play: async ({ canvasElement }) => {
@@ -141,7 +141,7 @@ export const ListAvailableModels = {
141141
},
142142
};
143143

144-
export const DeployModel = {
144+
export const DeployModel: StoryObj = {
145145
render: Template,
146146

147147
play: async ({ canvasElement }) => {

frontend/src/__tests__/integration/pages/projects/ProjectDetails.stories.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { StoryFn, Meta } from '@storybook/react';
2+
import { StoryFn, Meta, StoryObj } from '@storybook/react';
33
import { DefaultBodyType, MockedRequest, rest, RestHandler } from 'msw';
44
import { within } from '@storybook/testing-library';
55
import { Route } from 'react-router-dom';
@@ -151,7 +151,7 @@ const Template: StoryFn<typeof ProjectDetails> = (args) => {
151151
);
152152
};
153153

154-
export const Default = {
154+
export const Default: StoryObj = {
155155
render: Template,
156156
play: async ({ canvasElement }) => {
157157
// load page and wait until settled
@@ -160,7 +160,7 @@ export const Default = {
160160
},
161161
};
162162

163-
export const EmptyDetailsPage = {
163+
export const EmptyDetailsPage: StoryObj = {
164164
render: Template,
165165

166166
parameters: {

frontend/src/__tests__/integration/pages/projects/ProjectView.stories.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Meta } from '@storybook/react';
1+
import { Meta, StoryObj } from '@storybook/react';
22
import { rest } from 'msw';
33
import { within, userEvent } from '@storybook/testing-library';
44
import { mockProjectK8sResource } from '~/__mocks__/mockProjectK8sResource';
@@ -45,7 +45,7 @@ export default {
4545
},
4646
} as Meta<typeof ProjectView>;
4747

48-
export const EditProject = {
48+
export const EditProject: StoryObj = {
4949
parameters: {
5050
a11y: {
5151
// need to select modal as root
@@ -64,7 +64,7 @@ export const EditProject = {
6464
},
6565
};
6666

67-
export const DeleteProject = {
67+
export const DeleteProject: StoryObj = {
6868
parameters: {
6969
a11y: {
7070
element: '.pf-c-backdrop',
@@ -82,7 +82,7 @@ export const DeleteProject = {
8282
},
8383
};
8484

85-
export const CreateProject = {
85+
export const CreateProject: StoryObj = {
8686
parameters: {
8787
a11y: {
8888
element: '.pf-c-backdrop',

frontend/src/api/k8s/projects.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,17 @@ export const createProject = (
9595
export const getModelServingProjects = (): Promise<ProjectKind[]> =>
9696
getProjects(`${LABEL_SELECTOR_DASHBOARD_RESOURCE},${LABEL_SELECTOR_MODEL_SERVING_PROJECT}`);
9797

98-
async function filter(arr, callback) {
98+
const filter = async (arr: ProjectKind[], callback: (project: ProjectKind) => Promise<boolean>) => {
9999
const fail = Symbol();
100+
const isProject = (i: ProjectKind | typeof fail): i is ProjectKind => i !== fail;
100101
return (
101102
await Promise.all(arr.map(async (item) => ((await callback(item)) ? item : fail)))
102-
).filter((i) => i !== fail);
103-
}
103+
).filter(isProject);
104+
};
104105

105106
export const getModelServingProjectsAvailable = async (): Promise<ProjectKind[]> =>
106107
getModelServingProjects().then((projects) =>
107-
filter(projects, async (project) => {
108+
filter(projects, async (project: ProjectKind) => {
108109
const projectServing = await listServingRuntimes(project.metadata.name);
109110
return projectServing.length !== 0;
110111
}),

frontend/src/api/k8s/secrets.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ export const assembleSecret = (
1919
type: 'aws' | 'generic' = 'generic',
2020
secretName?: string,
2121
): SecretKind => {
22-
const labels = {
22+
const labels: Record<string, string> = {
2323
[KnownLabels.DASHBOARD_RESOURCE]: 'true',
2424
};
25-
const annotations = {};
25+
const annotations: Record<string, string> = {};
2626

2727
let stringData = data;
2828
let name = `secret-${genRandomChars()}`;

0 commit comments

Comments
 (0)