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

[Bug] element in classic components no longer is a "normal" HTMLElement in the stable types #20485

Closed
boris-petrov opened this issue Jun 29, 2023 · 2 comments · Fixed by #20491
Labels
Bug TypeScript Work on Ember’s types

Comments

@boris-petrov
Copy link
Contributor

🐞 Describe the Bug

Check the repro.

app/components/foo-component.ts:9:18 - error TS2339: Property 'dispatchEvent' does not exist on type 'SimpleElement'.

9     this.element.dispatchEvent(new Event('mousedown'));
                   ~~~~~~~~~~~~~

🔬 Minimal Reproduction

Repo.

Run npm install and then ./node_modules/.bin/tsc.

😕 Actual Behavior

Type error on dispatchEvent.

🤔 Expected Behavior

No error. Removing the last commit (which upgrades Ember) and rerunning npm install and then tsc will remove the errors.

🌍 Environment

  • Ember: 5.1.0
  • Node.js/npm: 20.3.1/9.7.2
  • OS: Linux
  • Browser: N/A

cc @chriskrycho

@chriskrycho
Copy link
Contributor

This is an interesting one and I'm curious to hear other folks' thoughts here—not least because this is a case where the stable types are telling the truth here about what Ember's internals actually assume and promise; but our public API has been that this.element can be assumed to a real Element forever. Our best bet here may be yet another creative lie.

(While I am quite comfortable holding the line in general on our stance that we will not be doing additional work to support Classic classes and features, this one is fairly fundamental to a lot of code bases and I think this should be made to work.)

cc. @jamescdavis @wagenet @gitKrystan

@chriskrycho
Copy link
Contributor

#20491 may be a viable fix here (per my spelunking!). However, I will wait for @wagenet to comment before we merge and cut another release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug TypeScript Work on Ember’s types
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants