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

[Bug] dts-gen causes an error if TypeScript isn't installed #2152

Closed
tasshi-me opened this issue Jun 22, 2023 · 1 comment
Closed

[Bug] dts-gen causes an error if TypeScript isn't installed #2152

tasshi-me opened this issue Jun 22, 2023 · 1 comment
Labels
bug Something isn't working pkg: dts-gen @kintone/dts-gen

Comments

@tasshi-me
Copy link
Member

tasshi-me commented Jun 22, 2023

Summary

Related to kintone/js-sdk-ja#39.

The typescript dependency is missing on @kintone/dts-gen, so dts-gen causes an error during generating type definition file.

Target Package

@kintone/dts-gen

Target Version

v7.0.2

Reproduction

  1. Install @kintone/dts-gen
  2. Run dts-gen
yarn add -D @kintone/dts-gen
kintone-dts-gen --base-url $KINTONE_BASE_URL --api-token $KINTONE_API_TOKEN --app-id $APP_ID --type-name SampleFields --namespace company.name.types -o sample-fields.d.ts

Expected Behavior

User can execute dts-gen successfully without installing typescript manually.
(When installing dts-gen, typescript should be installed automatically)

Actual Behavior

The dts-gen causes an error.

Error: Failed to load plugin '@typescript-eslint' declared in 'BaseConfig » @cybozu/eslint-config/presets/typescript » ../lib/typescript.js': Cannot find module 'typescript'
Require stack:
- /Users/tasshi/Downloads/test-dts-gen/node_modules/@typescript-eslint/eslint-plugin/dist/util/astUtils.js
- /Users/tasshi/Downloads/test-dts-gen/node_modules/@typescript-eslint/eslint-plugin/dist/util/index.js
- /Users/tasshi/Downloads/test-dts-gen/node_modules/@typescript-eslint/eslint-plugin/dist/rules/adjacent-overload-signatures.js
- /Users/tasshi/Downloads/test-dts-gen/node_modules/@typescript-eslint/eslint-plugin/dist/rules/index.js
- /Users/tasshi/Downloads/test-dts-gen/node_modules/@typescript-eslint/eslint-plugin/dist/index.js
- /Users/tasshi/Downloads/test-dts-gen/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
Referenced from: /Users/tasshi/Downloads/test-dts-gen/node_modules/@cybozu/eslint-config/lib/typescript.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
    at Function.Module._load (node:internal/modules/cjs/loader:804:27)
    at Module.require (node:internal/modules/cjs/loader:1028:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/tasshi/Downloads/test-dts-gen/node_modules/@typescript-eslint/eslint-plugin/dist/util/astUtils.js:30:25)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at Module.require (node:internal/modules/cjs/loader:1028:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/tasshi/Downloads/test-dts-gen/node_modules/@typescript-eslint/eslint-plugin/dist/util/astUtils.js',
    '/Users/tasshi/Downloads/test-dts-gen/node_modules/@typescript-eslint/eslint-plugin/dist/util/index.js',
    '/Users/tasshi/Downloads/test-dts-gen/node_modules/@typescript-eslint/eslint-plugin/dist/rules/adjacent-overload-signatures.js',
    '/Users/tasshi/Downloads/test-dts-gen/node_modules/@typescript-eslint/eslint-plugin/dist/rules/index.js',
    '/Users/tasshi/Downloads/test-dts-gen/node_modules/@typescript-eslint/eslint-plugin/dist/index.js',
    '/Users/tasshi/Downloads/test-dts-gen/node_modules/@eslint/eslintrc/dist/eslintrc.cjs'
  ]
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@cybozu/eslint-config includes typescript (and eslint) in peerDeps, so we need to add typescript to our deps manually.
https://github.com/cybozu/eslint-config/blob/master/package.json#L41

$ yarn add -D @kintone/dts-gen
yarn add v1.22.19
warning package.json: No license field
warning No license field
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
warning "@kintone/dts-gen > @cybozu/eslint-config@18.0.3" has unmet peer dependency "typescript@^3.3.3333 || ^4.0.0 || ^5.0.0".
warning "@kintone/dts-gen > @cybozu/eslint-config > @typescript-eslint/eslint-plugin > tsutils@3.21.0" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".

WA: Install typescript manually

Environment

  System:
    OS: macOS 13.4
    CPU: (10) arm64 Apple M1 Max
    Memory: 179.47 MB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 16.17.0 - ~/.nodenv/versions/16.17.0/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 8.19.2 - ~/.nodenv/versions/16.17.0/bin/npm
  npmPackages:
    @kintone/dts-gen: ^7.0.2 => 7.0.2
@tasshi-me
Copy link
Member Author

We decided not to do any implementation to fix it.

TypeScript is specified in peerDeps of @cybozu/eslint-config.
npm and pnpm install peerDeps automatically.
This issue only happens with Yarn.

@tasshi-me tasshi-me closed this as not planned Won't fix, can't repro, duplicate, stale Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pkg: dts-gen @kintone/dts-gen
Projects
None yet
Development

No branches or pull requests

1 participant