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]: Octokit v4 types #2677

Closed
1 task done
klippx opened this issue May 8, 2024 · 8 comments
Closed
1 task done

[BUG]: Octokit v4 types #2677

klippx opened this issue May 8, 2024 · 8 comments
Labels
Status: Needs Info Full requirements are not yet known, so implementation should not be started Type: Bug Something isn't working as documented typescript Relevant to TypeScript users only

Comments

@klippx
Copy link

klippx commented May 8, 2024

What happened?

TS does not seem to like the import("@octokit/core/types").Constructor or any such import, it resolves to any as you can see in the screenshot when I hover it:

Screenshot 2024-05-08 at 15 18 42

This causes my ts-eslint to panic Unsafe assignment of an any value.eslint[@typescript-eslint/no-unsafe-assignment](https://typescript-eslint.io/rules/no-unsafe-assignment), but since it is opt-in most people might not even notice they start getting any all over the place.

My .eslintrc.js

module.exports = {
  extends: [
    'eslint:recommended',
    'plugin:@typescript-eslint/recommended-type-checked',
    'plugin:@typescript-eslint/stylistic-type-checked',
    'plugin:import/errors',
    'plugin:import/typescript',
    'prettier',
  ],
  plugins: ['@typescript-eslint'],
  parser: '@typescript-eslint/parser',
  parserOptions: {
    project: true,
    tsconfigRootDir: __dirname,
  },
  root: true,
  settings: {
    'import/parsers': {
      '@typescript-eslint/parser': ['.d.ts', '.ts', '.tsx'],
    },
    'import/resolver': {
      typescript: {
        // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
        alwaysTryTypes: true,
        // Choose from one of the "project" configs below or omit to use <root>/tsconfig.json by default
        project: '<root>/tsconfig.json',
      },
    },
  },
}

Related to #2676

Versions

Octokit.js 4.0.1

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@klippx klippx added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels May 8, 2024
Copy link

github-actions bot commented May 8, 2024

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@wolfy1339
Copy link
Member

What is your tsconfig?

@gr2m
Copy link
Contributor

gr2m commented May 8, 2024

can you test again with the latest version? We had a build config bug that was resolved in v4.0.2

@gr2m gr2m added typescript Relevant to TypeScript users only and removed Status: Triage This is being looked at and prioritized labels May 8, 2024
@northword
Copy link

seems stil:

image

image

my tsconfig:

{
  "compilerOptions": {
    "target": "ESNext",
    "module": "ESNext",
    "moduleResolution": "Node",
    "esModuleInterop": true,
    "strict": true,
    "resolveJsonModule": true,
    "declaration": true,
    "outDir": "dist",
    "skipLibCheck": true,
    "rootDir": "src"
  },
  "include": ["src", "types", "bin"]
}

Currently using 4.0.2, works fine on 3.1.2.

@wolfy1339
Copy link
Member

Please read up https://www.typescriptlang.org/docs/handbook/modules/reference.html#packagejson-exports
and https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

This is an error with your tsconfig.json, you have to use either node16 or nodenext modules and moduleresolution

@wolfy1339 wolfy1339 added the Status: Needs Info Full requirements are not yet known, so implementation should not be started label May 14, 2024
@northword
Copy link

Oh very sorry for taking up your time because of my problem, I made changes based on your suggestions and have fixed the problem, thanks!

@wolfy1339
Copy link
Member

The original author hasn't responded, and given that #2676 was resolved and that this seems like a case of misconfigured TypeScript, I will close this

@wolfy1339 wolfy1339 closed this as not planned Won't fix, can't repro, duplicate, stale May 14, 2024
@klippx
Copy link
Author

klippx commented May 17, 2024

Yes, my project was not correctly in ESM, not in terms of typescript. After applying NodeNext and absolute imports octokit works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Info Full requirements are not yet known, so implementation should not be started Type: Bug Something isn't working as documented typescript Relevant to TypeScript users only
Projects
Archived in project
Development

No branches or pull requests

4 participants