-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Changes from all commits
4b9069f
36e4382
7d78e74
f08755e
67d9498
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,3 +57,6 @@ package-lock.json | |
|
||
# Playwright | ||
.playwright | ||
|
||
# TypeScript | ||
tsconfig.tsbuildinfo |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# TODO: remove in v11 | ||
/next | ||
# Generated declaration file | ||
index.d.ts |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"include": ["index.d.ts", "types"] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* Copyright IBM Corp. 2019, 2019 | ||
* | ||
* This source code is licensed under the Apache-2.0 license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import * as React from 'react'; | ||
|
||
type IconSize = 16 | 20 | 24 | 32 | '16' | '20' | '24' | '32' | number | string; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jdharvey-ibm Yes, both strings or number literals are allowed |
||
|
||
// Inspired by the original types defined in DefinitelyTyped: | ||
// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/31fb0ded56cff23b7e6693bd673b00f41dc00bbe/types/carbon__icons-react/index.d.ts | ||
interface IconProps | ||
extends Omit< | ||
React.SVGProps<React.ReactSVGElement>, | ||
'ref' | 'tabIndex' | 'aria-hidden' | ||
> { | ||
/** | ||
* @default "currentColor" | ||
*/ | ||
fill: string; | ||
|
||
/** | ||
* Specify the size of the icon. This value can be one of the predetermined | ||
* sizes for this icon (16, 20, 24, 32) or it can be a custom value that is | ||
* used for the width and height of the element | ||
* | ||
* @default 16 | ||
*/ | ||
size?: IconSize; | ||
|
||
/** | ||
* @default "http://www.w3.org/2000/svg" | ||
*/ | ||
xmlns?: string; | ||
} | ||
|
||
export type Icon = React.ForwardRefExoticComponent< | ||
IconProps & React.RefAttributes<SVGSVGElement> | ||
>; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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": [] | ||
} | ||
} | ||
Comment on lines
+1
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"files": [], | ||
"include": [], | ||
"references": [ | ||
{ | ||
"path": "./packages/icons-react" | ||
} | ||
] | ||
} |
There was a problem hiding this comment.
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
?