Skip to content

Commit

Permalink
Migration to new tsconfig solution (#20880)
Browse files Browse the repository at this point in the history
  • Loading branch information
tringakrasniqi authored Dec 2, 2021
1 parent 084a718 commit 3e29ec7
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 22 deletions.
1 change: 0 additions & 1 deletion packages/react-input/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.cache/
.storybook/
.vscode/
bundle-size/
Expand Down
6 changes: 4 additions & 2 deletions packages/react-input/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
const rootMain = require('../../../.storybook/main');

module.exports = /** @type {Pick<import('../../../.storybook/main').StorybookConfig,'addons'|'stories'|'webpackFinal'>} */ ({
module.exports = /** @type {Omit<import('../../../.storybook/main'), 'typescript'|'babel'>} */ ({
...rootMain,
stories: [...rootMain.stories, '../src/**/*.stories.mdx', '../src/**/*.stories.@(ts|tsx)'],
addons: [...rootMain.addons],
webpackFinal: (config, options) => {
const localConfig = { ...rootMain.webpackFinal(config, options) };

// add your own webpack tweaks if needed

return localConfig;
},
previewHead: rootMain.previewHead,
});
4 changes: 4 additions & 0 deletions packages/react-input/.storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import * as rootPreview from '../../../.storybook/preview';

/** @type {typeof rootPreview.decorators} */
export const decorators = [...rootPreview.decorators];

/** @type {typeof rootPreview.parameters} */
export const parameters = { ...rootPreview.parameters };
7 changes: 4 additions & 3 deletions packages/react-input/.storybook/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "",
"allowJs": true,
"checkJs": true
"checkJs": true,
"types": ["static-assets", "environment", "inline-style-expand-shorthand", "storybook__addons"]
},
"exclude": ["../**/*.test.ts", "../**/*.test.js", "../**/*.test.tsx", "../**/*.test.jsx"],
"include": ["../src/**/*", "*.js"]
"include": ["../src/**/*.stories.ts", "../src/**/*.stories.tsx", "*.js"]
}
2 changes: 1 addition & 1 deletion packages/react-input/config/api-extractor.local.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"extends": "./api-extractor.json",
"mainEntryPointFilePath": "<projectFolder>/dist/<unscopedPackageName>/src/index.d.ts"
"mainEntryPointFilePath": "<projectFolder>/dist/packages/<unscopedPackageName>/src/index.d.ts"
}
2 changes: 1 addition & 1 deletion packages/react-input/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
preset: '../../jest.preset.js',
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.json',
tsConfig: '<rootDir>/tsconfig.spec.json',
diagnostics: false,
},
},
Expand Down
7 changes: 4 additions & 3 deletions packages/react-input/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
"just": "just-scripts",
"lint": "just-scripts lint",
"start": "yarn storybook",
"test": "jest",
"test": "jest --passWithNoTests",
"docs": "api-extractor run --config=config/api-extractor.local.json --local",
"build:local": "tsc -p . --module esnext --emitDeclarationOnly && node ../../scripts/typescript/normalize-import --output dist/react-input/src && yarn docs",
"build:local": "tsc -p ./tsconfig.lib.json --module esnext --emitDeclarationOnly && node ../../scripts/typescript/normalize-import --output ./dist/packages/react-input/src && yarn docs",
"bundle:storybook": "just-scripts storybook:build",
"storybook": "start-storybook"
"storybook": "start-storybook",
"type-check": "tsc -b tsconfig.json"
},
"devDependencies": {
"@fluentui/babel-make-styles": "9.0.0-beta.4",
Expand Down
29 changes: 18 additions & 11 deletions packages/react-input/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
{
"extends": "../../tsconfig.base.json",
"include": ["src"],
"compilerOptions": {
"target": "ES2019",
"module": "CommonJS",
"lib": ["ES2019", "DOM"],
"outDir": "dist",
"jsx": "react",
"declaration": true,
"experimentalDecorators": true,
"noEmit": true,
"isolatedModules": true,
"importHelpers": true,
"jsx": "react",
"noUnusedLocals": true,
"preserveConstEnums": true,
"types": ["jest", "custom-global", "inline-style-expand-shorthand"],
"isolatedModules": true
}
"preserveConstEnums": true
},
"include": [],
"files": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
},
{
"path": "./.storybook/tsconfig.json"
}
]
}
20 changes: 20 additions & 0 deletions packages/react-input/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"noEmit": false,
"lib": ["ES2019", "dom"],
"outDir": "dist",
"declaration": true,
"types": ["static-assets", "environment", "inline-style-expand-shorthand"]
},
"exclude": [
"./src/common/**",
"**/*.spec.ts",
"**/*.spec.tsx",
"**/*.test.ts",
"**/*.test.tsx",
"**/*.stories.ts",
"**/*.stories.tsx"
],
"include": ["./src/**/*.ts", "./src/**/*.tsx"]
}
9 changes: 9 additions & 0 deletions packages/react-input/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "CommonJS",
"outDir": "dist",
"types": ["jest", "node", "inline-style-expand-shorthand"]
},
"include": ["**/*.spec.ts", "**/*.spec.tsx", "**/*.test.ts", "**/*.test.tsx", "**/*.d.ts"]
}

0 comments on commit 3e29ec7

Please sign in to comment.