When I was developing a NPM library (as an ESM module), WebStorm shows that my exports are unused. How to fix it?
My tsconfig.json:
{
"compilerOptions": {
"declaration": true,
"declarationDir": "./dist",
"lib": [],
"module": "CommonJS",
"target": "es5",
"sourceMap": true,
"strict": true,
"noImplicitAny": true
},
"include": [
"src"
]
}
My package.json:
{
"name": "",
"version": "0.0.1",
"main": "dist/index.js",
"scripts": {
"build": "gulp clear"
},
"exports": {
".": "./dist/index.js"
},
"devDependencies": {
"@types/node": "^20.4.2",
"fs-extra": "^11.1.1",
"gulp": "^4.0.2",
"gulp-sourcemaps": "^3.0.0",
"gulp-terser": "^2.1.0",
"gulp-typescript": "^6.0.0-alpha.1",
"merge-stream": "^2.0.0",
"typescript": "^5.1.6",
"vinyl-buffer": "^1.0.1"
}
}
gulpfile.js:
const gulp = require("gulp");
const ts = require("gulp-typescript");
const terser = require("gulp-terser");
const merge = require('merge-stream');
const tsProject = ts.createProject("tsconfig.json");
gulp.task("default", function () {
const tsResult = tsProject
.src()
.pipe(tsProject());
return merge(tsResult.dts, tsResult.js.pipe(terser()))
.pipe(gulp.dest("dist"));
});
Why it's happening and how to fix it? WebStorm 2023.1.3 on Snap
from Why WebStorm shows exports in TypeScript as unused?

No comments:
Post a Comment