Skip to content

Commit

Permalink
further types improving
Browse files Browse the repository at this point in the history
  • Loading branch information
mkslanc committed Nov 13, 2024
1 parent 17c3e18 commit 9f1a005
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
8 changes: 4 additions & 4 deletions ace-ext.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -571,11 +571,11 @@ declare module "ace-code/src/ext/prompt" {
*/
name: string;
/**
* Defines which part of the predefined value should be highlited.
* Defines which part of the predefined value should be highlighted.
*/
selection: [
start: number,
end: number
number,
number
];
/**
* Set to true if prompt has description below input box.
Expand Down Expand Up @@ -625,7 +625,7 @@ declare module "ace-code/src/ext/prompt" {
* @typedef PromptOptions
* @property {String} name Prompt name.
* @property {String} $type Use prompt of specific type (gotoLine|commands|modes or default if empty).
* @property {[start: number, end: number]} selection Defines which part of the predefined value should be highlited.
* @property {[number, number]} selection Defines which part of the predefined value should be highlighted.
* @property {Boolean} hasDescription Set to true if prompt has description below input box.
* @property {String} prompt Description below input box.
* @property {String} placeholder Placeholder for value.
Expand Down
9 changes: 7 additions & 2 deletions ace-lib.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ declare module "ace-code/src/lib/dom" {
export const HAS_CSS_TRANSFORMS: boolean;
export const HI_DPI: boolean;
export function translate(element: any, tx: any, ty: any): void;
export function importCssString(cssText: any, id: any, target: any): number;
/**
* @param {string} cssText
* @param {string} [id]
* @param {any} [target]
*/
export function importCssString(cssText: string, id?: string, target?: any): number;
}
declare module "ace-code/src/lib/oop" {
export function inherits(ctor: any, superCtor: any): void;
Expand Down Expand Up @@ -93,7 +98,7 @@ declare module "ace-code/src/lib/keys" {
export function keyCodeToString(keyCode: number): string;
}
declare module "ace-code/src/lib/event" {
export function addListener(elem: any, type: any, callback: any, destroyer: any | null): void;
export function addListener(elem: any, type: string, callback: any, destroyer?: any): void;
export function removeListener(elem: any, type: any, callback: any): void;
export function stopEvent(e: any): boolean;
export function stopPropagation(e: any): void;
Expand Down
2 changes: 1 addition & 1 deletion src/ext/prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var openPrompt;
* @typedef PromptOptions
* @property {String} name Prompt name.
* @property {String} $type Use prompt of specific type (gotoLine|commands|modes or default if empty).
* @property {[start: number, end: number]} selection Defines which part of the predefined value should be highlited.
* @property {[number, number]} selection Defines which part of the predefined value should be highlighted.
* @property {Boolean} hasDescription Set to true if prompt has description below input box.
* @property {String} prompt Description below input box.
* @property {String} placeholder Placeholder for value.
Expand Down
5 changes: 5 additions & 0 deletions src/lib/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,11 @@ function insertPendingStyles() {
});
}

/**
* @param {string} cssText
* @param {string} [id]
* @param {any} [target]
*/
function importCssString(cssText, id, target) {
if (typeof document == "undefined")
return;
Expand Down
10 changes: 9 additions & 1 deletion src/lib/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,15 @@ EventListener.prototype.destroy = function() {
this.elem = this.type = this.callback = undefined;
};

var addListener = exports.addListener = function(elem, type, callback, /**@type{any?}*/destroyer) {
/**
* Adds an event listener to the specified element.
*
* @param {any} elem - The element to add the event listener to.
* @param {string} type - The type of event to listen for.
* @param {any} callback - The callback function to be executed when the event is triggered.
* @param {any} [destroyer] - An optional object that will have the created EventListener instance added to its $toDestroy array, allowing it to be easily destroyed later.
*/
var addListener = exports.addListener = function(elem, type, callback, destroyer) {
elem.addEventListener(type, callback, getListenerOptions());
if (destroyer)
destroyer.$toDestroy.push(new EventListener(elem, type, callback));
Expand Down

0 comments on commit 9f1a005

Please sign in to comment.