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

Typescript IssueCommentEvent.issue type is never #395

Closed
danielpza opened this issue Mar 2, 2021 · 6 comments
Closed

Typescript IssueCommentEvent.issue type is never #395

danielpza opened this issue Mar 2, 2021 · 6 comments
Labels
Type: Bug Something isn't working as documented
Projects

Comments

@danielpza
Copy link

danielpza commented Mar 2, 2021

Trying to use type IssueCommentEvent accessing issue property yields never type:

import('@octokit/webhooks-definitions/schema').IssueCommentEvent['issue']

image

I would expect it to have some type, either Issue or some augmentation of it

Perhaps there's some conflict between the Issue type and specific type overwriting it it

@danielpza danielpza added the Type: Bug Something isn't working as documented label Mar 2, 2021
@ghost ghost added this to Bugs in JS Mar 2, 2021
@G-Rath
Copy link
Member

G-Rath commented Mar 2, 2021

That type doesn't resolve to never:

image

image

Could you provide some more information about your setup, such as your IDE and package versions?

@danielpza
Copy link
Author

I'm using emacs with lsp-mode, but I got a similar error using the cli:

$ cat test-issue-type.ts 
type Issue = import('@octokit/webhooks-definitions/schema').IssueCommentEvent['issue'];

const a: Issue = {};

$ tsc --version
Version 4.1.3

$ tsc --noEmit test-issue-type.ts 
test-issue-type.ts:3:7 - error TS2322: Type '{}' is not assignable to type 'never'.

3 const a: Issue = {};
        ~


Found 1 error.
@G-Rath
Copy link
Member

G-Rath commented Mar 2, 2021

What does your tsconfig look like?

Could you also confirm if this happens if you use an static import? (i.e import { IssueCommentEvent } from "@octokit/webhooks-definitions/schema").

@danielpza
Copy link
Author

Yes it happens using static imports

What does your tsconfig look like?

yep, looking at the tsconfig I found I had disabled the strict flag, enabling it fixes the issue, no other relevant modification were done to the tsconfig:

{
  "compilerOptions": {
    "target": "es5",                          /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
    "module": "commonjs",                     /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
    "checkJs": true,                       /* Report errors in .js files. */

    /* Strict Type-Checking Options */
    "strict": false,                           /* Enable all strict type-checking options. */
    "esModuleInterop": true,                  /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */

    /* Advanced Options */
    "skipLibCheck": true,                     /* Skip type checking of declaration files. */
    "forceConsistentCasingInFileNames": true  /* Disallow inconsistently-cased references to the same file. */
  }
}

To be clear changing to strict: true shows the correct type.

@G-Rath
Copy link
Member

G-Rath commented Mar 2, 2021

Interesting, it's because of strictNullChecks - it seems that it doesn't like the fact that closed_at is null so somehow the type becomes type never.

Maybe it's because when that flag is false null is effectively removed, so it's seeing it as never instead? 🤔

Sadly there's not really a lot we can do as the type is correct and valid.
You might have luck over at the TypeScript repo getting this classed as a bug.

@danielpza
Copy link
Author

I think I'm ok with enabling strictNullChecks, thanks for the help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working as documented
2 participants