Comments (11)
Duplicate of #54825.
from typescript.
This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes.
from typescript.
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.
The underlying issue is the same.
from typescript.
@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.
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.
Why no advanced notice?
from typescript.
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.
@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.
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.
Oh no, you are not Owner or Member. I have misunderstood and just noticed it. Sorry.
from typescript.
Related Issues (20)
- `tsc` compile `proposal-explicit-resource-management` different from `babel` and `swc` HOT 1
- After enabling noUncheckedIndexedAccess, using ++ on a default undefined does not trigger an error message. HOT 3
- C++-style `const` modifier on class members HOT 2
- Package Import is not working from neither way "CommonJS" or "Module" HOT 4
- Type guard for child not transitive parent object HOT 3
- Error when compiled JavaScript initializes static properties in a class with a hard private method (`#`) that references a static property
- The ?: inference failed; no selection was made between ifTrue and ifFalse. HOT 1
- Add Support for Flow's new component syntax HOT 6
- Documentation: "Creating and Printing a TypeScript AST" example does not work after v4.9.5
- `satisfies` does not work on a variable called `type`
- API: Can't seem to extract JsDoc tags from declaration HOT 2
- Add option to detect and strip internal exports
- false error on generic type alias parameters HOT 5
- Unable to declare an interface that extends `Record<string, nonAnyType>` with additional support functions. HOT 7
- Add support for generic types on a index accessor HOT 2
- `getTextOfJSDocComment` is stripping `#` from JSDoc comment HOT 1
- Enable `allowJs` with `isolatedDeclarations` HOT 1
- JSDoc comment string with the keyword "@private" before import statement in JS file result in cryptic error TS1191 during compilation HOT 2
- `NoInfer` isn't erased and breaks type narrowing HOT 3
- function with overloading incorrectly defines generic variables HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typescript.