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)
- [ServerErrors][TypeScript] 5.5.0-dev.20240428 HOT 12
- [ServerErrors][JavaScript] 5.5.0-dev.20240428 HOT 9
- Strange runtime caching bug involving `as const` and `const T` generic HOT 1
- When relatively importing a `.d.ts` file in a declaration file, TypeScript loads a `.ts` file instead HOT 7
- Calling decorators with @ loses type safety with function as argument HOT 1
- Include error maps in the typescript libraries for web apis to give developers easy access to potential thrown exceptions HOT 2
- jsdoc @type does not resolve a type
- Removing `node_modules`, running `npm ci` leaves diagnostics behind in ts and tsconfig files
- Module resolution: typeRoots key conflict in cache
- JSDoc @import not detecting use in @callback HOT 2
- Segmentation fault on Node.js 22 HOT 26
- Constraint in generic type forgotten in assignability check
- tsc crash with "TypeError: Cannot read properties of undefined (reading 'flags')" HOT 3
- TS hangs up entire computer, type of variables stuck at "Loading..."
- Use properties of main object as context parameter of function that belongs to property of main object
- staging-typescript website downtime
- Unnecessary any returned from Object.values and Object.entries HOT 9
- Missing reachability error on non-const enum
- Iterators/Generators, next(), and unsafe yield statement types
- Type inference: is that a bug? HOT 1
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.