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

Dist files contain references to @nextcloud/typings put is not declared as peer dep #609

Closed
skjnldsv opened this issue Apr 16, 2023 · 8 comments · Fixed by #610
Closed

Comments

@skjnldsv
Copy link
Contributor

Example: https://www.runpkg.com/?@nextcloud/l10n@2.1.0/dist/registry.d.ts

Importing and building might/will generate errors in other libs if they don't use @nextcloud/typing themselves

Ref nextcloud-libraries/nextcloud-files#621
cc @ChristophWurst @susnux

@skjnldsv skjnldsv changed the title Dist files contain refernces to @nextcloud/typings put is not declared as peer dep Dist files contain references to @nextcloud/typings put is not declared as peer dep Apr 16, 2023
@susnux
Copy link
Contributor

susnux commented Apr 17, 2023

I am still not sure if peer dependency or plain dependency is the correct way, what do you think?

@skjnldsv
Copy link
Contributor Author

Peer is automatically installed if you import the library.
Runtime is not really fitting here too as this is for typings only 🤔

@ChristophWurst
Copy link
Contributor

Peer means it's pushed down as dependency of packages that require this package. I don't think that is necessary. The typings are a dev dep of this package.

@skjnldsv
Copy link
Contributor Author

But they end up in the dist folder. Which still generates errors for other packages.

@ChristophWurst
Copy link
Contributor

Same issue with the router

> tsc

node_modules/@nextcloud/router/dist/index.d.ts:1:23 - error TS2688: Cannot find type definition file for '@nextcloud/typings'.

1 /// <reference types="@nextcloud/typings" />
                        ~~~~~~~~~~~~~~~~~~

@ChristophWurst
Copy link
Contributor

If typings are part of dist, doesn't that even make them regular dependencies?

Peer dependencies might create a dependency hell. Imagine we have to packages @nextcloud/a and @nextcloud/b. @nextcloud/a depends on typings v3, @nextcloud/b uses typings v4. If they had the typings as peer dependencies, an app would not be able to install a and b because it would become impossible to satisfy both a's and b's requirements.
If the typings are dev dependencies, they do not get installed.
If the typings are regular dependencies then npm's deep hierarchy allows the parallel installation of typings in v3 and v4.

@ChristophWurst
Copy link
Contributor

We also can't be the first ones to run into this. I'm sure other packages faced the same challenge.

@ChristophWurst
Copy link
Contributor

https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html#dependencies so regular dependencies it is.

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