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

Exclude mocks and Cypress specs from eui.d.ts #5412

Merged
merged 2 commits into from
Nov 24, 2021

Conversation

cee-chen
Copy link
Member

@cee-chen cee-chen commented Nov 24, 2021

Summary

Per @1Copenut's upgrade Kibana PR (elastic/kibana#119205), the checks step is failing with this error:

ERROR Type check failed in test/tsconfig.json:
ERROR node_modules/@elastic/eui/eui.d.ts:17870:31 - error TS2503: Cannot find namespace 'jest'.

It looks like there's a TypeScript export issue that I traced back to row_height_utils.ts (datagrid mock) and line 17,864 of the eui.d.ts definitions file.

Mocks should not be exported in our eui.d.ts file, nor should any other test files. I've updated our dtsgenerator.js config to exclude all possible mocks, as well as Cypress spec files just in case.

Checklist

  • Test against local Kibana somehow before patch release??

Copy link
Contributor

@thompsongl thompsongl left a comment

Choose a reason for hiding this comment

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

Confirmed locally that eui.d.ts does not contain any mock or spec files (and therefore no jest), and compared to main which does have mock file references.

@thompsongl
Copy link
Contributor

Test against local Kibana somehow before patch release??

You could use the upgrade PR branch and just replace the eui.d.ts and run the type check. Shouldn't even need a full EUI build.

@cee-chen
Copy link
Member Author

I can confirm that on latest main's eui.d.ts I can Ctrl+F for jest and find the __mocks__/row_height_utils file:

On this branch when I run node scripts/dtsgenerator.js, the above lines are now gone. I additinally do not see any .test.* or testenv files still so I think my file extension glob change is also safe.

@cee-chen
Copy link
Member Author

Haha, Greg's 2 fast and 2 furious

@cee-chen
Copy link
Member Author

You could use the upgrade PR branch and just replace the eui.d.ts and run the type check. Shouldn't even need a full EUI build.

Bootstrapping the upgrade PR branch now, may take a while. If we're confident this works and would rather start the patch release process now I'm good with it

Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

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

Edit: beat by Greg! ❤️

Confirmed mentions of mock are gone from eui.d.ts after running the dtsgenerator script. Spot checked the ts+tsx->{ts,tsx} format change works as intended.

Test against local Kibana somehow before patch release??

For this I usually copy & paste the generated eui.d.ts into Kibana's node_modules/@elastic/eui/eui.d.ts and run the type checker.

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5412/

@cee-chen
Copy link
Member Author

OK, pasted eui.d.ts and ran node scripts/type_check in Kibana and the 4 ts projs that are failing in Trevor's PR are passing locally.

(Unrelated: I saw type failures related to my EuiCodeBlock refactor which I'll shortly push up a fix for - it's in unreleased main and not in the 41.2 release so should be fine to not include in the patch).

@cee-chen cee-chen merged commit 32ca558 into elastic:main Nov 24, 2021
@cee-chen cee-chen deleted the fix-type-exports branch November 24, 2021 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants