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

Validate that types field is on a TypeScript entrypoint (behind a flag) #259

Open
Andarist opened this issue Feb 17, 2020 · 7 comments · May be fixed by #562
Open

Validate that types field is on a TypeScript entrypoint (behind a flag) #259

Andarist opened this issue Feb 17, 2020 · 7 comments · May be fixed by #562

Comments

@Andarist
Copy link
Member

It's not automatically generated, but even if manually added then it's not validated and cannot be fixed with preconstruct fix.

@Andarist
Copy link
Member Author

Ok, seems like .d.ts is actually generated - but because of the issue mentioned here I was thinking that I was looking at another directory (the root entry).

I feel however that maybe it should be validated that "types" got used and throw an error on that (in favor of those type files that are auto-generated). This should ofc happen only for TS projects - adding "types" manually should be supported for packages shipping .d.ts without them actually being written in TS.

@emmatown
Copy link
Member

I feel however that maybe it should be validated that "types" got used and throw an error on that (in favor of those type files that are auto-generated). This should ofc happen only for TS projects - adding "types" manually should be supported for packages shipping .d.ts without them actually being written in TS.

Agreed

@emmatown emmatown changed the title Additional entries don't have "types" generated Validate that types field isn't on a TypeScript entrypoint Jul 12, 2020
@hasparus
Copy link

hasparus commented Jan 4, 2021

Hey folks, what's the status of "types" field in package.json with Preconstruct? (BTW Preconstruct is blazing fast. Wow.)

TypeScript docs advise to add "types" key to package.json. Should preconstruct fix add it to point to the generated .cjs.d.ts file?

@emmatown
Copy link
Member

emmatown commented Jan 5, 2021

There's no real need since TypeScript can already resolve it. Is there are a particular reason you want to add it to the package.json?

@Andarist
Copy link
Member Author

Andarist commented Jan 5, 2021

Even to make it easier for other tools. For example, npm marks packages with TS types with a special badge. Compare:

@hasparus
Copy link

hasparus commented Jan 5, 2021

Is there are a particular reason you want to add it to the package.json?

What Andarist said, and I vaguely remember PRing/patching niche libraries I wanted to use, because old TS couldn't resolve it.

@emmatown emmatown changed the title Validate that types field isn't on a TypeScript entrypoint Validate that types field is on a TypeScript entrypoint (behind a flag) Jan 20, 2021
@emmatown
Copy link
Member

Okay, sounds good. Happy to accept a PR adding this(behind a flag for now because it would be a breaking change otherwise)

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

Successfully merging a pull request may close this issue.

3 participants