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(typescript): rename index.js to index.ts to expose some components #14358

Merged
merged 2 commits into from
Aug 4, 2023

Conversation

haocheng6
Copy link
Contributor

@haocheng6 haocheng6 commented Jul 31, 2023

Closes #14165

Changelog

Changed

  • Rename several index.js files to index.ts to make sure export statements in node_modules/@carbon/react/lib/index.d.ts of a TS React project can be resolved by the TypeScript compiler. (Reference: How TypeScript resolves modules)

(Note: This PR renames index.js files that only reference TS files. There are still many components that cannot be imported in a TS project. Fixing the problem for all components in a single PR may lead to a huge PR which would be hard to test and review, so I only fix the easiest ones in this PR.)

Testing / Reviewing

  • CI should pass.
  • Existing stories should work the same as before.
  • Manually verify the library built on the new code exposes components like DatePickerInput by following the steps below.
    • Build the project: yarn build
    • Create a new TypeScript React project: npx create-react-app test-carbon-import-ts --template typescript
    • In the newly created project, install @carbon/react: npm i @carbon/react
    • Copy the built lib to the new project (replace the path to the path on your machine): cp -r /root/my-fork/carbon/packages/react/lib /root/tmp/test-carbon-import-ts/node_modules/@carbon/react/
    • Add the following code snippet to src/App.tsx in the new project and verify those components are imported correctly.
import {
  ComboBox,
  DatePickerInput,
  ExpandableSearch,
  FileUploader,
  Filename,
  FileUploaderSkeleton,
  FileUploaderButton,
  FileUploaderDropContainer,
  FileUploaderItem,
  FormGroup,
  Loading,
  NumberInputSkeleton,
  NumberInput,
  OverflowMenuItem,
  RadioButton,
  RadioButtonGroup,
  SelectSkeleton,
  Select,
  SelectItem,
  SelectItemGroup,
  TimePicker,
  TimePickerSelect,
} from "@carbon/react";

@haocheng6 haocheng6 requested a review from a team as a code owner July 31, 2023 23:21
@netlify
Copy link

netlify bot commented Jul 31, 2023

Deploy Preview for carbon-components-react ready!

Name Link
🔨 Latest commit 1b87e3f
🔍 Latest deploy log https://app.netlify.com/sites/carbon-components-react/deploys/64c9365967a0df0008215f11
😎 Deploy Preview https://deploy-preview-14358--carbon-components-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link

netlify bot commented Jul 31, 2023

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit 1b87e3f
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/64c93659b66911000821a272
😎 Deploy Preview https://deploy-preview-14358--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member

@tay1orjones tay1orjones left a comment

Choose a reason for hiding this comment

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

Thanks for this!

@tw15egan tw15egan added this pull request to the merge queue Aug 4, 2023
Merged via the queue into carbon-design-system:main with commit f389dfa Aug 4, 2023
@haocheng6 haocheng6 deleted the 14165-rename-index-js branch August 4, 2023 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: DatePickerInput cannot find in react typescript project
4 participants