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

declarationDir compiler option fails generation #147

Closed
igorpupkinable opened this issue Feb 10, 2021 · 5 comments
Closed

declarationDir compiler option fails generation #147

igorpupkinable opened this issue Feb 10, 2021 · 5 comments
Labels
Milestone

Comments

@igorpupkinable
Copy link

I am trying to bundle type definitions, but get the following error TS6053: File 'src/index.d.ts' not found.
I run yarn dts-bundle-generator --external-imports=react --out-file lib/index.d.ts src/index.ts and it fails with this error.

My src/index.ts is just a simple import of reusable React components:

export {
  Body,
  Headline,
} from './Text';

src/Text/index.ts content is

export { default as Body } from './Body';
export { default as Headline } from './Headline';

src/Text/Body.tsx content is similar in both files:

import React, {
  FC,
} from 'react';
import classNames from 'classnames';

import { TextProps } from './TextProps';

import styles from './Text.css';

const Body: FC<TextProps> = ({
  ...
}) => (
  <span ... />
);

export default Body;

Why does it need src/index.d.ts at all?
I works fine if I run tsc to generate definition file for each ts/tsx file and use dts-bundle-generator later with
yarn dts-bundle-generator --external-imports=react --out-file lib/index.d.ts lib/src/index.d.ts

@timocov
Copy link
Owner

timocov commented Feb 11, 2021

Why does it need src/index.d.ts at all?

That's because the tool firstly compiles all sources to declaration files (in-memory) and then create a program for declaration files - this is how the tool works actually.

Also, what version of the tool you use? It seems that the issue is related to "outDir" folder (I noticed that source code is in src folder, but output for it is lib/src) but the tool removes outDir compiler option since v3.2.0. Do you use composite projects?

Is it possible to create a repro for that please? With tsconfig and all needed sources (I don't need all of them, just for a minimal repro). I think it might help much to solve the issue.

@igorpupkinable
Copy link
Author

igorpupkinable commented Feb 11, 2021

Thank you for the reply.

Indeed, I use composite project, but it should not affect the matter, because bundle generator is executed within the package itself.
Please find a cut down repo here.

It works if I generate type definitions upfront with yarn test:types and then build with yarn build.
You will see an output in packages/ui-core/lib/

However, it does not work if yarn build from scratch with filePath: './src/index.ts', in DTS config.

@timocov
Copy link
Owner

timocov commented Feb 11, 2021

The reason is declarationDir compiler option. This is a bug, I'll fix it shortly. Thanks for reporting!

@timocov timocov changed the title error TS6053: File 'src/index.d.ts' not found. declarationDir compiler option fails generation Feb 11, 2021
@timocov timocov added the Bug label Feb 11, 2021
@timocov timocov added this to the 5.7 milestone Feb 11, 2021
@timocov
Copy link
Owner

timocov commented Feb 11, 2021

The fix is just published with 5.7.0 version.

@igorpupkinable
Copy link
Author

It works. Thank you for fixing.

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

No branches or pull requests

2 participants