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]: InstallationUnsuspendEvent.installation is never #797

Closed
1 task done
chris-feist opened this issue May 16, 2023 · 9 comments
Closed
1 task done

[BUG]: InstallationUnsuspendEvent.installation is never #797

chris-feist opened this issue May 16, 2023 · 9 comments
Labels
Type: Support Any questions, information, or general needs around the SDK or GitHub APIs

Comments

@chris-feist
Copy link

What happened?

TypeScript converts InstallationUnsuspendEvent.installation to type never because it has troubles with the union type

https://github.com/octokit/webhooks/blob/main/payload-types/schema.d.ts#L3516

I'd recommend removing the union since suspended_by and suspended_at can already be null. Alternatively the fields could be omitted.

  installation: Installation;
  
// or

  installation: Omit<Installation, 'suspended_by' | 'suspended_at'> & {
    suspended_by: null;
    suspended_at: null;
  };

Versions

@octokit/webhooks-types: 6.11.0
typescript: 4.1.3

Relevant log output

The intersection 'Installation & { suspended_by: null; suspended_at: null; }' was reduced to 'never' because property 'suspended_at' has conflicting types in some constituents.

Code of Conduct

  • I agree to follow this project's Code of Conduct
@chris-feist chris-feist added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels May 16, 2023
@wolfy1339
Copy link
Member

Can you share your tsconfig?

If you don't have strict enabled, it resolves to never

@chris-feist
Copy link
Author

I have the default setting for strict. Here is my config:

// tsconfig.json
{
  "extends": "./tsconfig.paths.json",
  "compilerOptions": {
    "lib": ["ESNext"],
    "moduleResolution": "node",
    "removeComments": true,
    "sourceMap": true,
    "target": "ESNext",
    "outDir": "lib",
    "skipLibCheck": true
  },
  "include": ["src/**/*.ts", "serverless.ts"],
  "exclude": [
    "node_modules/**/*",
    ".serverless/**/*",
    ".webpack/**/*",
    "_warmup/**/*",
    ".vscode/**/*"
  ],
  "ts-node": {
    "require": ["tsconfig-paths/register"]
  }
}
// tsconfig.paths.json
{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@functions/*": ["src/functions/*"],
      "@languages/*": ["src/languages/*"],
      "@src/*": ["src/*"],
      "@utils/*": ["src/utils/*"]
    }
  }
}

@wolfy1339
Copy link
Member

At the very minimum, we require that the strictNullChecks be enabled.

The default value for strict is false (which includes strictNullChecks)

@wolfy1339 wolfy1339 added Type: Support Any questions, information, or general needs around the SDK or GitHub APIs and removed Type: Bug Something isn't working as documented Status: Triage This is being looked at and prioritized labels May 16, 2023
@chris-feist
Copy link
Author

Is there a reason for not updating the type to support both tsconfig options?

@wolfy1339 wolfy1339 closed this as not planned Won't fix, can't repro, duplicate, stale May 16, 2023
@github-project-automation github-project-automation bot moved this from 🆕 Triage to ✅ Done in 🧰 Octokit Active May 16, 2023
@wolfy1339
Copy link
Member

Even with that change, you still need strictNullChecks in order to use the types.

@wolfy1339
Copy link
Member

wolfy1339 commented May 16, 2023

See #395 also for more info

@chris-feist
Copy link
Author

While I can confirm that strictNullChecks: true does remove the error, my suggestions also remove the error. If you wanted to force suspended_at and suspended_by to null, then the Omit approach I suggested would be the best path forward. I put together this example:

https://stackblitz.com/edit/typescript-4gwo1b?file=index.ts

@wolfy1339
Copy link
Member

That isn't a viable solution. The types are autogenerated from our JSON schema

@chris-feist
Copy link
Author

Okay, makes sense then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Support Any questions, information, or general needs around the SDK or GitHub APIs
Projects
Archived in project
Development

No branches or pull requests

2 participants