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

Cannot skip file check by exclude in tsconfig.json #747

Closed
kingller opened this issue Jun 1, 2022 · 3 comments
Closed

Cannot skip file check by exclude in tsconfig.json #747

kingller opened this issue Jun 1, 2022 · 3 comments
Labels

Comments

@kingller
Copy link

kingller commented Jun 1, 2022

Current behavior

When I add exclude files of node_modules in tsconfig.json, it still be checked as bellow,

ERROR in node_modules/pandora/src/js/utils/index.ts:135:74
TS7006: Parameter 'name' implicitly has an 'any' type.
    133 |             label = field(object);
    134 |         } else if (field.indexOf('${') >= 0) {
  > 135 |             label = field.replace(/\$\{([a-z0-9]+)\}/gi, function (text, name): string {

ERROR in node_modules/pandora/src/js/utils/index.ts:672:39
TS7006: Parameter 'key' implicitly has an 'any' type.
    670 |     /** set object's attributes to empty  */
    671 |     changeAttrValToEmpty(obj: object): void {
  > 672 |         _.forEach(obj, function (val, key): void {

tsconfig.json

"exclude": [
        "node_modules",
        "**/*.spec.ts"
    ]

Expected behavior

Skip the check. When I run the pandora alone, it's OK. I don't know what happens, this error should not happen, or it should happen when I run the pandora alone. Here I want to skip it.

Steps to reproduce the issue

tsconfig.json

{
	"compilerOptions": {
		"outDir": "./dist/",
		"sourceMap": true,
		"noImplicitAny": true,
		"strictNullChecks": false,
		"module": "commonjs",
		"target": "ESNext",
		"jsx": "react",
		"experimentalDecorators": true,
		"emitDecoratorMetadata": true,
		"allowSyntheticDefaultImports": true,
		"esModuleInterop": true,
		"moduleResolution": "node",
		"skipLibCheck": true,
		"resolveJsonModule": true,
		"allowJs": false,
		"baseUrl": ".",
	},
	"files": [
		"./node_modules/pandora/src/typings/index.d.ts",
		"./node_modules/tsx-control-statements/index.d.tsx"
	],
	"include": [
		"./src/**/*"
	],
	"exclude": [
        "node_modules",
        "**/*.spec.ts"
    ]
}

webpack

const localIPPromise = DevServer.getHostname('local-ip');

module.exports = function (env, args = {}) {
    const mode = args.mode;
    const host = env.host || 'local-ip';

    return new Promise((resolve, reject) => {
        localIPPromise.then(
            (localIP) => {
                let config = {
                    mode: mode,
                    module: {
                        rules: [
                            {
                                test: /\.tsx?$/,
                                loader: 'babel-loader',
                                options: {
                                    presets: ['@babel/preset-typescript'],
                                    plugins: [['@babel/plugin-transform-typescript', { allowNamespaces: true }]],
                                },
                                include: [
                                    path.resolve(ROOT_PATH, 'src'),
                                ],
                            },
                            {
                                test: /\.jsx?$/,
                                include: [
                                    path.resolve(ROOT_PATH, 'src'),
                                ],
                                use: {
                                    loader: 'babel-loader',
                                },
                            },
                            // ...
                        ],
                    },
                    resolve: {
                        extensions: ['.ts', '.tsx', '.js', '.jsx'],
                    },
                    plugins: [
                       // ...
                        new ForkTsCheckerWebpackPlugin({
                            async: false,
                        }),
                        new ForkTsCheckerNotifierWebpackPlugin({
                            title: 'TypeScript',
                            excludeWarnings: true,
                            skipSuccessful: true,
                        }),
                    ],
                    externals: { pandora: 'pandora' },
                };
        );
    });
};

Issue reproduction repository

Environment

  • fork-ts-checker-webpack-plugin: 6.5.0
  • typescript: 4.6.4
  • eslint: 8.16.0
  • webpack: 5.65.0
  • os: macOS Big Sur 11.6
@kingller kingller added the bug label Jun 1, 2022
@piotr-oles
Copy link
Collaborator

Do you have this error with tsc --noEmit command?

@kingller
Copy link
Author

kingller commented Jun 2, 2022

Do you have this error with tsc --noEmit command?

Yes, I add it, but the error still occurs.

@piotr-oles
Copy link
Collaborator

piotr-oles commented Jun 2, 2022

If you have error for tsc --noEmit as well, it means that it's not an issue with the plugin, but with typescript or its configuration.
For me it seems that you have contradicting configuration - on the one hand you include ./node_modules/pandora/src/typings/index.d.ts from node_modules but you also exclude node_modules. I think that in this case, file will take precedence over exclude. And when you type-check ./node_modules/pandora/src/typings/index.d.ts, you type-check all its dependencies. Do you need pandora in files?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants