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): Refactor carbon/react index.js to index.ts to expose new typescript typings #12787

Merged
merged 31 commits into from
Jan 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9ebbc29
refactor: add build support for TS
mbarrer Oct 4, 2022
fcc9f98
refactor: convert Checkbox and Text to typescript
mbarrer Oct 4, 2022
6b58f27
refactor: add ts extensions to jest
mbarrer Oct 4, 2022
4241aeb
refactor: add ts extensions to jsTransform.js
mbarrer Oct 4, 2022
3bd84d9
refactor: add type exports to barrels
mbarrer Oct 4, 2022
12b4437
refactor: do not convert TextDirectionContext to TS
mbarrer Oct 17, 2022
bbd77f8
chore: add comment
mbarrer Oct 17, 2022
219d356
refactor: update Text with context
mbarrer Oct 17, 2022
29e095d
refactor: use @type jsdoc assertion
mbarrer Oct 17, 2022
88daf70
refactor: fix build and turn off explicit any rule
mbarrer Oct 17, 2022
406d89e
chore: merge
mbarrer Oct 31, 2022
00eed65
chore: yarn dedup
mbarrer Oct 31, 2022
1b090eb
chore: run install withh yarn 3.2.4
mbarrer Oct 31, 2022
ebbb68a
refactor: convert main index.js to ts. Always export named exports
mbarrer Dec 5, 2022
65f0c17
chore: merge main
mbarrer Dec 5, 2022
b8ba60f
chore: dedupe and merge fix
mbarrer Dec 5, 2022
c058a9a
chore: update to yarn 3.3.0
mbarrer Dec 5, 2022
72e34ab
chore: remove new-line
mbarrer Dec 5, 2022
3c49f17
chore: add Checkbox export
mbarrer Dec 5, 2022
c54a3cf
chore: run yarn test
mbarrer Dec 8, 2022
9c6df90
Merge branch 'main' into mbarrer
mbarrer Dec 8, 2022
0ce789c
chore: merge main
mbarrer Dec 8, 2022
751f0ea
chore: update test snap
mbarrer Dec 8, 2022
eeddcdb
Merge branch 'mbarrer' of github.com:carbon-design-system/mbarrer int…
mbarrer Dec 8, 2022
8006977
Merge branch 'main' of github.com:carbon-design-system/carbon into mb…
tay1orjones Dec 14, 2022
7a7f6f6
Merge branch 'main' of github.com:carbon-design-system/carbon into mb…
tay1orjones Dec 14, 2022
a60e42f
chore: review comments
mbarrer Dec 19, 2022
61fc973
Merge branch 'mbarrer' of github.com:carbon-design-system/mbarrer int…
mbarrer Dec 19, 2022
5068e51
chore: fix typo
mbarrer Dec 19, 2022
14599f0
Merge branch 'main' of github.com:carbon-design-system/carbon into mb…
mbarrer Dec 19, 2022
c93f809
Merge branch 'main' of github.com:carbon-design-system/carbon into mb…
tay1orjones Jan 6, 2023
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
20 changes: 18 additions & 2 deletions packages/react/__tests__/PublicAPI-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,31 @@ test('Public API should only change with a semver change', () => {
const CarbonReact = require('../src');
const PublicAPI = new Map();

Object.keys(CarbonReact).forEach((name) => {
// Sort alphabetically
const CarbonReactOrdered = Object.keys(CarbonReact)
.sort()
.reduce((obj, key) => {
obj[key] = CarbonReact[key];
return obj;
}, {});

Object.keys(CarbonReactOrdered).forEach((name) => {
const Component = CarbonReact[name];
PublicAPI.set(name, mapComponentToAPI(Component));
});

function mapComponentToAPI(Component) {
const api = {};

Object.keys(Component).forEach((key) => {
// Sort alphabetically
const ComponentOrdered = Object.keys(Component)
.sort()
.reduce((obj, key) => {
obj[key] = Component[key];
return obj;
}, {});

Object.keys(ComponentOrdered).forEach((key) => {
// There are a couple of properties on components that we don't believe
// are part of our API, such as `_` prefixed variables, or capture details
// that are internal to a library-specific piece of functionality. For
Expand Down
205 changes: 29 additions & 176 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3590,6 +3590,11 @@ Map {
},
},
},
"FormContext" => Object {
"$$typeof": Symbol(react.context),
"Consumer": "React.Consumer",
"Provider": "React.Provider",
},
"FormGroup" => Object {
"defaultProps": Object {
"invalid": false,
Expand Down Expand Up @@ -5678,6 +5683,11 @@ Map {
},
"render": [Function],
},
"PrefixContext" => Object {
"$$typeof": Symbol(react.context),
"Consumer": "React.Consumer",
"Provider": "React.Provider",
},
"PrimaryButton" => Object {},
"ProgressBar" => Object {
"propTypes": Object {
Expand Down Expand Up @@ -8283,6 +8293,11 @@ Map {
},
},
},
"ThemeContext" => Object {
"$$typeof": Symbol(react.context),
"Consumer": "React.Consumer",
"Provider": "React.Provider",
},
"Tile" => Object {
"$$typeof": Symbol(react.forward_ref),
"propTypes": Object {
Expand Down Expand Up @@ -8973,6 +8988,20 @@ Map {
"$$typeof": Symbol(react.forward_ref),
"render": [Function],
},
"types" => Object {
"0": "red",
"1": "magenta",
"10": "high-contrast",
"11": "outline",
"2": "purple",
"3": "blue",
"4": "cyan",
"5": "teal",
"6": "green",
"7": "gray",
"8": "cool-gray",
"9": "warm-gray",
},
"unstable_FeatureFlags" => Object {
"propTypes": Object {
"children": Object {
Expand Down Expand Up @@ -9826,182 +9855,6 @@ Map {
},
},
},
"unstable__FluidNumberInput" => Object {
"$$typeof": Symbol(react.forward_ref),
"propTypes": Object {
"allowEmpty": Object {
"type": "bool",
},
"className": Object {
"type": "string",
},
"defaultValue": Object {
"args": Array [
Array [
Object {
"type": "number",
},
Object {
"type": "string",
},
],
],
"type": "oneOfType",
},
"disableWheel": Object {
"type": "bool",
},
"disabled": Object {
"type": "bool",
},
"iconDescription": Object {
"type": "string",
},
"id": Object {
"isRequired": true,
"type": "string",
},
"invalid": Object {
"type": "bool",
},
"invalidText": Object {
"type": "node",
},
"label": Object {
"type": "node",
},
"max": Object {
"type": "number",
},
"min": Object {
"type": "number",
},
"onChange": Object {
"type": "func",
},
"onClick": Object {
"type": "func",
},
"onKeyUp": Object {
"type": "func",
},
"step": Object {
"type": "number",
},
"translateWithId": Object {
"type": "func",
},
"value": Object {
"args": Array [
Array [
Object {
"type": "number",
},
Object {
"type": "string",
},
],
],
"type": "oneOfType",
},
"warn": Object {
"type": "bool",
},
"warnText": Object {
"type": "node",
},
},
"render": [Function],
},
"unstable__FluidNumberInputSkeleton" => Object {
"propTypes": Object {
"className": Object {
"type": "string",
},
},
},
"unstable__FluidSearch" => Object {
"$$typeof": Symbol(react.forward_ref),
"defaultProps": Object {
"autoComplete": "off",
"closeButtonLabelText": "Clear search input",
"role": "searchbox",
"type": "text",
},
"propTypes": Object {
"autoComplete": Object {
"type": "string",
},
"className": Object {
"type": "string",
},
"closeButtonLabelText": Object {
"type": "string",
},
"defaultValue": Object {
"args": Array [
Array [
Object {
"type": "string",
},
Object {
"type": "number",
},
],
],
"type": "oneOfType",
},
"disabled": Object {
"type": "bool",
},
"id": Object {
"type": "string",
},
"labelText": Object {
"isRequired": true,
"type": "node",
},
"onChange": Object {
"type": "func",
},
"onClear": Object {
"type": "func",
},
"onKeyDown": Object {
"type": "func",
},
"placeholder": Object {
"type": "string",
},
"role": Object {
"type": "string",
},
"type": Object {
"type": "string",
},
"value": Object {
"args": Array [
Array [
Object {
"type": "string",
},
Object {
"type": "number",
},
],
],
"type": "oneOfType",
},
},
"render": [Function],
},
"unstable__FluidSearchSkeleton" => Object {
"propTypes": Object {
"className": Object {
"type": "string",
},
},
},
"unstable__FluidSelect" => Object {
"$$typeof": Symbol(react.forward_ref),
"propTypes": Object {
Expand Down
8 changes: 4 additions & 4 deletions packages/react/src/__tests__/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ describe('Carbon Components React', () => {
"FlexGrid",
"FluidForm",
"Form",
"FormContext",
"FormGroup",
"FormItem",
"FormLabel",
Expand Down Expand Up @@ -113,6 +114,7 @@ describe('Carbon Components React', () => {
"PasswordInput",
"Popover",
"PopoverContent",
"PrefixContext",
"PrimaryButton",
"ProgressBar",
"ProgressIndicator",
Expand Down Expand Up @@ -197,6 +199,7 @@ describe('Carbon Components React', () => {
"TextInput",
"TextInputSkeleton",
"Theme",
"ThemeContext",
"Tile",
"TileAboveTheFoldContent",
"TileBelowTheFoldContent",
Expand All @@ -217,6 +220,7 @@ describe('Carbon Components React', () => {
"TreeView",
"UnorderedList",
"VStack",
"types",
"unstable_FeatureFlags",
"unstable_LayoutDirection",
"unstable_Menu",
Expand All @@ -239,10 +243,6 @@ describe('Carbon Components React', () => {
"unstable__FluidDropdownSkeleton",
"unstable__FluidMultiSelect",
"unstable__FluidMultiSelectSkeleton",
"unstable__FluidNumberInput",
"unstable__FluidNumberInputSkeleton",
"unstable__FluidSearch",
"unstable__FluidSearchSkeleton",
"unstable__FluidSelect",
"unstable__FluidSelectSkeleton",
"unstable__FluidTextArea",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,4 @@ function AccordionSkeletonItem() {
}

export default AccordionSkeleton;
export { AccordionSkeleton };
1 change: 1 addition & 0 deletions packages/react/src/components/Accordion/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
import Accordion from './Accordion';

export default Accordion;
export { Accordion };
export { default as AccordionItem } from './AccordionItem';
export { default as AccordionSkeleton } from './Accordion.Skeleton';
1 change: 1 addition & 0 deletions packages/react/src/components/AccordionItem/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
// Alias for import paths for build tools that rely on this
import { AccordionItem } from '../Accordion';
export default AccordionItem;
export { AccordionItem };
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ BreadcrumbSkeleton.propTypes = {
};

export default BreadcrumbSkeleton;
export { BreadcrumbSkeleton };
1 change: 1 addition & 0 deletions packages/react/src/components/Button/Button.Skeleton.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,4 @@ ButtonSkeleton.propTypes = {
};

export default ButtonSkeleton;
export { ButtonSkeleton };
5 changes: 4 additions & 1 deletion packages/react/src/components/Button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

import Button from './Button';

export default Button;
export { Button };
export { default as ButtonSkeleton } from './Button.Skeleton';
export default from './Button';
4 changes: 3 additions & 1 deletion packages/react/src/components/ButtonSet/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/

export default from './ButtonSet';
import ButtonSet from './ButtonSet';
export { ButtonSet };
export default ButtonSet;
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ CheckboxSkeleton.propTypes = {
};

export default CheckboxSkeleton;
export { CheckboxSkeleton };
8 changes: 6 additions & 2 deletions packages/react/src/components/Checkbox/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
* LICENSE file in the root directory of this source tree.
*/

export { default as CheckboxSkeleton } from './Checkbox.Skeleton';
import Checkbox, { CheckboxProps } from './Checkbox';
export type { CheckboxProps };

export { default as CheckboxSkeleton } from './Checkbox.Skeleton';
export default Checkbox;

export { Checkbox };

export type { CheckboxProps };
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,4 @@ CodeSnippetSkeleton.propTypes = {
};

export default CodeSnippetSkeleton;
export { CodeSnippetSkeleton };
5 changes: 4 additions & 1 deletion packages/react/src/components/CodeSnippet/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

import CodeSnippet from './CodeSnippet';

export default CodeSnippet;
export { CodeSnippet };
export { default as CodeSnippetSkeleton } from './CodeSnippet.Skeleton';
export default from './CodeSnippet';
Loading