Add TypeScript config for @mailpoet/components
This handles both type checking and type declaration emitting. [MAILPOET-5015]
This commit is contained in:
1
packages/js/components/.gitignore
vendored
1
packages/js/components/.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
/build
|
||||
/build-module
|
||||
/build-types
|
||||
|
@ -10,6 +10,7 @@
|
||||
"import": "./build-module/index.js"
|
||||
}
|
||||
},
|
||||
"types": "build-types/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "wp-scripts build",
|
||||
"start": "wp-scripts start"
|
||||
@ -21,6 +22,7 @@
|
||||
"devDependencies": {
|
||||
"@types/react": "18.0.28",
|
||||
"@types/react-dom": "18.0.11",
|
||||
"fork-ts-checker-webpack-plugin": "^7.2.1",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0"
|
||||
},
|
||||
|
10
packages/js/components/tsconfig.json
Normal file
10
packages/js/components/tsconfig.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "../../../tsconfig.base.json",
|
||||
"include": ["src/**/*"],
|
||||
"compilerOptions": {
|
||||
"rootDir": "src",
|
||||
"declaration": true,
|
||||
"emitDeclarationOnly": true,
|
||||
"outDir": "build-types"
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
import path from 'node:path';
|
||||
import { default as defaultConfig } from '@wordpress/scripts/config/webpack.config.js';
|
||||
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
|
||||
import { WebpackEmitAllPlugin } from '../../../tools/webpack/webpack-emit-all-plugin.js';
|
||||
|
||||
const dirname = new URL('.', import.meta.url).pathname;
|
||||
@ -9,6 +10,7 @@ const plugins = [
|
||||
(plugin) => plugin.constructor.name !== 'DependencyExtractionWebpackPlugin',
|
||||
),
|
||||
new WebpackEmitAllPlugin({ context: path.join(dirname, 'src') }),
|
||||
new ForkTsCheckerWebpackPlugin({ typescript: { mode: 'write-dts' } }),
|
||||
];
|
||||
|
||||
export default {
|
||||
|
Reference in New Issue
Block a user