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

Fix type errors from Saved Object Management changes #3023

Open
tmarkley opened this issue Dec 4, 2022 · 3 comments · May be fixed by #3987
Open

Fix type errors from Saved Object Management changes #3023

tmarkley opened this issue Dec 4, 2022 · 3 comments · May be fixed by #3987
Assignees
Labels
good first issue Good for newcomers help wanted Community development is encouraged technical debt If not paid, jeapardizes long-term success and maintainability of the repository. typescript

Comments

@tmarkley
Copy link
Contributor

tmarkley commented Dec 4, 2022

Task for #1660

PR: #2656 (and some before it)

Code owners and PR reviewers, can you help address this?
@cwperks @kavilla @kristenTian @ashwin-pc @zengyan-amazon @joshuarrrr @zhongnansu

$ tsc --noEmit
...

src/plugins/saved_objects_management/public/lib/get_relationships.ts:52:68 - error TS18046: 'respError' is of type 'unknown'.

52     const err = new Error(respBody.message || respBody.error || `${respError.status} Response`);
                                                                      ~~~~~~~~~

src/plugins/saved_objects_management/public/lib/get_relationships.ts:54:54 - error TS18046: 'respError' is of type 'unknown'.

54     (err as any).statusCode = respBody.statusCode || respError.status;
                                                        ~~~~~~~~~

src/plugins/saved_objects_management/public/lib/parse_query.test.ts:37:25 - error TS7006: Parameter 'field' implicitly has an 'any' type.

37       getFieldClauses: (field) => {
                           ~~~~~

src/plugins/saved_objects_management/public/lib/parse_query.test.ts:46:39 - error TS2554: Expected 1 arguments, but got 2.

46     expect(parseQuery({ ast } as any, ['type'])).toEqual({
                                         ~~~~~~~~

src/plugins/saved_objects_management/public/lib/parse_query.ts:61:5 - error TS2322: Type '{ queryText: string | undefined; visibleTypes: string[] | undefined; visibleNamespaces: string[] | undefined; }' is not assignable to type 'ParsedQuery'.
  Object literal may only specify known properties, and 'visibleNamespaces' does not exist in type 'ParsedQuery'.

61     visibleNamespaces,
       ~~~~~~~~~~~~~~~~~

src/plugins/saved_objects_management/public/management_section/objects_table/components/overwrite_modal.test.tsx:34:33 - error TS2306: File '/workspaces/OpenSearch-Dashboards/node_modules/@elastic/eui/lib/test/index.d.ts' is not a module.

34 import { findTestSubject } from '@elastic/eui/lib/test';
                                   ~~~~~~~~~~~~~~~~~~~~~~~

src/plugins/saved_objects_management/public/management_section/objects_table/components/table.test.tsx:33:33 - error TS2306: File '/workspaces/OpenSearch-Dashboards/node_modules/@elastic/eui/lib/test/index.d.ts' is not a module.

33 import { findTestSubject } from '@elastic/eui/lib/test';
                                   ~~~~~~~~~~~~~~~~~~~~~~~

src/plugins/saved_objects_management/public/management_section/objects_table/components/table.test.tsx:41:7 - error TS2739: Type '{ basePath: IBasePath & BasePath; actionRegistry: Mocked<SavedObjectsManagementActionServiceStart>; ... 18 more ...; canDelete: true; }' is missing the following properties from type 'TableProps': namespaceRegistry, dateFormat

41 const defaultProps: TableProps = {
         ~~~~~~~~~~~~

src/plugins/saved_objects_management/public/management_section/objects_table/components/table.tsx:64:22 - error TS2552: Cannot find name 'SavedObjectsManagementNamespaceServiceStart'. Did you mean 'SavedObjectsManagementActionServiceStart'?

64   namespaceRegistry: SavedObjectsManagementNamespaceServiceStart;
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/plugins/saved_objects_management/public/management_section/objects_table/components/table.tsx:133:16 - error TS2554: Expected 2 arguments, but got 1.

133     this.props.onQueryChange({ query });
                   ~~~~~~~~~~~~~~~~~~~~~~~~

  src/plugins/saved_objects_management/public/management_section/objects_table/components/table.tsx:80:31
    80   onQueryChange: (query: any, filterFields: string[]) => void;
                                     ~~~~~~~~~~~~~~~~~~~~~~
    An argument for 'filterFields' was not provided.

src/plugins/saved_objects_management/public/management_section/objects_table/components/table.tsx:178:7 - error TS6133: 'namespaceRegistry' is declared but its value is never read.

178       namespaceRegistry,
          ~~~~~~~~~~~~~~~~~

src/plugins/saved_objects_management/public/management_section/objects_table/saved_objects_table.test.tsx:148:5 - error TS2741: Property 'dateFormat' is missing in type '{ allowedTypes: string[]; serviceRegistry: jest.Mocked<ISavedObjectsManagementServiceRegistry>; actionRegistry: jest.Mocked<SavedObjectsManagementActionServiceStart>; ... 11 more ...; search: ISearchStart; }' but required in type 'SavedObjectsTableProps'.

148     defaultProps = {
        ~~~~~~~~~~~~

  src/plugins/saved_objects_management/public/management_section/objects_table/saved_objects_table.tsx:116:3
    116   dateFormat: string;
          ~~~~~~~~~~
    'dateFormat' is declared here.

src/plugins/saved_objects_management/public/management_section/objects_table/saved_objects_table.tsx:184:38 - error TS2339: Property 'visibleNamespaces' does not exist on type 'ParsedQuery'.

184     const { queryText, visibleTypes, visibleNamespaces } = parseQuery(this.state.activeQuery);
                                         ~~~~~~~~~~~~~~~~~

src/plugins/saved_objects_management/public/management_section/objects_table/saved_objects_table.tsx:215:26 - error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'.
  No index signature with a parameter of type 'string' was found on type '{}'.

215         label: `${id} (${filteredTypeCounts[id] || 0})`,
                             ~~~~~~~~~~~~~~~~~~~~~~

src/plugins/saved_objects_management/public/management_section/objects_table/saved_objects_table.tsx:254:38 - error TS2339: Property 'visibleNamespaces' does not exist on type 'ParsedQuery'.

254     const { queryText, visibleTypes, visibleNamespaces } = parseQuery(query);
                                         ~~~~~~~~~~~~~~~~~

src/plugins/saved_objects_management/public/management_section/objects_table/saved_objects_table.tsx:810:25 - error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'.
  No index signature with a parameter of type 'string' was found on type '{}'.

810       view: `${type} (${typeCounts[type] || 0})`,
                            ~~~~~~~~~~~~~~~~

src/plugins/saved_objects_management/public/management_section/objects_table/saved_objects_table.tsx:832:32 - error TS7053: Element implicitly has an 'any' type because expression of type 'any' can't be used to index type '{}'.

832           view: `${ns.name} (${nsCounts[ns.id] || 0})`,
                                   ~~~~~~~~~~~~~~~

src/plugins/saved_objects_management/public/management_section/objects_table/saved_objects_table.tsx:863:12 - error TS2741: Property 'namespaceRegistry' is missing in type '{ basePath: IBasePath; itemId: string; actionRegistry: SavedObjectsManagementActionServiceStart; columnRegistry: SavedObjectsManagementColumnServiceStart; ... 17 more ...; dateFormat: string; }' but required in type 'Readonly<TableProps>'.

863           <Table
               ~~~~~

  src/plugins/saved_objects_management/public/management_section/objects_table/components/table.tsx:64:3
    64   namespaceRegistry: SavedObjectsManagementNamespaceServiceStart;
         ~~~~~~~~~~~~~~~~~
    'namespaceRegistry' is declared here.

src/plugins/saved_objects_management/public/management_section/saved_objects_table_page.tsx:59:22 - error TS2552: Cannot find name 'SavedObjectsManagementNamespaceServiceStart'. Did you mean 'SavedObjectsManagementActionServiceStart'?

59   namespaceRegistry: SavedObjectsManagementNamespaceServiceStart;
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/plugins/saved_objects_management/public/mocks.ts:42:3 - error TS2322: Type '{ actions: jest.Mocked<SavedObjectsManagementActionServiceSetup>; columns: jest.Mocked<SavedObjectsManagementColumnServiceSetup>; serviceRegistry: jest.Mocked<...>; }' is not assignable to type 'Mocked<SavedObjectsManagementPluginSetup>'.
  Property 'namespaces' is missing in type '{ actions: jest.Mocked<SavedObjectsManagementActionServiceSetup>; columns: jest.Mocked<SavedObjectsManagementColumnServiceSetup>; serviceRegistry: jest.Mocked<...>; }' but required in type '{ actions: SavedObjectsManagementActionServiceSetup; columns: SavedObjectsManagementColumnServiceSetup; namespaces: SavedObjectsManagementNamespaceServiceSetup; serviceRegistry: ISavedObjectsManagementServiceRegistry; }'.

42   return mock;
     ~~~~~~~~~~~~

  src/plugins/saved_objects_management/public/plugin.ts:59:3
    59   namespaces: SavedObjectsManagementNamespaceServiceSetup;
         ~~~~~~~~~~
    'namespaces' is declared here.

src/plugins/saved_objects_management/public/mocks.ts:50:3 - error TS2322: Type '{ actions: jest.Mocked<SavedObjectsManagementActionServiceStart>; columns: jest.Mocked<SavedObjectsManagementColumnServiceStart>; }' is not assignable to type 'Mocked<SavedObjectsManagementPluginStart>'.
  Property 'namespaces' is missing in type '{ actions: jest.Mocked<SavedObjectsManagementActionServiceStart>; columns: jest.Mocked<SavedObjectsManagementColumnServiceStart>; }' but required in type '{ actions: SavedObjectsManagementActionServiceStart; columns: SavedObjectsManagementColumnServiceStart; namespaces: SavedObjectsManagementNamespaceServiceStart; }'.

50   return mock;
     ~~~~~~~~~~~~

  src/plugins/saved_objects_management/public/plugin.ts:66:3
    66   namespaces: SavedObjectsManagementNamespaceServiceStart;
         ~~~~~~~~~~
    'namespaces' is declared here.

src/plugins/saved_objects_management/public/services/index.ts:54:3 - error TS2724: '"./types"' has no exported member named 'SavedObjectsManagementNamespace'. Did you mean 'SavedObjectsManagementRecord'?

54   SavedObjectsManagementNamespace,
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/plugins/saved_objects_management/public/services/namespace_service.ts:12:10 - error TS2724: '"./types"' has no exported member named 'SavedObjectsManagementNamespace'. Did you mean 'SavedObjectsManagementRecord'?

12 import { SavedObjectsManagementNamespace } from './types';
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/plugins/saved_objects_management/public/services/namespace_service.ts:32:20 - error TS7008: Member 'alias' implicitly has an 'any' type.

32   private readonly alias;
                      ~~~~~

src/plugins/saved_objects_management/public/services/namespace_service.ts:48:14 - error TS2540: Cannot assign to 'alias' because it is a read-only property.

48         this.alias = alias;
                ~~~~~

src/plugins/saved_objects_management/server/routes/find.ts:87:51 - error TS2345: Argument of type '{ fields: undefined; searchFields: string[]; search?: string | undefined; namespaces?: string | string[] | undefined; sortField?: string | undefined; hasReference?: Readonly<{} & { id: string; type: string; }> | undefined; page: number; type: string | string[]; perPage: number; defaultSearchOperator: "AND" | "OR"; }' is not assignable to parameter of type 'SavedObjectsFindOptions'.
  Types of property 'namespaces' are incompatible.
    Type 'string | string[] | undefined' is not assignable to type 'string[] | undefined'.
      Type 'string' is not assignable to type 'string[]'.

 87       const findResponse = await client.find<any>({
                                                      ~
 88         ...req.query,
    ~~~~~~~~~~~~~~~~~~~~~
... 
 90         searchFields: [...searchFields],
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 91       });
    ~~~~~~~

src/plugins/saved_objects_management/server/routes/scroll_count.ts:62:16 - error TS2339: Property 'namespaces' does not exist on type '{ type: {}; }'.

62         counts.namespaces = {};
                  ~~~~~~~~~~

src/plugins/saved_objects_management/server/routes/scroll_count.ts:81:20 - error TS2339: Property 'namespaces' does not exist on type '{ type: {}; }'.

81             counts.namespaces[ns] = counts.namespaces[ns] || 0;
                      ~~~~~~~~~~

src/plugins/saved_objects_management/server/routes/scroll_count.ts:81:44 - error TS2339: Property 'namespaces' does not exist on type '{ type: {}; }'.

81             counts.namespaces[ns] = counts.namespaces[ns] || 0;
                                              ~~~~~~~~~~

src/plugins/saved_objects_management/server/routes/scroll_count.ts:82:20 - error TS2339: Property 'namespaces' does not exist on type '{ type: {}; }'.

82             counts.namespaces[ns]++;
                      ~~~~~~~~~~

src/plugins/saved_objects_management/server/routes/scroll_count.ts:85:9 - error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'.
  No index signature with a parameter of type 'string' was found on type '{}'.

85         counts.type[type] = counts.type[type] || 0;
           ~~~~~~~~~~~~~~~~~

src/plugins/saved_objects_management/server/routes/scroll_count.ts:85:29 - error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'.
  No index signature with a parameter of type 'string' was found on type '{}'.

85         counts.type[type] = counts.type[type] || 0;
                               ~~~~~~~~~~~~~~~~~

src/plugins/saved_objects_management/server/routes/scroll_count.ts:86:9 - error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'.
  No index signature with a parameter of type 'string' was found on type '{}'.

86         counts.type[type]++;
           ~~~~~~~~~~~~~~~~~

src/plugins/saved_objects_management/server/routes/scroll_count.ts:90:14 - error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'.
  No index signature with a parameter of type 'string' was found on type '{}'.

90         if (!counts.type[type]) {
                ~~~~~~~~~~~~~~~~~

src/plugins/saved_objects_management/server/routes/scroll_count.ts:91:11 - error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'.
  No index signature with a parameter of type 'string' was found on type '{}'.

91           counts.type[type] = 0;
             ~~~~~~~~~~~~~~~~~

src/plugins/saved_objects_management/server/routes/scroll_count.ts:97:21 - error TS2339: Property 'namespaces' does not exist on type '{ type: {}; }'.

97         if (!counts.namespaces[ns]) {
                       ~~~~~~~~~~

src/plugins/saved_objects_management/server/routes/scroll_count.ts:98:18 - error TS2339: Property 'namespaces' does not exist on type '{ type: {}; }'.

98           counts.namespaces[ns] = 0;
                    ~~~~~~~~~~

@joshuarrrr joshuarrrr added untriaged typescript technical debt If not paid, jeapardizes long-term success and maintainability of the repository. good first issue Good for newcomers help wanted Community development is encouraged and removed untriaged labels Dec 5, 2022
@joshuarrrr
Copy link
Member

@tmarkley Thanks for breaking this task up into achievable chunks. I've marked this as a good first issue, because most typescript errors can be addressed with only localized knowledge of the target files.

@Nicksqain
Copy link
Contributor

@joshuarrrr I'm already solving that problem. Could you sign me up?

@joshuarrrr
Copy link
Member

Sure, you've got it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Community development is encouraged technical debt If not paid, jeapardizes long-term success and maintainability of the repository. typescript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants