dojo / dojo/typings

EventedConstructor incorrectly typed

Open
#113 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
29
Forks
35
PR merge metrics
No merged PRs in 30d

Description

`Evented` isn't created with `declare`. It's a traditional es5 class function.

```
define(["./aspect", "./on"], function(aspect, on){
// module:
// dojo/Evented

"use strict";
var after = aspect.after;
function Evented(){
// summary:
// A class that can be used as a mixin or base class,
// to add on() and emit() methods to a class
// for listening for events and emitting events:
// example:
// | define(["dojo/Evented", "dojo/_base/declare", "dojo/Stateful"
// | ], function(Evented, declare, Stateful){
// | var EventedStateful = declare([Evented, Stateful], {...});
// | var instance = new EventedStateful();
// | instance.on("open", function(event){
// | ... do something with event
// | });
// |
// | instance.emit("open", {name:"some event", ...});
}
Evented.prototype = {
on: function(type, listener){
return on.parse(this, type, listener, function(target, type){
return after(target, 'on' + type, listener, true);
});
},
emit: function(type, event){
var args = [this];
args.push.apply(args, arguments);
return on.emit.apply(on, args);
}
};
return Evented;
});
```

This needs fixing:

```
interface EventedConstructor extends _base.DeclareConstructor {
new (params?: Object): Evented;
}
```

Contributor guide

Open the contributing guide

Research direction

Locate the EventedConstructor declaration in the Dojo typings and compare it with the Evented ES5 constructor shown in the issue. Update the declaration to reflect that constructor, then run the repository's available TypeScript validation or typing checks to confirm it is accepted.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.