Giter VIP home page Giter VIP logo

Comments (9)

jcalz avatar jcalz commented on June 22, 2024 6

I'm amazed that people figured out what this issue meant. My brain was imploding trying to understand what could possibly have been the bug: "Why would the () => part matter here? Why is the desired behavior just 'an error' without mentioning, like, what kind of error? Why wouldn't you be allowed to narrow from boolean to true in a type assertion? Wait, has 3 cut in front of 1 and 2 in the number line again? Am I... am I dreaming? This is a dream, isn't it?"

from typescript.

fatcerberus avatar fatcerberus commented on June 22, 2024 4

3 is always cutting in front of 1 and 2, he thinks he's so important having his visage plastered everywhere. Still better than that jerk 7. 6 still needs therapy to this day after witnessing t h e i n c i d e n t

from typescript.

MartinJohns avatar MartinJohns commented on June 22, 2024 2

This is working as intended. Using a type assertion you tell the compiler "shh.. trust me, it's this type, I know what I'm doing..."

@KDwevedi They surely mean the 1 > 3 case.

from typescript.

dragomirtitian avatar dragomirtitian commented on June 22, 2024 1

Maybe I'm just slow today, but why should this trigger an error?

from typescript.

KDwevedi avatar KDwevedi commented on June 22, 2024 1

...I was expecting the above code to be an error, since the 1 < 3 is always false.

Why is 1 < 3 false? < is just the less than comparison operator, correct?

from typescript.

fatcerberus avatar fatcerberus commented on June 22, 2024

@dragomirtitian This is just a guess but maybe OP expects an error because 2 < 3 is always false? But then false as true isn’t an error either so…

from typescript.

jko206 avatar jko206 commented on June 22, 2024

I should have been more clear.

as @fatcerberus mentioned, I was expecting the above code to be an error, since the 1 < 3 is always false.

from typescript.

whzx5byb avatar whzx5byb commented on June 22, 2024

Note that all of these are valid...

const a = false as true;
const b = 'x' as 'y';
const c = 1 as 2;

from typescript.

typescript-bot avatar typescript-bot commented on June 22, 2024

This issue has been marked as "Working as Intended" and has seen no recent activity. It has been automatically closed for house-keeping purposes.

from typescript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.