-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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
Disallow truthiness checks on certain literal kinds #59003
base: main
Are you sure you want to change the base?
Conversation
@typescript-bot test this |
@typescript-bot test it I guess I should make that an alias, as two people have done that today... |
Hey @jakebailey, the results of running the DT tests are ready. Everything looks the same! |
@jakebailey Here are the results of running the user tests with tsc comparing Everything looks good! |
@jakebailey Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
@jakebailey Here are the results of running the top 400 repos with tsc comparing Everything looks good! |
|
||
switch (condExpr.kind) { | ||
case SyntaxKind.RegularExpressionLiteral: | ||
case SyntaxKind.FunctionExpression: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aware this is still a draft, but function expressions will almost certainly be a mistyped IIFE, so it might be helpful to separate out a specific error message for these – maybe some sort of "Did you mean to call..." message, à la 2774?
Does this test for the negated forms too? |
@typescript-bot pack this |
Hey @RyanCavanaugh, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build and an npm module you can use via |
|
Gonna find all the bad code now, I think @typescript-bot test it |
Hey @RyanCavanaugh, the results of running the DT tests are ready. There were interesting changes: Branch only errors:Package: ember/v2
Package: ember/v3
Package: react-native-joi
Package: ember
Package: ember__component
Package: hapi__joi
Package: karma-browserstack-launcher
Package: rsvp
Package: ember__component/v3
|
@RyanCavanaugh Here are the results of running the user tests with tsc comparing Something interesting changed - please have a look. Details
|
@RyanCavanaugh Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
6 new errors in vscode based on the benchmarks; it's confusing why the user tests did not say anything there, but maybe top400 will say something. |
Tested manually:
|
@RyanCavanaugh Here are the results of running the top 400 repos with tsc comparing Something interesting changed - please have a look. Details
|
Collated breaks Clearly intentional, albeit weird: optimizeNodes(): this | undefined {
return `${this.code}` ? this : undefined
} Very good find -- catching an operator precedence bug. The checking to allow e.g. if (historyMsgLength > modelConfig?.max_tokens ?? 4000) Good find, maybe someone thought setTheme({ ...theme_setting } || {});
{...prevStyles} || {} Very good find: This project idiomatically does <QuestionTip ml={1} label={publishT('QPM Tips' || '')}></QuestionTip>
// and
label={t('support.outlink.share.Response Quote tips' || '')} ??. Asked about it <Image
src={`https://github.com/${profile?.username}.png` || ''} ??. Asked about it. {
layout: 'vertical' || 'flex',
labelLayout: undefined,
flex: false,
className: 'flex flex-row gap-2 justify-between',
}, |
For |
The webpack one above looks like a bona fide bug: if (typeof value === "string" && /^[+-]?\d*(\.\d*)[eE]\d+$/) This was almost certainly meant to actually run that regex on something. |
Yep, though given the full code is: case "number":
if (typeof value === "number") return value;
if (typeof value === "string" && /^[+-]?\d*(\.\d*)[eE]\d+$/) {
const n = +value;
if (!isNaN(n)) return n;
} I would personally just remove the regex altogether; after all, this block says a number is being parsed, and there's already a saving |
Seeing what a potential fix for #59001 turns up