Coder Social home page Coder Social logo

Comments (11)

MartinJohns avatar MartinJohns commented on May 1, 2024 3

Duplicate of #54825.

from typescript.

typescript-bot avatar typescript-bot commented on May 1, 2024 2

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

from typescript.

uhyo avatar uhyo commented on May 1, 2024

I doubt this is a duplicate. The linked issue is all about whether TS should know that 0 < 1, while this issue only requires the knowledge that 0 === 0, which TS already uses in many places.

Also the linked issue mentions another issue ( #48536 (comment) ) but that's a different topic too. This issue does not include any request to reason about β€œor” logics.

from typescript.

MartinJohns avatar MartinJohns commented on May 1, 2024

The underlying issue is the same.

from typescript.

tats-u avatar tats-u commented on May 1, 2024

@MartinJohns You have said that that issue is difficult to be fixed for a "design limitation", but this is a more limited form and easier to be fixed. This issue must not be closed just because of the combination of the "duplication" and that "design limitation".

from typescript.

tats-u avatar tats-u commented on May 1, 2024

I have added an additional limitation that the fallback value is the same as the value of the other operand of the equality or non-or-equal comparison (< or >) operator.

from typescript.

tats-u avatar tats-u commented on May 1, 2024

Why no advanced notice?

from typescript.

MartinJohns avatar MartinJohns commented on May 1, 2024

Reopen and remove Duplilate

Ryan considers it a duplicate, that's why he marked the issue as such. He surely read your comment, but it doesn't change anything. The underlaying issue is still the same. Type narrowing is done on variables, not expressions. By adding the ?? 0 to bar?.length you're not checking anything bar related for truthiness anymore, but the entire expression, so bar is not narrowed. Changing that would require a lot of changes in the code base.

Why no advanced notice?

It's been marked as Duplicate for 4 days. That's the advance notice.

from typescript.

tats-u avatar tats-u commented on May 1, 2024

@MartinJohns Do you mean #48536 (comment) ?
a ?? "" === "" is as simple as typeof a === "b". The only differences are:

  • the fallback value propagated from the left operand expression when a is nullish is vary from a single value ("undefined")
  • ?? is a binary instead of unary

FYI C# 8.0+'s null flow analysis can recognize this pattern. You will be able to get its specification from https://ecma-international.org/publications-and-standards/standards/ecma-334/ next year. This patern might as well be considered to be added to the backlog.

TS may not be able to handle the type number (not nullish) | 0 (nullish) unlike ("string" | "nunber" | ...) | "undefined" in a expression.

It's been marked as Duplicate for 4 days. That's the advance notice.

FYI, https://github.com/actions/stale, which has been famous, politely writes a post before closing, but your bot does not. However I do not require the bot to be improved because this improvement is just a bullshit job for your team and even hell can be home.

from typescript.

MartinJohns avatar MartinJohns commented on May 1, 2024

Please note that I am not a member of the TypeScript team. It's not my bot.

Besides that, the bot did write a polite comment before closing the issue.

from typescript.

tats-u avatar tats-u commented on May 1, 2024

Oh no, you are not Owner or Member. I have misunderstood and just noticed it. Sorry.

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.