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

d.ts file is always generated as "components.d.ts" instead of given name in package.json #386

Closed
1 of 3 tasks
marinho opened this issue Dec 28, 2017 · 4 comments
Closed
1 of 3 tasks
Assignees

Comments

@marinho
Copy link

marinho commented Dec 28, 2017

Stencil version:

 @stencil/core@0.1.0

I'm submitting a:

  • bug report
  • feature request
  • support request

Current behavior:

Documentation in https://stenciljs.com/docs/distribution mentions that in order to distribute a components library, one should add a types entry to package.json, which in given example is "dist/collection/index.d.ts".

That is actually not working as expected as different values are provided to types, as you can see below:

When "types" = "dist/types/components.d.ts"

dist/types/components.d.ts is generated aside with folder dist/types/components which results not being possible to triple comment reference to other d.ts files inside that folder (look at [3]).

As dist/types/components.d.ts encapsulates all interfaces and types, I can only use HTML{MyComponentHere}Element from global declarations.

When "types" = "dist/types/index.d.ts"

No warning or error appears, but dist/types/components.d.ts is still generated instead of dist/types/index.d.ts.

When "types" = "dist/types/foo.d.ts"

[ ERROR ]  package.json error
    package.json "types" property is required when generating a distribution. Recommended entry d.ts file is:
    dist/types/components.d.ts

Expected behavior:

  • The error message is inconsistent, as if components.d.ts is "recommended“ (not required), it should just show a warning and still generate a file with the given name.
  • The d.ts file should still be generated with the given name. Using another name such as index.d.ts would make possible to import public interfaces from other type files from dist/types/components (look at [3]).

Steps to reproduce:

Just try the different values I mentioned above.

Related code:

Guess there's no need.

Other information:

[1] That was partially fixed in 5083ff14
[2] I can file a PR as contribution if this is accepted. I haven't done it, as I don't know if there's a policy or approval to follow before.
[3] I couldn't find confirmation about components.d.ts encapsulating folder components from the same folder, but that was the behaviour I got when tried it myself.

@marinho marinho changed the title "types" d.ts file should generate with given name in package.json d.ts file is always generated as "components.d.ts" instead of given name in package.json Dec 28, 2017
@marinho
Copy link
Author

marinho commented Dec 28, 2017

After a chat with @adamdbradley in Slack, one important clarification made clear I was misunderstanding types key in package.json all the time.

I was thinking it was used to generate the entry d.ts file of src and so dist/types too.

I was very wrong. types is just used to point to which file in dist/types should be taken by external apps. dist/types/components.d.ts is just a copy of src/components.d.ts, and so, by writing my own src/index.d.ts, I could easily solve the issues I was facing.

In my opinion, that means this issue should be just about showing a warning instead of an error when types is a value other than index.d.ts or components.d.ts. But I wouldn't see it as a priority, as it's a good practice to stay with one of both instead of foo.d.ts.

@marinho
Copy link
Author

marinho commented Dec 28, 2017

Additionally: I think we need something about that in https://stenciljs.com/docs/distribution, as it's not documented at all.

@jthoms1
Copy link
Member

jthoms1 commented Jan 9, 2018

@marinho I agree that this is something that we need to document better. I have changed the tags on this to better represent what we need to do to resolve this.

@jgw96 jgw96 assigned jgw96 and unassigned jthoms1 Jan 10, 2018
@jgw96
Copy link
Contributor

jgw96 commented Jan 18, 2018

After discussing this with @jthoms1 and looking at the code we decided the actual issue here is that the index.d.ts file that was in the src folder of the component starter was actually not needed and misleading, which caused the confusion above. I have removed that file from the component starter and am going to close this issue for now. Thanks for using Stencil!

@jgw96 jgw96 closed this as completed Jan 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants