Skip to content

Change Navigator.connection types#144

Closed
ajuanjojjj wants to merge 3 commits intoapache:masterfrom
ajuanjojjj:master
Closed

Change Navigator.connection types#144
ajuanjojjj wants to merge 3 commits intoapache:masterfrom
ajuanjojjj:master

Conversation

@ajuanjojjj
Copy link
Copy Markdown

Platforms affected

All typescript projects

Motivation and Context

Fixes "Wrong typing for Connection" (#143)

Description

Adds dispatchEvent() to Navigator.connection
Change Connection.type from string to ConnectionType

Testing

Compilating after the changes

Checklist

  • I've run the tests to see all new and existing tests pass
  • I added automated test coverage as appropriate for this change
  • Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • If this Pull Request resolves an issue, I linked to the issue in the text above
  • I've updated the documentation if necessary

@ajuanjojjj
Copy link
Copy Markdown
Author

I tried to run the tests with npm test, but seems like there's no .eslintrc file, so eslint fails.

However, given that this is a TypeScript only issue, I'm not sure it'd do anything, even if the fix introduces problems, unless said file included configuration for the eslint-typescript plugin. Nevertheless, i'd be happy to run further tests if needed

@GitToTheHub
Copy link
Copy Markdown
Contributor

Thanks for the contribution and for taking the time to address the TypeScript issue.

After review, we’re going to close this PR for now.

The proposed typings change introduces API mismatches with this plugin’s actual runtime behavior:

  • connection.type is narrowed in a way that may reject valid values returned by the plugin.
  • dispatchEvent() is added to the typing, but this method is not implemented by the plugin object itself.

So while this does address the original TS compatibility report, it also creates new type-accuracy problems.
If you’d like, feel free to open a follow-up PR with a safer typing approach that keeps DOM compatibility without overstating runtime capabilities.

Thanks again for your work and for raising this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants