Closed
Bug 1950401
Opened 28 days ago
Closed 25 days ago
Figure out how to make TypeScript work with classes that implement idl interfaces with constants
Categories
(Developer Infrastructure :: Lint and Formatting, task, P3)
Developer Infrastructure
Lint and Formatting
Tracking
(firefox137 fixed)
RESOLVED
FIXED
137 Branch
Tracking | Status | |
---|---|---|
firefox137 | --- | fixed |
People
(Reporter: standard8, Assigned: zombie)
References
(Blocks 1 open bug)
Details
(Whiteboard: [addons-jira])
Attachments
(1 file)
We have an nsIAutoCompleteResult
interface, for which the definition starts off like:
interface nsIAutoCompleteResult : nsISupports
{
const unsigned short RESULT_IGNORED = 1; /* indicates invalid searchString */
const unsigned short RESULT_FAILURE = 2; /* indicates failure */
...
I have a class which implements it, so for TypeScript to understand this, I'm adding an annotation:
/**
* @implements {nsIAutoCompleteResult}
*/
class SearchHistoryResult {
...
However, this fails with:
Type 'SearchHistoryResult' is missing the following properties from type 'nsIAutoCompleteResult': RESULT_IGNORED, RESULT_FAILURE, RESULT_NOMATCH, RESULT_SUCCESS, and 2 more.
:zombie suggested doing something like @implements {Omit<nsIAutoCompleteResult, "RESULT_IGNORED"|"RESULT_NOMATCH"|"RESULT_NOMATCH"|"RESULT_FAILURE"|"RESULT_SUCCESS"|"RESULT_NOMATCH_ONGOING"|"RESULT_SUCCESS_ONGOING">}
however, that then runs into issues when we try to pass the class to a function that takes an nsIAutoCompleteResult
:
Argument of type 'SearchHistoryResult' is not assignable to parameter of type 'nsIAutoCompleteResult'.
Type 'SearchHistoryResult' is missing the following properties from type 'nsIAutoCompleteResult': RESULT_IGNORED, RESULT_FAILURE, RESULT_NOMATCH, RESULT_SUCCESS, and 2 more.
Assignee | ||
Updated•27 days ago
|
Whiteboard: [addons-jira]
Updated•27 days ago
|
Assignee | ||
Comment 1•27 days ago
|
||
Updated•27 days ago
|
Assignee: nobody → tomica
Status: NEW → ASSIGNED
Pushed by tjovanovic@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/61095d707c5b
Mark constants (and enum variants) in xpcom interfaces as optional r=Standard8
Comment 3•25 days ago
|
||
bugherder |
Status: ASSIGNED → RESOLVED
Closed: 25 days ago
status-firefox137:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → 137 Branch
You need to log in
before you can comment on or make changes to this bug.
Description
•