Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
Depending on my
tsconfig.json
configuration, I had trouble importing this plugin (has no construct signatures
,Unsafe construction of an any type value.
, etc.).I used different kinds of imports that all failed with my configuration (well, I tried to just bypass them with
@ts-ignore
oreslint-disable
and it did works for some situations).import GasPlugin from "gas-webpack-plugin";
import { GasPlugin } from "gas-webpack-plugin";
import * as GasPlugin from "gas-webpack-plugin";
import GasPlugin = require("gas-webpack-plugin");
const GasPlugin = require("gas-webpack-plugin");
I also tried to use different variation on the object initialisation:
new GasPlugin();
new GasPlugin.default();
Analysis
From my understanding, the file
index.js
was written as aCommonJS
module (due to theconst = require()
andmodule.exports
. However, thetype.d.ts
was written as if the package was authored asECMAScript
module (due toimport from
andexport default
).As references to resolve this I used the following references.
esm
andcjs
in regards to imports and exports.export =
vsexport default
/import
variants microsoft/TypeScript#7185 (comment)Solution
Based on the analysis, I rewrote
type.d.ts
by usingexport =
to (hopefully!) indicate that the module was written as aCommonJS
. This seems to works for my first configuration.Configurations
I will keep as draft for the time being, while I test with my other configurations (I have transpile to JS in
esm
andcjs
for the package and others various when I use the package). I will add all info on those variations here when tested on my side. This will be manual testing, I will leave to you or another contributor to write tests if needed.Config 1 - Made to run
jest
- ✅⚠ Needs to import with
import GasPlugin = require("gas-webpack-plugin");
.tsconfig.json