Closed marinho closed 6 years ago
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
.
Additionally: I think we need something about that in https://stenciljs.com/docs/distribution, as it's not documented at all.
@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.
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!
Stencil version:
I'm submitting a:
Current behavior:
Documentation in https://stenciljs.com/docs/distribution mentions that in order to distribute a components library, one should add a
types
entry topackage.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 folderdist/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 useHTML{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 ofdist/types/index.d.ts
.When "types" = "dist/types/foo.d.ts"
Expected behavior:
components.d.ts
is "recommended“ (not required), it should just show a warning and still generate a file with the given name.index.d.ts
would make possible to import public interfaces from other type files fromdist/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 https://github.com/ionic-team/stencil/commit/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 foldercomponents
from the same folder, but that was the behaviour I got when tried it myself.