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

fix: typing of terminalObjectFunction (this) #896

Merged
merged 2 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion js/jquery.terminal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type TypeOrPromise<T> = T | PromiseLike<T>;

declare namespace JQueryTerminal {
type interpreterFunction = (this: JQueryTerminal, command: string, term: JQueryTerminal) => any;
type terminalObjectFunction = (...args: (string | number | RegExp)[]) => (void | TypeOrPromise<simpleEchoValue>);
type terminalObjectFunction = (this: JQueryTerminal, ...args: (string | number | RegExp)[]) => (void | TypeOrPromise<simpleEchoValue>);
type Interpreter = string | interpreterFunction | ObjectInterpreter;
type ObjectInterpreter = {
[key: string]: ObjectInterpreter | terminalObjectFunction;
Expand Down
5 changes: 5 additions & 0 deletions test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ $('.term').terminal([obj_interpreter]);
$('.term').terminal(["foo.php", obj_interpreter]);
$('.term').terminal(["foo.php", obj_interpreter, function(command) {
}]);
$('.term').terminal({
help: function () {
this.echo('Help command');
}
});

class Foo {
x: string;
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"lib": ["es2015", "ES2018.Promise", "dom"]
"lib": ["es2015", "ES2018.Promise", "dom"],
"noImplicitThis": true
},
"exclude": ["npm"]
}
Loading