Skip to content

Commit

Permalink
refactor(project): update ts config and typings for icons-react
Browse files Browse the repository at this point in the history
  • Loading branch information
joshblack authored and metonym committed Aug 30, 2022
1 parent 72fcdc6 commit 2ecd26f
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 47 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@ package-lock.json

# Playwright
.playwright

# TypeScript
tsconfig.tsbuildinfo
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +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 --skipLibCheck --noEmit",
"typecheck": "tsc -b",
"postinstall": "husky install"
},
"resolutions": {
Expand Down
4 changes: 2 additions & 2 deletions packages/icon-build-helpers/src/builders/react/next.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,12 @@ async function builder(metadata, { output }) {

let declarationFile = `${templates.banner}
import { Icon } from './types/Icon.d.ts';
import { Icon } from './types/Icon';
`;

for (const m of modules) {
declarationFile += `export const ${m.name} = Icon;\n`;
declarationFile += `export const ${m.name}: Icon;\n`;
}

await fs.writeFile(path.join(output, 'index.d.ts'), declarationFile);
Expand Down
2 changes: 1 addition & 1 deletion packages/icons-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"scripts": {
"build": "yarn clean && node tasks/build.js",
"clean": "rimraf es lib",
"clean": "rimraf es lib index.d.ts",
"postinstall": "carbon-telemetry collect --install"
},
"types": "./index.d.ts",
Expand Down
4 changes: 4 additions & 0 deletions packages/icons-react/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"include": ["index.d.ts", "types"]
}
2 changes: 2 additions & 0 deletions packages/icons-react/types/Icon.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* 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;

// Inspired by the original types defined in DefinitelyTyped:
Expand Down
55 changes: 14 additions & 41 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -1,53 +1,26 @@
{
"compilerOptions": {
/* Type Checking */
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"alwaysStrict": true,
"noFallthroughCasesInSwitch": false,
"lib": ["es2015.iterable", "es2015.generator", "es5"],
"moduleResolution": "node",

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

"strictNullChecks": true,
"noImplicitAny": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noPropertyAccessFromIndexSignature": true,
"noUncheckedIndexedAccess": true,
"strictPropertyInitialization": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"strict": true,
"strictBindCallApply": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"strictPropertyInitialization": true,

/* Modules */
"baseUrl": ".",
"module": "esnext",
"moduleResolution": "node",
"paths": {
"*": ["node_modules/*"]
},
"resolveJsonModule": true,
"types": ["node"],
"typeRoots": ["./node_modules/@types", "./types"],

/* Emit */
"noEmit": true,

/* JavaScript Support */
"allowJs": true,

/* Interop Constraints */
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"alwaysStrict": true,
"preserveConstEnums": true,

/* Language and Environment */
"jsx": "preserve",
"lib": ["dom", "dom.iterable", "esnext"],
"target": "es2018",

/* Completeness */
"skipLibCheck": true
"types": []
}
}
9 changes: 7 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"extends": "./tsconfig.base.json",
"include": ["packages/icons-react"]
"files": [],
"include": [],
"references": [
{
"path": "./packages/icons-react"
}
]
}

0 comments on commit 2ecd26f

Please sign in to comment.