-
-
Notifications
You must be signed in to change notification settings - Fork 40
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
Yarn v2 + Typescript: Typings Issue @types/json-schema missing from dependencies #97
Comments
6 tasks
/cc @arcanis |
Yep. An alternative is to define |
/cc @vankop What decision are we making? |
I am fine with putting it as |
While it's a little bit weird in my opinion, I don't see a better solution than adding it to |
alexander-akait
pushed a commit
that referenced
this issue
May 29, 2020
… (#98) Co-authored-by: Evilebot Tnawi <evilebottnawi@users.noreply.github.com>
Fixed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expected Behavior
When using Yarn v2 Berry Plug-n-Play module resolution, typescript to transpile, and requiring webpack 5 as a dependency, the code should compile without issue.
Actual Behavior
typescript gives this error when trying to compile
Yarn v2 Plug-n-Play is strict (which is a good thing) in that it does not allow a package/workspace to require dependencies which are not listed in its package.json dependencies. Even if I add
@types/json-schema
to my own repo's dev dependencies, it still won't fix the issue. The only way I can solve this issue is to modify the yarn lockfile to add"@types/json-schema": ^7.0.4
to thedependencies
ofschema-utils
.Code
How Do We Reproduce?
I've created a demo repository
git clone https://github.com/AlexLeung/schema-utils-typescript-issue-demo
cd schema-utils-typescript-issue-demo
yarn install
yarn start
Notice all these TypeScript errors related to
json-schema
being missingTo fix, you can:
yarn.lock
schema-utils
and add a new line"@types/json-schema": ^7.0.4
yarn install
yarn start
Now you'll notice that all those
json-schema
errors are gone, but I'll need to open a similar issue on the webpack repo itself to solve the issue withestree
.How Do We Solve?
Move
@types/json-schema
from devDependencies to dependencies.As a general rule, whenever you're writing typescript definitions such as the one for schema-utils, if you're going to include another library's types in the definitions which you export, you need to include that library's types as a dependency rather than a devDependency.
Please review the official TypeScript guidelines on Publishing. https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html See the "Dependencies" section.
The text was updated successfully, but these errors were encountered: