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 types to Tip #26173

Merged
merged 3 commits into from
Oct 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions packages/components/src/tip/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
/**
* Internal dependencies
* WordPress dependencies
*/
import { SVG, Path } from '../';
import { SVG, Path } from '@wordpress/primitives';
Comment on lines -2 to +4
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed this to make it possible to add types to Tip. Is there a reason why we weren't importing this directly from primitives?


/**
* @typedef Props
* @property {import('react').ReactNode} children Children to render in the tip.
*/

/**
* @param {Props} props
* @return {JSX.Element} Element
*/
function Tip( props ) {
return (
<div className="components-tip">
Expand Down
8 changes: 3 additions & 5 deletions packages/components/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"rootDir": "src",
"declarationDir": "build-types",
"declarationDir": "build-types"
},
"references": [],
"include": [
"src/dashicon/*"
],
"references": [ { "path": "../primitives" } ],
Copy link
Member

Choose a reason for hiding this comment

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

We have to add references so TypeScript can figure out the build order properly. It’s the one “gotcha” to the setup

We would want this for all the monorepo packages this package depends on, but we have a problem where this isn't a "leaf" package so we need to add them as we need them.

This should fix the test issues that appeared on this branch.

Copy link
Member

Choose a reason for hiding this comment

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

We need to add one for @wordpress/element as well. We could add all the packages that have opted-in to typing and appear in this package`s package.json.

"include": [ "src/dashicon/*", "src/tip/*" ]
}