Skip to content

fix(typescript): rename index.js to index.ts to expose some components#14358

Merged
tw15egan merged 2 commits into
carbon-design-system:mainfrom
haocheng6:14165-rename-index-js
Aug 4, 2023
Merged

fix(typescript): rename index.js to index.ts to expose some components#14358
tw15egan merged 2 commits into
carbon-design-system:mainfrom
haocheng6:14165-rename-index-js

Conversation

@haocheng6

@haocheng6 haocheng6 commented Jul 31, 2023

Copy link
Copy Markdown
Contributor

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

netlify Bot commented Jul 31, 2023

Copy link
Copy Markdown

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

netlify Bot commented Jul 31, 2023

Copy link
Copy Markdown

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.

@tay1orjones tay1orjones left a comment

Copy link
Copy Markdown
Member

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