From 0c5dc553872d970617b7576441b3791ce071307e Mon Sep 17 00:00:00 2001 From: Alice Koreman Date: Fri, 6 Dec 2024 11:36:13 +0100 Subject: [PATCH] chore: small type fixes --- ace-internal.d.ts | 2 +- ace.d.ts | 2 +- src/edit_session.js | 2 +- src/ext/searchbox.js | 5 +++++ tool/ace_declaration_generator.js | 10 +++++++++- types/ace-ext.d.ts | 11 +++++++++++ types/ace-modules.d.ts | 2 +- 7 files changed, 29 insertions(+), 5 deletions(-) diff --git a/ace-internal.d.ts b/ace-internal.d.ts index 154614fd96..3062f479df 100644 --- a/ace-internal.d.ts +++ b/ace-internal.d.ts @@ -845,7 +845,7 @@ export namespace Ace { */ $quotes: { [quote: string]: string }; HighlightRules: { - new(config: any): HighlightRules + new(config?: any): HighlightRules }; //TODO: fix this foldingRules?: FoldMode; $behaviour?: Behaviour; diff --git a/ace.d.ts b/ace.d.ts index 190a64cf86..83623a4fbe 100644 --- a/ace.d.ts +++ b/ace.d.ts @@ -695,7 +695,7 @@ declare module "ace-code" { } interface SyntaxMode { HighlightRules: { - new(config: any): HighlightRules; + new(config?: any): HighlightRules; }; //TODO: fix this foldingRules?: FoldMode; /** diff --git a/src/edit_session.js b/src/edit_session.js index f7364e0c4b..5cb405437b 100644 --- a/src/edit_session.js +++ b/src/edit_session.js @@ -138,7 +138,7 @@ class EditSession { /** * End current Ace operation. * Emits "beforeEndOperation" event just before clearing everything, where the current operation can be accessed through `curOp` property. - * @param {any} e + * @param {any} [e] */ endOperation(e) { if (this.curOp) { diff --git a/src/ext/searchbox.js b/src/ext/searchbox.js index e26a900391..e1a9c08be7 100644 --- a/src/ext/searchbox.js +++ b/src/ext/searchbox.js @@ -129,6 +129,10 @@ class SearchBox { } }); + /** + * @type {{schedule: (timeout?: number) => void}} + * @external + */ this.$onChange = lang.delayedCall(function() { _this.find(false, false); }); @@ -158,6 +162,7 @@ class SearchBox { /** * @param {boolean} [preventScroll] + * @external */ $syncOptions(preventScroll) { dom.setCssClass(this.replaceOption, "checked", this.searchRange); diff --git a/tool/ace_declaration_generator.js b/tool/ace_declaration_generator.js index 40b4b8bd44..fb9a58b9e8 100644 --- a/tool/ace_declaration_generator.js +++ b/tool/ace_declaration_generator.js @@ -363,7 +363,7 @@ function fixDeclaration(content, aceNamespacePath) { const startsWithDollar = ts.isIdentifier(node.name) && /^[$_]/.test(node.name.text); - if (isPrivate || startsWithDollar || hasInternalTag(node)) { + if (isPrivate || (startsWithDollar && !hasExternalTag(node)) || hasInternalTag(node)) { return ts.factory.createNotEmittedStatement(node); } } @@ -459,6 +459,14 @@ function hasInternalTag(node) { return jsDocs.length > 0; } +function hasExternalTag(node) { + const sourceFile = node.getSourceFile(); + if (!sourceFile) return false; + + const jsDocs = ts.getJSDocTags(node).filter(tag => tag.tagName.text === 'external'); + return jsDocs.length > 0; +} + function createMinimalLanguageServiceHost() { return { files: {}, diff --git a/types/ace-ext.d.ts b/types/ace-ext.d.ts index 984dcdce74..5941797e1a 100644 --- a/types/ace-ext.d.ts +++ b/types/ace-ext.d.ts @@ -183,8 +183,19 @@ declare module "ace-code/src/ext/searchbox" { searchInput: HTMLInputElement; replaceInput: HTMLInputElement; searchCounter: HTMLElement; + /** + * + * @external + */ + $onChange: { + schedule: (timeout?: number) => void; + }; setSearchRange(range: any): void; searchRangeMarker: number; + /** + * @external + */ + $syncOptions(preventScroll?: boolean): void; highlight(re?: RegExp): void; find(skipCurrent: boolean, backwards: boolean, preventScroll?: any): void; updateCounter(): void; diff --git a/types/ace-modules.d.ts b/types/ace-modules.d.ts index dcd0faae0c..261dbac941 100644 --- a/types/ace-modules.d.ts +++ b/types/ace-modules.d.ts @@ -3767,7 +3767,7 @@ declare module "ace-code/src/edit_session" { * End current Ace operation. * Emits "beforeEndOperation" event just before clearing everything, where the current operation can be accessed through `curOp` property. */ - endOperation(e: any): void; + endOperation(e?: any): void; /** * Sets the `EditSession` to point to a new `Document`. If a `BackgroundTokenizer` exists, it also points to `doc`. *