Skip to content

Commit

Permalink
Mark last non-trivial errors with ts-expect-error
Browse files Browse the repository at this point in the history
  • Loading branch information
EzraBrooks committed Nov 17, 2023
1 parent 43cfd96 commit 619c2d9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
6 changes: 6 additions & 0 deletions src/actionlib/SimpleActionServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class SimpleActionServer extends EventEmitter2 {
// needs to happen AFTER rest is set up
that.emit("cancel");
} else {
// @ts-expect-error -- we need to design a way to handle arbitrary fields in Message types.
that.statusMessage.status_list = [
{ goal_id: goalMessage.goal_id, status: 1 },
];
Expand Down Expand Up @@ -156,7 +157,9 @@ class SimpleActionServer extends EventEmitter2 {
var nsecs = Math.round(
1000000000 * (currentTime.getTime() / 1000 - secs)
);
// @ts-expect-error -- we need to design a way to handle arbitrary fields in Message types.
that.statusMessage.header.stamp.secs = secs;
// @ts-expect-error -- we need to design a way to handle arbitrary fields in Message types.
that.statusMessage.header.stamp.nsecs = nsecs;
statusPublisher.publish(that.statusMessage);
}, 500); // publish every 500ms
Expand All @@ -173,6 +176,7 @@ class SimpleActionServer extends EventEmitter2 {
});
this.resultPublisher.publish(resultMessage);

// @ts-expect-error -- we need to design a way to handle arbitrary fields in Message types.
this.statusMessage.status_list = [];
if (this.nextGoal) {
this.currentGoal = this.nextGoal;
Expand All @@ -194,6 +198,7 @@ class SimpleActionServer extends EventEmitter2 {
});
this.resultPublisher.publish(resultMessage);

// @ts-expect-error -- we need to design a way to handle arbitrary fields in Message types.
this.statusMessage.status_list = [];
if (this.nextGoal) {
this.currentGoal = this.nextGoal;
Expand All @@ -219,6 +224,7 @@ class SimpleActionServer extends EventEmitter2 {
* Handle case where client requests preemption.
*/
setPreempted() {
// @ts-expect-error -- we need to design a way to handle arbitrary fields in Message types.
this.statusMessage.status_list = [];
var resultMessage = new Message({
status: { goal_id: this.currentGoal.goal_id, status: 2 },
Expand Down
1 change: 1 addition & 0 deletions src/core/Ros.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class Ros extends EventEmitter2 {
connect(url) {
if (this.transportLibrary === "socket.io") {
this.socket = assign(
// @ts-expect-error -- this doesn't seem to work
io(url, { "force new connection": true }),
socketAdapter(this)
);
Expand Down
2 changes: 2 additions & 0 deletions src/node/SocketIO.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class SocketIO {
this.socketio = null;
this.socket = Ros.socket;
if (options.http) {
// @ts-expect-error -- this doesn't seem to work.
this.socketio = io(options.http);
} else if (options.socketio) {
this.socketio = options.socketio;
Expand All @@ -28,6 +29,7 @@ class SocketIO {
}
sendToFront(name, event) {
return function (event) {
// @ts-expect-error -- this doesn't seem to work.
this.socketio.emit(name, event);
};
}
Expand Down
18 changes: 9 additions & 9 deletions src/node/TopicStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ var DuplexStream = require('stream').Duplex;
* Publish a connected ROS topic to a duplex
* stream. This stream can be piped to, which will
* publish to the topic.
*
* @param {Object} options
* @param {boolean} [options.subscribe=true] - The flag to indicate whether to subscribe to the topic and start emitting data or not.
* @param {boolean} [options.publish=true] - The flag to indicate whether to register the stream as a publisher to the topic or not.
* @param {boolean} [options.transform] - A function to change the data to be published or filter it if false is returned.
*/
*
* @param {Object} options
* @param {boolean} [options.subscribe=true] - The flag to indicate whether to subscribe to the topic and start emitting data or not.
* @param {boolean} [options.publish=true] - The flag to indicate whether to register the stream as a publisher to the topic or not.
* @param {function} [options.transform] - A function to change the data to be published or filter it if false is returned.
*/
// @ts-expect-error -- prototype call here is unhappy - maybe we need to get rid of this or roll it into Topic.
Topic.prototype.toStream = function(options) {
options = options || {subscribe: true, publish: true};

var topic = this;
var hasTransform = typeof options.transform === 'function';

var stream = new DuplexStream({
objectMode: true
Expand All @@ -24,8 +24,8 @@ Topic.prototype.toStream = function(options) {

// Publish to the topic if someone pipes to stream
stream._write = function(chunk, encoding, callback) {
if (hasTransform) {
chunk = options.transform(chunk);
if (typeof options.transform === "function") {
chunk = options.transform(chunk);
}
if (chunk === false) {
topic.publish(chunk);
Expand Down

0 comments on commit 619c2d9

Please sign in to comment.