TS typing?
Amaimersion opened this issue · comments
Sergey,
I think you could achieve the same with:
"main": "./src/index.js",
"types": "./src/index.d.ts",
and adding same definition file into the source code.
I think you would have to add dev dependency to @types/webpack
, as your d.ts
contains references to webpack.
After this client consuming your package should just do:
npm i -D @types/node
npm i remove-files-webpack-plugin
import RemovePlugin = require("remove-files-webpack-plugin");
new RemovePlugin({
before: {
root: ".",
include: [
"./test"
],
exclude: [
"./test/test.txt"
],
trash: false,
log: false,
emulate: true,
allowRootAndOutside: true
},
after: {
test: [
{
folder: "./",
method: (filePath) => {
return filePath.includes('.map');
}
},
{
folder: "./test",
method: (filePath) => {
return filePath.includes('.map');
},
recursive: true
}
],
logWarning: true,
logError: true,
logDebug: true
}
});
this just transpiles as expected to:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const RemovePlugin = require("remove-files-webpack-plugin");
new RemovePlugin({
before: {
root: ".",
include: [
"./test"
],
exclude: [
"./test/test.txt"
],
trash: false,
log: false,
emulate: true,
allowRootAndOutside: true
},
after: {
test: [
{
folder: "./",
method: (filePath) => {
return filePath.includes('.map');
}
},
{
folder: "./test",
method: (filePath) => {
return filePath.includes('.map');
},
recursive: true
}
],
logWarning: true,
logError: true,
logDebug: true
}
});
word of warning, I never did this myself (I do not own a package myself that requires this)
Okay, @peterblazejewicz
Looks like at the moment adding typings into package itself is better than pushing into DefinitelyTyped. I knew that i was able to add it by myself into package, but for some reason i wanted to add it in DefinitelyTyped.
Okay, then i will add types into package itself.
Thank you for your advices!