Skip to content

Commit 18cc336

Browse files
fix: narrowing platform to be either win or mac (#5707)
Co-authored-by: Marin Sokol <[email protected]>
1 parent ff16482 commit 18cc336

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

src/commands/command_manager.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var EventEmitter = require("../lib/event_emitter").EventEmitter;
1010
class CommandManager extends MultiHashHandler{
1111
/**
1212
* new CommandManager(platform, commands)
13-
* @param {String} platform Identifier for the platform; must be either `"mac"` or `"win"`
13+
* @param {import("../keyboard/hash_handler").Platform} platform Identifier for the platform; must be either `"mac"` or `"win"`
1414
* @param {any[]} commands A list of commands
1515
**/
1616
constructor(platform, commands) {

src/keyboard/hash_handler.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,22 @@
99
var useragent = require("../lib/useragent");
1010
var KEY_MODS = keyUtil.KEY_MODS;
1111

12+
/**
13+
* @typedef {"win" | "mac"} Platform
14+
*/
15+
1216
class MultiHashHandler {
1317
/**
1418
* @param {Record<string, CommandLike> | Command[]} [config]
15-
* @param {string} [platform]
19+
* @param {Platform} [platform]
1620
*/
1721
constructor(config, platform) {
1822
this.$init(config, platform, false);
1923
}
2024

2125
/**
2226
* @param {Record<string, CommandLike> | Command[]} config
23-
* @param {string} [platform]
27+
* @param {Platform} [platform]
2428
* @param {boolean} [$singleCommand]
2529
*/
2630
$init(config, platform, $singleCommand) {
@@ -281,7 +285,7 @@ function getPosition(command) {
281285
class HashHandler extends MultiHashHandler {
282286
/**
283287
* @param {Record<string, CommandLike> | Command[]} [config]
284-
* @param {string} [platform]
288+
* @param {Platform} [platform]
285289
*/
286290
constructor(config, platform) {
287291
super(config, platform);

types/ace-modules.d.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -1847,14 +1847,15 @@ declare module "ace-code/src/search" {
18471847
declare module "ace-code/src/keyboard/hash_handler" {
18481848
export type Command = import("ace-code").Ace.Command;
18491849
export type CommandLike = import("ace-code").Ace.CommandLike;
1850+
export type Platform = "win" | "mac";
18501851
export class HashHandler extends MultiHashHandler {
18511852
}
18521853
export namespace HashHandler {
18531854
function call(thisArg: any, config: any, platform: any): void;
18541855
}
18551856
export class MultiHashHandler {
1856-
constructor(config?: Record<string, CommandLike> | Command[], platform?: string);
1857-
platform: string;
1857+
constructor(config?: Record<string, CommandLike> | Command[], platform?: Platform);
1858+
platform: Platform;
18581859
commands: Record<string, Command>;
18591860
commandKeyBinding: {};
18601861
addCommand(command: Command): void;
@@ -1890,10 +1891,10 @@ declare module "ace-code/src/commands/command_manager" {
18901891
export class CommandManager extends MultiHashHandler {
18911892
/**
18921893
* new CommandManager(platform, commands)
1893-
* @param {String} platform Identifier for the platform; must be either `"mac"` or `"win"`
1894+
* @param {import("ace-code/src/keyboard/hash_handler").Platform} platform Identifier for the platform; must be either `"mac"` or `"win"`
18941895
* @param {any[]} commands A list of commands
18951896
**/
1896-
constructor(platform: string, commands: any[]);
1897+
constructor(platform: import("ace-code/src/keyboard/hash_handler").Platform, commands: any[]);
18971898
byName: Record<string, import("ace-code").Ace.Command>;
18981899
exec(command: string | string[] | import("ace-code").Ace.Command, editor: Editor, args: any): boolean;
18991900
canExecute(command: string | import("ace-code").Ace.Command, editor: Editor): boolean;

0 commit comments

Comments
 (0)