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

Add tsconfig for url_forwarding #81177

Merged
merged 19 commits into from
Oct 27, 2020
Merged

Conversation

smith
Copy link
Contributor

@smith smith commented Oct 20, 2020

Also:

  • Add missing entry in tsconfig.refs.json for kibana_legacy, as a follow-up to Add TS config for kibana_legacy #80992.
  • Add missing .d.ts files for kibana_legacy.
  • Explicitly import MockedKeys and DeeplyMockedKeys.
  • Add missing exclusions in x-pack/tsconfig.json.
  • Alphabetize lists.

References #80508
References #81003

Also add missing pieces to kibana_react, as a follow-up to elastic#80992.

References elastic#80508
References elastic#81003
@smith
Copy link
Contributor Author

smith commented Oct 20, 2020

I had to add a bunch of the missing exports to new .d.ts files in kibana_legacy. The errors didn't show up when. I ran tsc in kibana_legacy or in the CI checks in the top level.

When I run npx tsc from url_forwarding after adding these changes I'm still getting a bunch of errors from core:

../../core/target/types/public/chrome/chrome_service.mock.d.ts:5:32 - error TS2304: Cannot find name 'DeeplyMockedKeys'.

5     createStartContract: () => DeeplyMockedKeys<InternalChromeStart>;
                                 ~~~~~~~~~~~~~~~~

../../core/target/types/public/mocks.d.ts:26:17 - error TS2304: Cannot find name 'DeeplyMockedKeys'.

26         chrome: DeeplyMockedKeys<import("./chrome").InternalChromeStart>;
                   ~~~~~~~~~~~~~~~~

../../core/target/types/public/mocks.d.ts:30:24 - error TS2304: Cannot find name 'MockedKeys'.

30         notifications: MockedKeys<import(".").NotificationsStart>;
                          ~~~~~~~~~~

../../core/target/types/public/mocks.d.ts:31:19 - error TS2304: Cannot find name 'DeeplyMockedKeys'.

31         overlays: DeeplyMockedKeys<import(".").OverlayStart>;
                     ~~~~~~~~~~~~~~~~

../../core/target/types/public/mocks.d.ts:40:20 - error TS2304: Cannot find name 'MockedKeys'.

40     notifications: MockedKeys<import(".").NotificationsSetup>;
                      ~~~~~~~~~~

../../core/target/types/public/mocks.d.ts:50:13 - error TS2304: Cannot find name 'DeeplyMockedKeys'.

50     chrome: DeeplyMockedKeys<import("./chrome").InternalChromeStart>;
               ~~~~~~~~~~~~~~~~

../../core/target/types/public/mocks.d.ts:54:20 - error TS2304: Cannot find name 'MockedKeys'.

54     notifications: MockedKeys<import(".").NotificationsStart>;
                      ~~~~~~~~~~

../../core/target/types/public/mocks.d.ts:55:15 - error TS2304: Cannot find name 'DeeplyMockedKeys'.

55     overlays: DeeplyMockedKeys<import(".").OverlayStart>;
                 ~~~~~~~~~~~~~~~~

../../core/target/types/public/notifications/notifications_service.mock.d.ts:5:32 - error TS2304: Cannot find name 'MockedKeys'.

5     createSetupContract: () => MockedKeys<NotificationsSetup>;
                                 ~~~~~~~~~~

../../core/target/types/public/notifications/notifications_service.mock.d.ts:6:32 - error TS2304: Cannot find name 'MockedKeys'.

6     createStartContract: () => MockedKeys<NotificationsStart>;
                                 ~~~~~~~~~~

../../core/target/types/public/overlays/overlay_service.mock.d.ts:5:32 - error TS2304: Cannot find name 'DeeplyMockedKeys'.

5     createStartContract: () => DeeplyMockedKeys<OverlayStart>;
                                 ~~~~~~~~~~~~~~~~

../../core/target/types/server/elasticsearch/elasticsearch_service.d.ts:4:33 - error TS2307: Cannot find module '../audit_trail' or its corresponding type declarations.

4 import { AuditTrailStart } from '../audit_trail';
                                  ~~~~~~~~~~~~~~~~

../../core/target/types/server/elasticsearch/legacy/cluster_client.d.ts:2:32 - error TS2307: Cannot find module '../../audit_trail' or its corresponding type declarations.

2 import { AuditorFactory } from '../../audit_trail';
                                 ~~~~~~~~~~~~~~~~~~~

../../core/target/types/server/elasticsearch/legacy/scoped_cluster_client.d.ts:1:25 - error TS2307: Cannot find module '../../audit_trail' or its corresponding type declarations.

1 import { Auditor } from '../../audit_trail';
                          ~~~~~~~~~~~~~~~~~~~

../../core/target/types/server/index.d.ts:34:59 - error TS2307: Cannot find module './audit_trail' or its corresponding type declarations.

34 import { Auditor, AuditTrailSetup, AuditTrailStart } from './audit_trail';
                                                             ~~~~~~~~~~~~~~~

../../core/target/types/server/index.d.ts:39:74 - error TS2307: Cannot find module './audit_trail' or its corresponding type declarations.

39 export { AuditableEvent, Auditor, AuditorFactory, AuditTrailSetup } from './audit_trail';
                                                                            ~~~~~~~~~~~~~~~

../../core/target/types/server/internal_types.d.ts:14:50 - error TS2307: Cannot find module './audit_trail' or its corresponding type declarations.

14 import { AuditTrailSetup, AuditTrailStart } from './audit_trail';
                                                    ~~~~~~~~~~~~~~~


Found 17 errors.

Do I have an incorrect path or missing compiler option or do we need to add missing .d.ts for all the projects that reference them?

The files failing with MockedKeys and DeeplyMockedKeys have /// <reference types="jest" />. There's a jest.d.ts in x-pack, does the contents for that need to be moved/copied to the root typings?

@mshustov
Copy link
Contributor

mshustov commented Oct 20, 2020

I don't see any errors for ./node_modules/.bin/tsc -b src/plugins/kibana_legacy/tsconfig.json
I added the next tsconfig.json for url_forwarding :

{
  "extends": "../../../tsconfig.base.json",
  "compilerOptions": {
    "composite": true,
    "outDir": "./target/types",
    "emitDeclarationOnly": true,
    "declaration": true,
    "declarationMap": true
  },
  "include": ["../../../typings/**/*", "public/**/*"],
  "references": [{
    "path": "../../core/tsconfig.json"
  }, {
    "path": "../kibana_legacy/tsconfig.json"
  }]
}

and can see only the next errors when run ./node_modules/.bin/tsc -b src/plugins/url_forwarding/tsconfig.json

src/plugins/kibana_legacy/target/types/public/angular/index.d.ts:1:39 - error TS7016: Could not find a declaration file for module './promises'. '/Users/mikhailshustov/work/kibana/src/plugins/kibana_legacy/public/angular/promises.js' implicitly has an 'any' type.

1 export { PromiseServiceCreator } from './promises';
                                        ~~~~~~~~~~~~

src/plugins/kibana_legacy/target/types/public/angular/index.d.ts:2:37 - error TS7016: Could not find a declaration file for module './watch_multi'. '/Users/mikhailshustov/work/kibana/src/plugins/kibana_legacy/public/angular/watch_multi.js' implicitly has an 'any' type.

2 export { watchMultiDecorator } from './watch_multi';
                                      ~~~~~~~~~~~~~~~

src/plugins/kibana_legacy/target/types/public/angular/index.d.ts:4:84 - error TS7016: Could not find a declaration file for module './kbn_top_nav'. '/Users/mikhailshustov/work/kibana/src/plugins/kibana_legacy/public/angular/kbn_top_nav.js' implicitly has an 'any' type.

4 export { createTopNavDirective, createTopNavHelper, loadKbnTopNavDirectives } from './kbn_top_nav';
                                                                                     ~~~~~~~~~~~~~~~

src/plugins/kibana_legacy/target/types/public/utils/index.d.ts:2:44 - error TS7016: Could not find a declaration file for module './kbn_accessible_click'. '/Users/mikhailshustov/work/kibana/src/plugins/kibana_legacy/public/utils/kbn_accessible_click.js' implicitly has an 'any' type.

2 export { KbnAccessibleClickProvider } from './kbn_accessible_click';
                                             ~~~~~~~~~~~~~~~~~~~~~~~~

src/plugins/kibana_legacy/target/types/public/utils/index.d.ts:4:45 - error TS7016: Could not find a declaration file for module './register_listen_event_listener'. '/Users/mikhailshustov/work/kibana/src/plugins/kibana_legacy/public/utils/register_listen_event_listener.js' implicitly has an 'any' type.

4 export { registerListenEventListener } from './register_listen_event_listener';
                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@smith I'm not sure what tsconfig npx tsc uses

@smith
Copy link
Contributor Author

smith commented Oct 20, 2020

@restrry ok the errors you saw are the ones I'm fixing in this PR by adding the .d.ts files to kibana_legacy. The ones I'm seeing in core must be because of something else. I assumed running tsc from a directory would default to ./tsconfig.json but I'll make sure to run it with the config explicitly from now on. Thanks!

@smith smith marked this pull request as ready for review October 26, 2020 22:55
@smith smith requested a review from a team October 26, 2020 22:55
@smith smith requested a review from a team as a code owner October 26, 2020 22:55
@smith smith added release_note:skip Skip the PR/issue when compiling release notes v7.11.0 v8.0.0 labels Oct 26, 2020
@smith
Copy link
Contributor Author

smith commented Oct 27, 2020

@elasticmachine merge upstream

smith added a commit to smith/kibana that referenced this pull request Oct 27, 2020
Currently blocked by elastic#81177 because it fails on `MockedKeys/DeeplyMockedKeys`
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a lot is going on in this PR and I don't understand half of it - focused on the KibanaApp changes, those LGTM (only adding additional types). Left a nit about a type that can be improved, but as there are many more missing and these utilities are deprecated anyway it's low priority.

IController
>>;
export const createTopNavHelper: (
options: unknown
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This is NavigationPublicPluginStart['ui']

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for that. I think I'll leave it since it's not widely used and I wanted to be as generic as possible since I'm not familiar with the code.

@smith smith merged commit d1827dc into elastic:master Oct 27, 2020
@smith smith deleted the nls/tpr_url_forwarding branch October 27, 2020 20:18
smith added a commit to smith/kibana that referenced this pull request Oct 27, 2020
Also add missing pieces to kibana_react, as a follow-up to elastic#80992.

References elastic#80508
References elastic#81003

# Conflicts:
#	tsconfig.json
smith added a commit that referenced this pull request Oct 27, 2020
Also add missing pieces to kibana_react, as a follow-up to #80992.

References #80508
References #81003
gmmorris added a commit to gmmorris/kibana that referenced this pull request Oct 28, 2020
…kibana into task-manager/lost-connectivity

* 'task-manager/lost-connectivity' of github.com:gmmorris/kibana:
  skips overview tests (elastic#81877)
  [Security Solution][Case] Fix connector's labeling (elastic#81824)
  [Maps] Fix EMS test (elastic#81856)
  [Security Solutions][Detections] - Fix bug, last response not showing for disabled rules (elastic#81783)
  skip flaky suite (elastic#81853)
  Add tsconfig for url_forwarding (elastic#81177)
  skip flaky suite (elastic#81844)
  check for server enabled (elastic#81818)
  [Seurity Solution][Case] Create case plugin client (elastic#81018)
  [Security Solutions][Detection Engine] Changes wording for threat matches and rules (elastic#81334)
  [Security Solution] critical pref bug with browser fields reducer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes v7.11.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants