From d31d8d6f97122150aef22905c4215b3ae9fd2443 Mon Sep 17 00:00:00 2001 From: Anna Wen <54281166+annawen1@users.noreply.github.com> Date: Mon, 30 Dec 2024 15:49:30 -0500 Subject: [PATCH] chore: add tsconfig file within component package to generate the TS declaration files (#344) * chore: add tsconfig to generate d.ts files * docs: adjust stackblitz link position in mdx docs * chore: set utilities to canary --- .../ExampleButton/__stories__/ExampleButton.mdx | 10 +++++----- .../ExampleButton/components/ExampleButton.tsx | 2 +- .../react/src/components/ExampleButton/package.json | 3 +++ .../react/src/components/ExampleButton/tsconfig.json | 8 ++++++++ packages/react/tasks/build.js | 2 +- yarn.lock | 12 ++++++++++++ 6 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 packages/react/src/components/ExampleButton/tsconfig.json diff --git a/packages/react/src/components/ExampleButton/__stories__/ExampleButton.mdx b/packages/react/src/components/ExampleButton/__stories__/ExampleButton.mdx index d15f19af..c3c9d769 100644 --- a/packages/react/src/components/ExampleButton/__stories__/ExampleButton.mdx +++ b/packages/react/src/components/ExampleButton/__stories__/ExampleButton.mdx @@ -3,17 +3,17 @@ import * as ExampleButtonStories from './ExampleButton.stories'; +# ExampleButton + +{/* */} +{/* */} + > 💡 Check our > [Stackblitz](https://stackblitz.com/github/carbon-design-system/carbon-labs/tree/main/examples/react/example-button) > example implementation. [![Edit carbon-labs](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/carbon-design-system/carbon-labs/tree/main/examples/react/example-button) -# ExampleButton - -{/* */} -{/* */} - ## Table of Contents - [Overview](#overview) diff --git a/packages/react/src/components/ExampleButton/components/ExampleButton.tsx b/packages/react/src/components/ExampleButton/components/ExampleButton.tsx index 861269af..1473cf4a 100644 --- a/packages/react/src/components/ExampleButton/components/ExampleButton.tsx +++ b/packages/react/src/components/ExampleButton/components/ExampleButton.tsx @@ -8,7 +8,7 @@ */ import React from 'react'; import { Button, ButtonProps } from '@carbon/react'; -import { usePrefix } from '../../../internal/usePrefix'; +import { usePrefix } from '@carbon-labs/utilities/es/index.js'; /** Primary UI component for user interaction */ diff --git a/packages/react/src/components/ExampleButton/package.json b/packages/react/src/components/ExampleButton/package.json index 6972b4a5..ad7b1148 100644 --- a/packages/react/src/components/ExampleButton/package.json +++ b/packages/react/src/components/ExampleButton/package.json @@ -23,5 +23,8 @@ "scripts": { "build": "node ../../../tasks/build.js", "clean": "rm -rf {es,lib,scss}" + }, + "devDependencies": { + "@carbon-labs/utilities": "canary" } } diff --git a/packages/react/src/components/ExampleButton/tsconfig.json b/packages/react/src/components/ExampleButton/tsconfig.json new file mode 100644 index 00000000..1a834217 --- /dev/null +++ b/packages/react/src/components/ExampleButton/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "typescript-config-carbon/tsconfig.base.json", + "compilerOptions": { + // TODO: Turn back on once stricter typings for internal utitlies are complete + "noImplicitAny": false + }, + "exclude": ["**/__stories__/*.stories.js", "**/__tests__/*"] +} diff --git a/packages/react/tasks/build.js b/packages/react/tasks/build.js index 8305159d..f685150e 100644 --- a/packages/react/tasks/build.js +++ b/packages/react/tasks/build.js @@ -31,7 +31,7 @@ const packageJSON = JSON.parse( async function build() { const reactEntrypoint = { filepath: path.resolve(process.cwd(), 'index.ts'), - rootDir: 'src', + rootDir: path.resolve(process.cwd()), outputDirectory: path.resolve(process.cwd()), }; diff --git a/yarn.lock b/yarn.lock index 83f1fdfc..6a9da5a6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2585,6 +2585,8 @@ __metadata: "@carbon-labs/react-example-button@workspace:packages/react/src/components/ExampleButton": version: 0.0.0-use.local resolution: "@carbon-labs/react-example-button@workspace:packages/react/src/components/ExampleButton" + dependencies: + "@carbon-labs/utilities": "npm:canary" languageName: unknown linkType: soft @@ -2606,6 +2608,16 @@ __metadata: languageName: node linkType: hard +"@carbon-labs/utilities@npm:canary": + version: 0.14.1-canary.387 + resolution: "@carbon-labs/utilities@npm:0.14.1-canary.387" + dependencies: + react: "npm:^18.3.1" + react-dom: "npm:^18.3.1" + checksum: 10c0/17f791a40f4f55689924b355fdecbfb254abd99325e1aee86ef96b7adb95e57d5be0b0eb928083137a6bad8a667d1bdfe33af2946502fa48434a133fb43756a3 + languageName: node + linkType: hard + "@carbon-labs/web-components-example-button@workspace:packages/web-components/src/components/example-button": version: 0.0.0-use.local resolution: "@carbon-labs/web-components-example-button@workspace:packages/web-components/src/components/example-button"