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

Improper module declaration #12

Open
ghost opened this issue Jul 6, 2021 · 2 comments
Open

Improper module declaration #12

ghost opened this issue Jul 6, 2021 · 2 comments

Comments

@ghost
Copy link

ghost commented Jul 6, 2021

Importing the plugin when using TypeScript to write webpack configuration with
import InjectBodyPlugin from 'inject-body-webpack-plugin';
as suggested by the Example section in readme.md yields

error TS2351: This expression is not constructable.
Type 'typeof import("inject-body-webpack-plugin")' has no construct signatures.
by the TypeScript compiler even though if type checking is skipped no error occurs.

I think the problem is with generated module declaration in index.d.ts.
If we replace export class InjectBodyPlugin with export default class InjectBodyPlugin error no longer occurs.

@rxgx
Copy link

rxgx commented Aug 1, 2021

For CommonJS, I had to use the default property for the class to work.

const InjectBodyPlugin = require('inject-body-webpack-plugin').default;

@marcellino-ornelas
Copy link

marcellino-ornelas commented Jan 2, 2023

Any updates on this? Having issues importing InjectBodyPlugin in typescript

Needed to bypass this with

// @ts-expect-error
new InjectBodyPlugin({
	content: '<main id="root"></main>',
	position: 'start',
}),

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

No branches or pull requests

2 participants