Skip to content

Commit 65df3c1

Browse files
authored
fix: set types declarationDir based on cwd (#643) (#646)
1 parent 436498f commit 65df3c1

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

src/index.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,21 @@ async function getOutput({ cwd, output, pkgMain, pkgName }) {
364364
return main;
365365
}
366366

367+
function getDeclarationDir({ options, pkg }) {
368+
const { cwd, output } = options;
369+
370+
let result = output;
371+
372+
if (pkg.types || pkg.typings) {
373+
result = pkg.types || pkg.typings;
374+
result = resolve(cwd, result);
375+
}
376+
377+
result = dirname(result);
378+
379+
return result;
380+
}
381+
367382
async function getEntries({ input, cwd }) {
368383
let entries = (
369384
await map([].concat(input), async file => {
@@ -567,9 +582,7 @@ function createConfig(options, entry, format, writeMeta) {
567582
compilerOptions: {
568583
sourceMap: options.sourcemap,
569584
declaration: true,
570-
declarationDir: dirname(
571-
pkg.types || pkg.typings || options.output,
572-
),
585+
declarationDir: getDeclarationDir({ options, pkg }),
573586
jsx: 'react',
574587
jsxFactory:
575588
// TypeScript fails to resolve Fragments when jsxFactory

0 commit comments

Comments
 (0)