Skip to content

Commit 9423de0

Browse files
authored
feat: enabling type imports directly from @carbon/react (#18301)
* feat: types addition to index.ts * feat: exports 2 * feat: added type exports for many comps * feat: new type interface exports * feat: added more interface exports * feat: completed the types interface exports * fix: added fragmet to button * chore: format
1 parent f53c551 commit 9423de0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+511
-87
lines changed

packages/react/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"version": "1.74.0",
55
"license": "Apache-2.0",
66
"main": "lib/index.js",
7+
"types": "lib/index.d.ts",
78
"module": "es/index.js",
89
"repository": {
910
"type": "git",

packages/react/src/components/AILabel/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ const propMappingFunction = (deprecatedValue) => {
127127
return mapPopoverAlignProp(deprecatedValue);
128128
};
129129

130-
interface AILabelProps {
130+
export interface AILabelProps {
131131
AILabelContent?: React.ReactNode;
132132
aiText?: string;
133133
aiTextLabel?: string;

packages/react/src/components/AISkeleton/AISkeletonIcon.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import classNames from 'classnames';
1111
import { usePrefix } from '../../internal/usePrefix';
1212
import { SkeletonIcon } from '../SkeletonIcon';
1313

14-
interface AISkeletonIconProps {
14+
export interface AISkeletonIconProps {
1515
/**
1616
* Specify an optional className to add.
1717
*/

packages/react/src/components/AISkeleton/AISkeletonText.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import classNames from 'classnames';
1111
import { usePrefix } from '../../internal/usePrefix';
1212
import { SkeletonText } from '../SkeletonText';
1313

14-
interface AISkeletonTextProps {
14+
export interface AISkeletonTextProps {
1515
/**
1616
* Specify an optional className to be applied to the container node.
1717
*/

packages/react/src/components/Accordion/Accordion.Skeleton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { ChevronRight } from '@carbon/icons-react';
1212
import SkeletonText from '../SkeletonText';
1313
import { usePrefix } from '../../internal/usePrefix';
1414

15-
interface AccordionSkeletonProps {
15+
export interface AccordionSkeletonProps {
1616
/**
1717
* Specify the alignment of the accordion heading
1818
* title and chevron.

packages/react/src/components/Accordion/AccordionItem.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import deprecate from '../../prop-types/deprecate';
2525
import { usePrefix } from '../../internal/usePrefix';
2626
import { AccordionContext } from './AccordionProvider';
2727

28-
interface AccordionItemProps {
28+
export interface AccordionItemProps {
2929
/**
3030
* Specify an optional className to be
3131
* applied to the container node.
@@ -90,7 +90,7 @@ interface AccordionItemProps {
9090
handleAnimationEnd?: AnimationEventHandler<HTMLElement>;
9191
}
9292

93-
interface AccordionToggleProps {
93+
export interface AccordionToggleProps {
9494
'aria-controls'?: AriaAttributes['aria-controls'];
9595
'aria-expanded'?: AriaAttributes['aria-expanded'];
9696
className?: string;

packages/react/src/components/AspectRatio/AspectRatio.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import PropTypes from 'prop-types';
1010
import React, { PropsWithChildren, ReactHTML } from 'react';
1111
import { usePrefix } from '../../internal/usePrefix';
1212

13-
interface AspectRatioProps {
13+
export interface AspectRatioProps {
1414
/**
1515
* Provide a custom component or string to be rendered as
1616
* the outermost node of the component. This is useful if you want

packages/react/src/components/ClassPrefix/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import PropTypes from 'prop-types';
99
import React, { PropsWithChildren } from 'react';
1010
import { PrefixContext } from '../../internal/usePrefix';
1111

12-
interface ClassPrefixProps {
12+
export interface ClassPrefixProps {
1313
/**
1414
* The value used to prefix the CSS selectors
1515
* used by Carbon components.

packages/react/src/components/ComboBox/ComboBox.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ const findHighlightedIndex = <ItemType,>(
152152

153153
type ExcludedAttributes = 'id' | 'onChange' | 'onClick' | 'type' | 'size';
154154

155-
interface OnChangeData<ItemType> {
155+
export interface OnChangeData<ItemType> {
156156
selectedItem: ItemType | null | undefined;
157157
inputValue?: string | null;
158158
}
@@ -164,13 +164,14 @@ interface OnChangeData<ItemType> {
164164
* because those components aren't Typescript. (If you try, TranslationKey
165165
* ends up just being defined as "string".)
166166
*/
167-
type TranslationKey =
167+
export type TranslationKey =
168168
| 'close.menu'
169169
| 'open.menu'
170170
| 'clear.all'
171171
| 'clear.selection';
172172

173-
type ItemToStringHandler<ItemType> = (item: ItemType | null) => string;
173+
export type ItemToStringHandler<ItemType> = (item: ItemType | null) => string;
174+
174175
export interface ComboBoxProps<ItemType>
175176
extends Omit<InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes>,
176177
TranslateWithId<TranslationKey> {
@@ -1349,7 +1350,7 @@ type ComboboxComponentProps<ItemType> = PropsWithRef<
13491350
PropsWithChildren<ComboBoxProps<ItemType>> & RefAttributes<HTMLInputElement>
13501351
>;
13511352

1352-
interface ComboBoxComponent {
1353+
export interface ComboBoxComponent {
13531354
<ItemType>(props: ComboboxComponentProps<ItemType>): ReactElement | null;
13541355
}
13551356

packages/react/src/components/ComboButton/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const defaultTranslations = {
3535
/**
3636
* Message ids that will be passed to translateWithId().
3737
*/
38-
type TranslationKey = keyof typeof defaultTranslations;
38+
export type TranslationKey = keyof typeof defaultTranslations;
3939

4040
const propMappingFunction = (deprecatedValue) => {
4141
const mapping = {

0 commit comments

Comments
 (0)