-
Notifications
You must be signed in to change notification settings - Fork 76
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
refactor: fixup typescript errors #10295
Conversation
@@ -279,7 +279,13 @@ export class Button | |||
}} | |||
disabled={childElType === "button" ? this.disabled || this.loading : null} | |||
download={ | |||
childElType === "a" && (this.download === "" || this.download) ? this.download : null | |||
childElType === "a" |
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.
with this change, when this.download
is true
, we set the prop as ""
instead.
not required for Stencil, but this is needed for Lit as download
attribute is typed as string
rather than string | boolean
in Lumina for technical reasons (it's one few such special attributes for legacy dom reasons)
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.
This needs to be updated or reverted. It breaks this test.
This change changes how the internal element's download
attribute is applied.
before
after
@@ -43,7 +43,7 @@ import { | |||
import { componentOnReady } from "../../utils/component"; | |||
import { SLOTS as PANEL_SLOTS } from "../panel/resources"; | |||
import { HeadingLevel } from "../functional/Heading"; | |||
import { OverlayPositioning } from "../../components"; | |||
import type { OverlayPositioning } from "../../utils/floating-ui"; |
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.
since components.d.ts will be deleted, I'm changing this to import from the actual origin
@@ -2,7 +2,7 @@ import { FunctionalComponent, h, VNode } from "@stencil/core"; | |||
import { JSXAttributes } from "@stencil/core/internal"; | |||
import { FloatingLayout } from "../../utils/floating-ui"; | |||
|
|||
interface FloatingArrowProps extends JSXAttributes { | |||
interface FloatingArrowProps extends JSXAttributes<SVGSVGElement> { |
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.
this way ref
callback is typed correctly, rather than as broad Element
@@ -113,7 +113,7 @@ export class Link implements InteractiveComponent, LoadableComponent { | |||
When the 'download' property of type 'boolean | string' is set to true, the value is "". | |||
This works around that issue for now. | |||
*/ | |||
download={Tag === "a" && (download === "" || download) ? download : null} | |||
download={Tag === "a" ? (download === true ? "" : download ? download : null) : null} |
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.
same as in button.tsx
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.
Similar to button, this change breaks this test.
@@ -174,7 +174,7 @@ export class Link implements InteractiveComponent, LoadableComponent { | |||
/** the rendered child element */ | |||
private childEl: HTMLAnchorElement | HTMLSpanElement; | |||
|
|||
private childElClickHandler = (event: PointerEvent): void => { | |||
private childElClickHandler = (event: MouseEvent): void => { |
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.
onClick emits MouseEvent, not PointerEvent
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.
FWIW, this might change in the near future since Chrome and Firefox already emit pointer events, and it looks like Safari will soon (adhering to the updated spec).
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.
Thanks for the fyi.
I will revert this change and update Lumina's JSX typings.
For the future, I am looking to automate the process of keeping Lumina's JSX typings up to date with the web platform to fix the DX issue we are having with Maquette and Stencil.
@@ -268,7 +268,7 @@ export class Popover | |||
|
|||
@State() defaultMessages: PopoverMessages; | |||
|
|||
arrowEl: SVGElement; | |||
arrowEl: SVGSVGElement; |
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.
the correct type for the <svg>
element is SVGSVGElement
.
SVGElement
means "any element from the SVG namespace", just like HTMLElement
means "any element from the HTML namespace"
@@ -356,7 +356,7 @@ export class Rating | |||
} | |||
}; | |||
|
|||
private handleInputChange = (event: InputEvent) => { | |||
private handleInputChange = (event: Event) => { |
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.
onChange emits Event
onInput emits InputEvent
@@ -344,7 +344,7 @@ export class Tooltip implements FloatingUIComponent, OpenCloseComponent { | |||
> | |||
<FloatingArrow | |||
floatingLayout={floatingLayout} | |||
ref={(arrowEl: SVGElement) => (this.arrowEl = arrowEl)} | |||
ref={(arrowEl) => (this.arrowEl = arrowEl)} |
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.
no longer need to type this here now that FloatingArrow ref type is typed correctly
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.
these link/script tags seem needless here since they are inserted by _assets/head.ts anyway
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.
Thanks for the cleanup!
BTW, I extracted the demo-related changes to a separate PR to keep this one focused on TS errors.
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.
Sounds good. I will undo those changes in this PR
@@ -1,5 +1,4 @@ | |||
import { Rule } from "eslint"; | |||
// @ts-ignore |
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.
PSA: do not use // @ts-ignore
as it's dangerous.
Reason: once the thing that was causing the TypeScript error is fixed, the // @ts-ignore
comment may remain in the code. In the future, if another TypeScript error may occur in that place, you won't see it because // @ts-ignore
would hide it.
Safer alternative: // @ts-expect-error
- acts just like // @ts-ignore
, except, if no error was reported, TypeScript will complain of needless // @ts-expect-error
(just like it was needless in this case it seems like)
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.
Looking great, @maxpatiiuk! 🚀
Before moving forward, can you address the button and link-related test failures?
@@ -279,7 +279,13 @@ export class Button | |||
}} | |||
disabled={childElType === "button" ? this.disabled || this.loading : null} | |||
download={ | |||
childElType === "a" && (this.download === "" || this.download) ? this.download : null | |||
childElType === "a" |
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.
This needs to be updated or reverted. It breaks this test.
This change changes how the internal element's download
attribute is applied.
before
after
@@ -113,7 +113,7 @@ export class Link implements InteractiveComponent, LoadableComponent { | |||
When the 'download' property of type 'boolean | string' is set to true, the value is "". | |||
This works around that issue for now. | |||
*/ | |||
download={Tag === "a" && (download === "" || download) ? download : null} | |||
download={Tag === "a" ? (download === true ? "" : download ? download : null) : null} |
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.
Similar to button, this change breaks this test.
@@ -174,7 +174,7 @@ export class Link implements InteractiveComponent, LoadableComponent { | |||
/** the rendered child element */ | |||
private childEl: HTMLAnchorElement | HTMLSpanElement; | |||
|
|||
private childElClickHandler = (event: PointerEvent): void => { | |||
private childElClickHandler = (event: MouseEvent): void => { |
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.
FWIW, this might change in the near future since Chrome and Firefox already emit pointer events, and it looks like Safari will soon (adhering to the updated spec).
import { CSS, SUBSTITUTIONS } from "./resources"; | ||
import type { HandleMessages } from "./assets/handle/t9n"; |
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.
This rearrangement causes an import/order
lint error. Can you run the linter to autofix?
If you have a custom groups
option for that rule, I can update ours separately to follow suit.
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.
hmm, interesting that pre-commit hook didn't catch this. maybe my node_modules was out of date 🤔
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.
Thanks for the cleanup!
BTW, I extracted the demo-related changes to a separate PR to keep this one focused on TS errors.
460c6e8
to
0d8576e
Compare
0d8576e
to
a5a393c
Compare
Tooltip e2e test is failing on the CI. |
That's an unstable test (I'll try to stabilize soon). I've triggered another run of E2E tests in the meantime. |
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.
Awesome! Thanks, @maxpatiiuk! 🚀
**Related Issue:** N/A ## Summary Extracts demo page cleanup from #10295. Co-authored-by: Max Patiiuk <max@patii.uk>
…estone-estimates * origin/dev: (997 commits) fix: correct non-standard filled icon names (#10309) fix(panel): initially closed panel should be hidden (#10308) chore(linting): automate tracking of custom Sass functions for stylelint (#10313) chore: tidy up demo pages (#10314) build(deps): update dependency dayjs to v1.11.13 (#10283) build(deps): update dependency jsdom to v24.1.3 (#10298) build(deps): update dependency husky to v9.1.6 (#10318) build(deps): update angular-cli monorepo to v18.2.4 (#10317) docs: update component READMEs (#10316) refactor(stylelint): change config to module format to enable more dynamic options (#10311) refactor: fixup typescript errors (#10295) build(deps): update dependency lint-staged to v15.2.10 (#10302) build(deps): update dependency focus-trap to v7.6.0 (#10281) build(deps): update dependency husky to v9.1.5 (#10297) chore: release next feat(checkbox): add component tokens (#10221) revert: "chore: set default page size for E2E tests (#10219)" (#10299) chore(icons): ensure UI icons follow naming convention (#10292) chore: release next feat: add model-history, raster-function-history, raster function-template-history, raster-tool-history, tool-history (#10305) ...
With the changes in this PR, after running the codemod, there are only 60 TypeScript errors in the Calcite package - those should be best fixed manually after running the codemod.
Now that error count is down to negligible level, will work on migrating tests.