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

Validate existing JavaScript implementation with TypeScript #649

Merged
merged 47 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
7dd2cd4
Add a simple tsconfig.json that allows JavaScript
EzraBrooks Nov 16, 2023
7c2123a
Auto-refactor protos to classes via IntelliSense
EzraBrooks Nov 16, 2023
3b7cc6a
Fix some missing imports
EzraBrooks Nov 16, 2023
1d88c5d
JSDoc syntax fixes for Ros.js
EzraBrooks Nov 16, 2023
c2de695
fix more callback jsdoc issues
EzraBrooks Nov 16, 2023
db78330
fix constructor docs
EzraBrooks Nov 16, 2023
c17d2e6
remove non-type-overlapping superconstructors
EzraBrooks Nov 16, 2023
7e084c7
Comment on weird type
EzraBrooks Nov 16, 2023
1090db7
couple more callback docs
EzraBrooks Nov 16, 2023
92e5c96
Vector3 options actually are optional
EzraBrooks Nov 17, 2023
b1ef2bb
Quaternion options are also actually optional
EzraBrooks Nov 17, 2023
a7d0f05
Pose options are actually optional as well
EzraBrooks Nov 17, 2023
b4970e4
Fix name clobbering in UrdfJoint
EzraBrooks Nov 17, 2023
b5d2314
Fix null case in UrdfSphere
EzraBrooks Nov 17, 2023
2bafd13
fix variable clobbering in `UrdfVisual`
EzraBrooks Nov 17, 2023
193a7b1
fix type of decodeNativeArray
EzraBrooks Nov 17, 2023
a4f01d8
Ignore some issues that aren't trivially fixable
EzraBrooks Nov 17, 2023
5705815
fix XML order of operations issue in urdfmodel
EzraBrooks Nov 17, 2023
e1aea21
Mark last non-trivial errors with ts-expect-error
EzraBrooks Nov 17, 2023
30f4b39
Oops, my autoformat broke single-quote standard
EzraBrooks Nov 17, 2023
2e42eb1
Bump esversion in jshint, decrease it in tsconfig
EzraBrooks Nov 17, 2023
5a4ec44
make jshint happy about "confusing pluses"
EzraBrooks Nov 17, 2023
2515fb8
Fix URDF tests with a quick hack
EzraBrooks Nov 17, 2023
787b89a
less overzealous removal of `options || {}`
EzraBrooks Nov 17, 2023
57f3332
add typescript to grunt
EzraBrooks Nov 17, 2023
3d5b9a1
expect some possible null current implementations
EzraBrooks Nov 17, 2023
24a9d3a
fix some class type errors
EzraBrooks Nov 17, 2023
e5dfbb3
replace deprecated prototype call with super()
EzraBrooks Nov 17, 2023
6c0f71d
Update build output
sea-bass Nov 20, 2023
7e39eff
Use more modern export syntax to enable types
EzraBrooks Nov 27, 2023
c24bc28
fix math index
EzraBrooks Nov 27, 2023
9d9b54b
more type fixes
EzraBrooks Nov 27, 2023
2eb4a98
quaternion type fix
EzraBrooks Nov 27, 2023
b521de2
fix this type AGAIN
EzraBrooks Nov 27, 2023
d607263
fix typescript issues in tests
EzraBrooks Nov 27, 2023
900ccf1
preserve mixin API without using mixin
EzraBrooks Nov 27, 2023
9a142a2
possibly fix topic stream type issues?
EzraBrooks Nov 27, 2023
a98a627
bump jshint again
EzraBrooks Nov 27, 2023
8ccdd43
Have RosTCP return a TopicStream
EzraBrooks Nov 27, 2023
82c438d
adding template types to jsdoc
EzraBrooks Nov 27, 2023
532c31b
simplify build
EzraBrooks Nov 28, 2023
db8e26a
Merge branch 'develop' into add-typescript
EzraBrooks Nov 28, 2023
6770cba
update build
EzraBrooks Nov 28, 2023
5d3b36a
Merge branch 'develop' into add-typescript
EzraBrooks Nov 28, 2023
562dfde
Put ES5 module exports back
EzraBrooks Nov 28, 2023
522ff0b
Merge branch 'develop' into add-typescript
EzraBrooks Dec 14, 2023
8007272
remove extraneous templated tsconfig settings
EzraBrooks Dec 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ doc
node_modules
*.out
*.log
*.tar.gz
*.tar.gz
tsbuild
4 changes: 3 additions & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
"trailing": true,
"quotmark": "single",
"proto": true,
"laxbreak": true
"laxbreak": true,
// TypeScript will compile down to es5.
"esversion": 9
}

42 changes: 18 additions & 24 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,22 @@ module.exports = function(grunt) {

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
shell: {
ts: {
command: 'tsc -p .'
}
},
browserify: {
dist: {
src: ['./src/RosLibBrowser.js'],
src: ['./tsbuild/RosLibBrowser.js'],
dest: './build/roslib.js'
}
},
jshint: {
options: {
jshintrc: true
},
files: [
'./Gruntfile.js',
'./src/**/*.js'
]
files: ['./Gruntfile.js', './src/**/*.js']
},
karma: {
options: {
Expand All @@ -37,19 +39,20 @@ module.exports = function(grunt) {
}
},
test: {
configFile: './test/karma.conf.js',
configFile: './test/karma.conf.js'
},
examples: {
configFile: './test/examples/karma.conf.js',
configFile: './test/examples/karma.conf.js'
},
workersocket: {
configFile: './test/workersocket/karma.conf.js',
},
configFile: './test/workersocket/karma.conf.js'
}
},
mochaTest: {
options: {
reporter: 'spec',
timeout: 5000
reporter: 'spec',
timeout: 5000,
require: 'ts-node/register'
},
test: {
src: ['./test/*.test.js']
Expand All @@ -75,20 +78,14 @@ module.exports = function(grunt) {
options: {
interrupt: true
},
files: [
'./src/**/*.js'
],
files: ['./src/**/*.js'],
tasks: ['browserify']
},
build_and_watch: {
options: {
interrupt: true
},
files: [
'Gruntfile.js',
'.jshintrc',
'./src/**/*.js'
],
files: ['Gruntfile.js', '.jshintrc', './src/**/*.js'],
tasks: ['build']
}
},
Expand All @@ -100,10 +97,7 @@ module.exports = function(grunt) {
},
jsdoc: {
doc: {
src: [
'./src/*.js',
'./src/**/*.js'
],
src: ['./src/*.js', './src/**/*.js'],
options: {
destination: './doc',
configure: 'jsdoc_conf.json'
Expand All @@ -117,7 +111,7 @@ module.exports = function(grunt) {
grunt.registerTask('test-examples', ['mochaTest:examples', 'karma:examples']);
grunt.registerTask('test-tcp', ['mochaTest:tcp']);
grunt.registerTask('test-workersocket', ['karma:workersocket']);
grunt.registerTask('build', ['browserify', 'uglify']);
grunt.registerTask('build', ['shell', 'browserify', 'uglify']);
grunt.registerTask('build_and_watch', ['watch']);
grunt.registerTask('doc', ['clean', 'jsdoc']);
};
49 changes: 49 additions & 0 deletions build/RosLib.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
export = ROSLIB;
/**
* @fileOverview
* @author Russell Toris - rctoris@wpi.edu
*/
/**
* If you use roslib in a browser, all the classes will be exported to a global variable called ROSLIB.
*
* If you use nodejs, this is the variable you get when you require('roslib').
*/
declare var ROSLIB: {
URDF_SPHERE: number;
URDF_BOX: number;
URDF_CYLINDER: number;
URDF_MESH: number;
UrdfBox: typeof import("./urdf/UrdfBox");
UrdfColor: typeof import("./urdf/UrdfColor");
UrdfCylinder: typeof import("./urdf/UrdfCylinder");
UrdfLink: typeof import("./urdf/UrdfLink");
UrdfMaterial: typeof import("./urdf/UrdfMaterial");
UrdfMesh: typeof import("./urdf/UrdfMesh");
UrdfModel: typeof import("./urdf/UrdfModel"); /**
* @default
* @description Library version
*/
UrdfSphere: typeof import("./urdf/UrdfSphere");
UrdfVisual: typeof import("./urdf/UrdfVisual");
TFClient: typeof import("./tf/TFClient");
Pose: typeof import("./math/Pose");
Quaternion: typeof import("./math/Quaternion");
Transform: typeof import("./math/Transform");
Vector3: typeof import("./math/Vector3");
ActionClient: typeof import("./actionlib/ActionClient");
ActionListener: typeof import("./actionlib/ActionListener");
Goal: typeof import("./actionlib/Goal");
SimpleActionServer: typeof import("./actionlib/SimpleActionServer");
Ros: typeof import("./core/Ros");
Topic: typeof import("./core/Topic");
Message: typeof import("./core/Message");
Param: typeof import("./core/Param");
Service: typeof import("./core/Service");
ServiceRequest: typeof import("./core/ServiceRequest");
ServiceResponse: typeof import("./core/ServiceResponse");
/**
* @default
* @description Library version
*/
REVISION: string;
};
1 change: 1 addition & 0 deletions build/RosLibBrowser.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
32 changes: 32 additions & 0 deletions build/RosLibNode.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
declare const _exports: {
Ros: typeof import("./node/RosTCP");
Topic: typeof import("./node/TopicStream");
URDF_SPHERE: number;
URDF_BOX: number;
URDF_CYLINDER: number;
URDF_MESH: number;
UrdfBox: typeof import("./urdf/UrdfBox");
UrdfColor: typeof import("./urdf/UrdfColor");
UrdfCylinder: typeof import("./urdf/UrdfCylinder");
UrdfLink: typeof import("./urdf/UrdfLink");
UrdfMaterial: typeof import("./urdf/UrdfMaterial");
UrdfMesh: typeof import("./urdf/UrdfMesh");
UrdfModel: typeof import("./urdf/UrdfModel");
UrdfSphere: typeof import("./urdf/UrdfSphere");
UrdfVisual: typeof import("./urdf/UrdfVisual");
TFClient: typeof import("./tf/TFClient");
Pose: typeof import("./math/Pose");
Quaternion: typeof import("./math/Quaternion");
Transform: typeof import("./math/Transform");
Vector3: typeof import("./math/Vector3");
ActionClient: typeof import("./actionlib/ActionClient");
ActionListener: typeof import("./actionlib/ActionListener");
Goal: typeof import("./actionlib/Goal");
SimpleActionServer: typeof import("./actionlib/SimpleActionServer");
Message: typeof import("./core/Message");
Param: typeof import("./core/Param");
Service: typeof import("./core/Service");
ServiceRequest: typeof import("./core/ServiceRequest");
ServiceResponse: typeof import("./core/ServiceResponse");
};
export = _exports;
57 changes: 57 additions & 0 deletions build/actionlib/ActionClient.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
export = ActionClient;
/**
* An actionlib action client.
*
* Emits the following events:
* * 'timeout' - If a timeout occurred while sending a goal.
* * 'status' - The status messages received from the action server.
* * 'feedback' - The feedback messages received from the action server.
* * 'result' - The result returned from the action server.
*
*/
declare class ActionClient extends EventEmitter2 {
/**
* @param {Object} options
* @param {Ros} options.ros - The ROSLIB.Ros connection handle.
* @param {string} options.serverName - The action server name, like '/fibonacci'.
* @param {string} options.actionName - The action message name, like 'actionlib_tutorials/FibonacciAction'.
* @param {number} [options.timeout] - The timeout length when connecting to the action server.
* @param {boolean} [options.omitFeedback] - The flag to indicate whether to omit the feedback channel or not.
* @param {boolean} [options.omitStatus] - The flag to indicate whether to omit the status channel or not.
* @param {boolean} [options.omitResult] - The flag to indicate whether to omit the result channel or not.
*/
constructor(options: {
ros: Ros;
serverName: string;
actionName: string;
timeout?: number | undefined;
omitFeedback?: boolean | undefined;
omitStatus?: boolean | undefined;
omitResult?: boolean | undefined;
});
ros: Ros;
serverName: string;
actionName: string;
timeout: number | undefined;
omitFeedback: boolean | undefined;
omitStatus: boolean | undefined;
omitResult: boolean | undefined;
goals: {};
feedbackListener: Topic<any>;
statusListener: Topic<any>;
resultListener: Topic<any>;
goalTopic: Topic<any>;
cancelTopic: Topic<any>;
/**
* Cancel all goals associated with this ActionClient.
*/
cancel(): void;
/**
* Unsubscribe and unadvertise all topics associated with this ActionClient.
*/
dispose(): void;
}
import EventEmitter2_1 = require("eventemitter2");
import EventEmitter2 = EventEmitter2_1.EventEmitter2;
import Ros = require("../core/Ros");
import Topic = require("../core/Topic");
30 changes: 30 additions & 0 deletions build/actionlib/ActionListener.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
export = ActionListener;
/**
* An actionlib action listener.
*
* Emits the following events:
* * 'status' - The status messages received from the action server.
* * 'feedback' - The feedback messages received from the action server.
* * 'result' - The result returned from the action server.
*

*/
declare class ActionListener extends EventEmitter2 {
/**
* @param {Object} options
* @param {Ros} options.ros - The ROSLIB.Ros connection handle.
* @param {string} options.serverName - The action server name, like '/fibonacci'.
* @param {string} options.actionName - The action message name, like 'actionlib_tutorials/FibonacciAction'.
*/
constructor(options: {
ros: Ros;
serverName: string;
actionName: string;
});
ros: Ros;
serverName: string;
actionName: string;
}
import EventEmitter2_1 = require("eventemitter2");
import EventEmitter2 = EventEmitter2_1.EventEmitter2;
import Ros = require("../core/Ros");
48 changes: 48 additions & 0 deletions build/actionlib/Goal.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
export = Goal;
/**
* An actionlib goal that is associated with an action server.
*
* Emits the following events:
* * 'timeout' - If a timeout occurred while sending a goal.
*/
declare class Goal extends EventEmitter2 {
/**
* @param {Object} options
* @param {ActionClient} options.actionClient - The ROSLIB.ActionClient to use with this goal.
* @param {Object} options.goalMessage - The JSON object containing the goal for the action server.
*/
constructor(options: {
actionClient: ActionClient;
goalMessage: any;
});
actionClient: ActionClient;
goalMessage: Message<{
goal_id: {
stamp: {
secs: number;
nsecs: number;
};
id: string;
};
goal: any;
}>;
isFinished: boolean;
status: any;
result: any;
feedback: any;
goalID: string;
/**
* Send the goal to the action server.
*
* @param {number} [timeout] - A timeout length for the goal's result.
*/
send(timeout?: number | undefined): void;
/**
* Cancel the current goal.
*/
cancel(): void;
}
import EventEmitter2_1 = require("eventemitter2");
import EventEmitter2 = EventEmitter2_1.EventEmitter2;
import ActionClient = require("./ActionClient");
import Message = require("../core/Message");
Loading