Skip to content

[NewErrors] 4.7.1-rc vs 4.6.4 #49142

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

Closed
typescript-bot opened this issue May 17, 2022 · 11 comments
Closed

[NewErrors] 4.7.1-rc vs 4.6.4 #49142

typescript-bot opened this issue May 17, 2022 · 11 comments

Comments

@typescript-bot
Copy link
Collaborator

The following errors were reported by 4.7.1-rc, but not by 4.6.4

coder/code-server

6 of 57 projects failed to build with the old tsc

src/tsconfig.json

facebook/docusaurus

31 of 41 projects failed to build with the old tsc

packages/docusaurus-theme-classic/tsconfig.json

reduxjs/react-redux

test/typetests/tsconfig.json

tsconfig.json

react-bootstrap/react-bootstrap

test/tsconfig.json

  • error TS2774: This condition will always return true since this function is always defined. Did you mean to call it instead?

tsconfig.json

  • error TS2774: This condition will always return true since this function is always defined. Did you mean to call it instead?

statelyai/xstate

6 of 20 projects failed to build with the old tsc

packages/xstate-inspect/tsconfig.json

packages/xstate-test/tsconfig.json

palantir/blueprint

3 of 25 projects failed to build with the old tsc

packages/docs-theme/src/tsconfig.json

lensapp/lens

6 of 9 projects failed to build with the old tsc

tsconfig.extension-api.json

tsconfig.json

webpack/tsconfig.json

@Josh-Cena
Copy link
Contributor

Josh-Cena commented May 17, 2022

@DanielRosenwasser
Copy link
Member

I would probably switch to as {}. Unlike unioning a never with other types (where you are enriching the absence of execution with possible executions), spreading a never sort of implies that you should get never out of it.

@Josh-Cena
Copy link
Contributor

Sigh What if I told you that {} is banned by TypeScript-ESLint as well😄 But thanks for that tip, it makes sense. I'll negotiate with my linter.

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented May 18, 2022

Wh-really? Why? Because it insists on using object?

@Josh-Cena
Copy link
Contributor

Yeah, the reason is because {} doesn't do excess property checks and even accepts primitives, so people using it to represent "empty object" would often shoot themselves in the foot. See @typescript-eslint/ban-types

@Josh-Cena
Copy link
Contributor

Josh-Cena commented May 18, 2022

Also, {} doesn't work, because in fact, the compiler only accepts props that's assignable to props of both div and pre, which seems to reduce to never. We'll use as any for now, but I hope there's a better pattern to do this, possibly with oneof generics.

@RyanCavanaugh
Copy link
Member

@RyanCavanaugh
Copy link
Member

I would use as object instead of as any

@Josh-Cena
Copy link
Contributor

Josh-Cena commented May 20, 2022

Ref typescript-eslint/typescript-eslint#5018 (comment)

But as object doesn't fix that particular error😢 I have yet to know a fix

The interesting thing is even not passing any props won't work. I think it's already intersecting to never in the generic body.

@UNIDY2002
Copy link

UNIDY2002 commented May 25, 2022

Hi, I also encountered a similar error after upgrading my TypeScript. I am using AbortController from abort-controller, and here is my code:

import AbortController from "abort-controller";
const controller = new AbortController();
const init: RequestInit = {
    headers: headers,
    signal: controller.signal,
};

TypeScript raises an error saying:

error TS2322: Type 'import("/.../node_modules/abort-controller/dist/abort-controller").AbortSignal' is not assignable to type 'AbortSignal'.

200         signal: controller.signal,
            ~~~~~~

I am wondering is there a proper way to solve this error. Thanks!

@DanielRosenwasser
Copy link
Member

You may want to file a bug on abort-controller or add the following to your package.json and npm install.

{
 "devDependencies": {
    "@typescript/lib-dom": "npm:@types/web"
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants