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

chore(carbon__icons-react): ship TypeScript definitions #12034

Closed

Conversation

metonym
Copy link
Collaborator

@metonym metonym commented Aug 30, 2022

Closes #11317

This PR is based on #11533. I simply copied and rebased the PR on main.


Currently, @types/carbon__icons-react has to be manually updated for TypeScript support.

The goal for this PR is to better support TypeScript for the @carbon/icons-react package without rewriting it completely. By generating and shipping definitions with each release, @types/carbon__icons-react can be removed.

Related discussions in DefinitelyTyped:

Changelog

New

  • chore(carbon__icons-react): ship TypeScript definitions

@netlify
Copy link

netlify bot commented Aug 30, 2022

Deploy Preview for carbon-components-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit cfea21e
🔍 Latest deploy log https://app.netlify.com/sites/carbon-components-react/deploys/630e5ba3e752620008b01bdb
😎 Deploy Preview https://deploy-preview-12034--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 settings.

@netlify
Copy link

netlify bot commented Aug 30, 2022

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit cfea21e
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/630e5ba3c1540b0008b439c0
😎 Deploy Preview https://deploy-preview-12034--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 settings.

@netlify
Copy link

netlify bot commented Aug 30, 2022

Deploy Preview for carbon-components-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 67d9498
🔍 Latest deploy log https://app.netlify.com/sites/carbon-components-react/deploys/63263a363412250008380c4b
😎 Deploy Preview https://deploy-preview-12034--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 settings.

@netlify
Copy link

netlify bot commented Aug 30, 2022

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit 67d9498
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/63263a36fa0184000aa44d2d
😎 Deploy Preview https://deploy-preview-12034--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 settings.

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 resubmitting this! I don't recall any blockers from the original PR

Comment on lines +1 to +26
{
"compilerOptions": {
"lib": ["es2015.iterable", "es2015.generator", "es5"],
"moduleResolution": "node",

"declaration": true,
"declarationMap": true,
"sourceMap": true,
"composite": true,
"noEmitOnError": true,

"strictNullChecks": true,
"noImplicitAny": true,
"noImplicitThis": true,
"strictPropertyInitialization": true,
"noUnusedLocals": true,
"noUnusedParameters": true,

"alwaysStrict": true,
"preserveConstEnums": true,

"jsx": "preserve",

"types": []
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure this is the PR in which we want to define the overall monorepo's tsconfig file. I'd be more comfortable with each respective package defining their own for now until we have a global baseline that is defined by the TS working group.

Separately, It might be worth generating the basic tsconfig files using the tsc --init command since it outputs all (read: most) possible settings and gives nice context to each of them. Then from there, we can make changes to the configs above and beyond the defaults as needed.

@@ -26,6 +26,7 @@
"sync": "carbon-cli sync",
"test": "cross-env BABEL_ENV=test jest",
"test:e2e": "cross-env BABEL_ENV=test jest -c jest.e2e.config.js",
"typecheck": "tsc -b",
Copy link
Contributor

Choose a reason for hiding this comment

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

This script name implies type-checking and not necessarily building. Would it make more sense for this to be tsc --noEmit?


import * as React from 'react';

type IconSize = 16 | 20 | 24 | 32 | '16' | '20' | '24' | '32' | number | string;
Copy link
Contributor

Choose a reason for hiding this comment

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

There's an outstanding comment relating to this that I think needs some discussion. You can ignore my comment on it because the answer to what I asked over there is "yes", but the comment about IDE autocompletion is worth exploring further.

Also, I'm not sure why strings are allowable on this prop. @tay1orjones Do react icons allow you to specify string versions of the number sizes?

Copy link
Member

Choose a reason for hiding this comment

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

@jdharvey-ibm Yes, both strings or number literals are allowed

@dakahn dakahn removed their request for review September 8, 2022 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[Bug]: @carbon/react/icons module does not provide IDE import auto-complete
4 participants