Skip to content
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

@ts-expect-error chipaway #1366

Open
20 of 34 tasks
marlitas opened this issue Dec 8, 2022 · 19 comments
Open
20 of 34 tasks

@ts-expect-error chipaway #1366

marlitas opened this issue Dec 8, 2022 · 19 comments
Assignees

Comments

@marlitas
Copy link
Contributor

marlitas commented Dec 8, 2022

Remove unnecessary @ts-expect-errors, or add a comment explaining why it is necessary.

Results from chipAway:

samreid added a commit to phetsims/circuit-construction-kit-dc that referenced this issue Dec 8, 2022
pixelzoom added a commit to phetsims/molecule-polarity that referenced this issue Dec 8, 2022
pixelzoom added a commit to phetsims/scenery-phet that referenced this issue Dec 8, 2022
jessegreenberg added a commit to phetsims/quadrilateral that referenced this issue Dec 8, 2022
@pixelzoom
Copy link
Contributor

I've addressed the ts-expect-errors in molecule-polarity and scenery-phet. The 3 in natural-selection all have (blocked) issues noted, and I'm expecting to remove them as those issues are addressed. Unassigning.

@pixelzoom pixelzoom removed their assignment Dec 8, 2022
@jessegreenberg
Copy link
Contributor

I reviewed my repos and ended up leaving most of my @ts-expect-errors in quadrilateral, utterance-queue, and tappi. They all involved prototype code or experimental technology (Web Bluetooth API, Vibration API, that kind of thing).

@jessegreenberg jessegreenberg removed their assignment Dec 8, 2022
@pixelzoom
Copy link
Contributor

pixelzoom commented Dec 8, 2022

@jessegreenberg That's great. But looking at utterance-queue, the majority of those @ts-expect-errors have either no associated comment, or a comment that's not very useful (e.g. "Don't judge me TypeScript..."). So there's no way that the reader is going to know that those are prototype or experimental source files.

@jessegreenberg
Copy link
Contributor

jessegreenberg commented Dec 8, 2022

I agree! Those comments were fun at the time but not so informative. They were updated in previous commits (I should have mentioned in my comment). Feel free to pull master to verify.

@veillette
Copy link
Contributor

The @ts-expect-error in Calculus-Grapher was addressed.

@zepumph
Copy link
Member

zepumph commented Dec 12, 2022

There are still 10 usages of @ts-expect-error in joist. This is due to:

@pixelzoom
Copy link
Contributor

pixelzoom commented Dec 15, 2022

In #1366 (comment), @AgustinVallejo said:

The two in My Solar System are not avoidable... One is inherited logic from bamboo/BarPlot, and the other one has to do with multilink handling of mapped arrays.

The one in CommonModel.ts (Multilink) is very avoidable. Here’s the diff:

-    // @ts-expect-error (multilink doesn't like non-tuple arrays for TypeScript, but works perfectly fine)
-    Multilink.multilink( this.availableBodies.map( body => body.isActiveProperty ), () => {
+    Multilink.multilinkAny( this.availableBodies.map( body => body.isActiveProperty ), () => {

When you have a Multilink or DerivedProperty that has an unknown number of dependencies, use Multilink.multilinkAny and DerivedProperty.deriveAny respectively.

samreid added a commit to phetsims/circuit-construction-kit-common that referenced this issue Dec 15, 2022
samreid added a commit to phetsims/circuit-construction-kit-common that referenced this issue Dec 15, 2022
@samreid
Copy link
Member

samreid commented Dec 15, 2022

We have started using @ts-expect-error as a way of doing "type check" unit tests. These @ts-expect-error should not be removed or considered in metrics with the "bad" ones. Should we standardize something to indicate this, like:

// @ts-expect-error for testing

@zepumph
Copy link
Member

zepumph commented Dec 15, 2022

How about // @ts-expect-error INTENTIONAL - doc here? @samreid and I feel like intentional is already what we use for IntentionalAny.

@pixelzoom
Copy link
Contributor

pixelzoom commented Dec 15, 2022

That's fine too, as long the doc here part is not optional. There needs to be information about why it's intentional.

@samreid
Copy link
Member

samreid commented Dec 16, 2022

That's fine too, as long the doc here part is not optional. There needs to be information about why it's intentional.

Perhaps one day a bad-typescript-text rule will enforce this.

@zepumph
Copy link
Member

zepumph commented Dec 16, 2022

With this patch:

Subject: [PATCH] NumberProperty.reset handles issues with setting range or Property first, https://github.com/phetsims/axon/issues/427
---
Index: eslint/rules/bad-typescript-text.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/eslint/rules/bad-typescript-text.js b/eslint/rules/bad-typescript-text.js
--- a/eslint/rules/bad-typescript-text.js	(revision f1bf431c9398154880ddd568dfd351931bf5633d)
+++ b/eslint/rules/bad-typescript-text.js	(date 1671229930872)
@@ -49,6 +49,10 @@
     {
       id: '@returns with type and/or without extra doc',
       regex: /(@returns \{)|(@returns *$)/
+    },
+    {
+      id: '@ts-expect-error needs documentation',
+      regex: /@ts-expect-error\s*$/
     }
   ];
 

We only have 88 problems:

✖ 88 problems (88 errors, 0 warnings)

Results from chipAway:

@samreid
Copy link
Member

samreid commented Dec 16, 2022

Are there ts-expect-errors in axon that weren't discovered in the above comment?

@zepumph
Copy link
Member

zepumph commented Dec 19, 2022

Probably!

jbphet pushed a commit to phetsims/joist that referenced this issue Dec 19, 2022
jbphet pushed a commit to phetsims/joist that referenced this issue Dec 19, 2022
@jessegreenberg jessegreenberg self-assigned this Dec 22, 2022
jessegreenberg added a commit to phetsims/utterance-queue that referenced this issue Dec 22, 2022
@jessegreenberg jessegreenberg removed their assignment Dec 22, 2022
@marlitas
Copy link
Contributor Author

SR: I would like some help with tricky Axon ts-expect-errors
JO: I can help

Thanks JO!

samreid added a commit to phetsims/axon that referenced this issue Dec 23, 2022
samreid added a commit to phetsims/axon that referenced this issue Dec 23, 2022
marlitas added a commit to phetsims/axon that referenced this issue Dec 29, 2022
@samreid
Copy link
Member

samreid commented Jan 4, 2023

I finished the Circuit Construction Kit ones as part of phetsims/circuit-construction-kit-common#918

@samreid samreid removed their assignment Feb 14, 2023
zepumph pushed a commit to phetsims/perennial that referenced this issue Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants