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

Introduce JSDoc-based Type System with checkJs flag #5318

Merged
merged 44 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
7e7f329
correct many descriptions; automatic type declarations generation wit…
mkslanc Aug 25, 2023
1d09f95
continue type casting
mkslanc Aug 25, 2023
9110b45
convert to es6 class
mkslanc Aug 26, 2023
ab962b9
continue providing types
mkslanc Aug 27, 2023
84d383b
continue providing types
mkslanc Aug 30, 2023
55f04df
Merge branch 'selection-es6' into better-types
mkslanc Aug 30, 2023
d9dc97e
Merge branch 'master' into better-types
mkslanc Sep 8, 2023
f60e632
continue providing types
mkslanc Sep 14, 2023
d8411db
continue providing types
mkslanc Sep 17, 2023
25ba191
Merge branch 'master' into better-types
mkslanc Sep 17, 2023
6cf736d
resolve merge conflicts with new version
mkslanc Sep 17, 2023
5d05997
revert demo changes
mkslanc Sep 17, 2023
02c9a3c
fix eslint errors
mkslanc Sep 17, 2023
9eb7d72
fix bugs
mkslanc Sep 17, 2023
d9e9a19
return demo
mkslanc Sep 17, 2023
cd5ce9a
continue providing types
mkslanc Sep 18, 2023
47027a1
describe available events for different classes
mkslanc Sep 21, 2023
ba40d17
improvements in types
mkslanc Sep 22, 2023
caaa69e
better way to merge interfaces
nightwing Sep 26, 2023
5402ec9
use declare module instead of hackish typedef's
mkslanc Sep 28, 2023
08b4f18
Merge branch 'master' into better-types
mkslanc Sep 28, 2023
43901dc
resolve merge conflicts
mkslanc Sep 28, 2023
06bc8c8
fix multiline jsdoc types definitions
mkslanc Sep 28, 2023
ad589bd
continue providing types
mkslanc Sep 30, 2023
18069d5
continue providing types
mkslanc Oct 4, 2023
b729b74
move some inline typedef imports to separate typedefs
mkslanc Oct 7, 2023
79de751
correct declarations
mkslanc Oct 15, 2023
07f9b8e
first version of declaration generator for ace-code
mkslanc Oct 15, 2023
6bfc9e3
correct declarations
mkslanc Oct 17, 2023
feacbc8
generate declaration for ace-builds
mkslanc Oct 17, 2023
7575de5
separate building for ace-code and ace-builds; correct build script
mkslanc Oct 19, 2023
ca733da
rename `correctModulesForAceBuilds` to `updateDeclarationModuleNames`
mkslanc Oct 23, 2023
7e32810
Merge pull request #3 from mkslanc/types-generator
mkslanc Oct 23, 2023
da92d09
fix left errors in generation
mkslanc Nov 2, 2023
9a5b4d0
change declaration structure for ace-code
mkslanc Nov 2, 2023
29ba8ab
Merge branch 'master' into better-types
mkslanc Nov 2, 2023
f36b98e
add types to new declarations
mkslanc Nov 2, 2023
16db9ca
remove declaration_generator; make ace-builds to use old declaration
mkslanc Nov 2, 2023
a88c30d
Merge branch 'master' into better-types
mkslanc Nov 17, 2023
8581365
update to last version
mkslanc Nov 17, 2023
cec9e2a
return base ace.d.ts; use `ace-internal` for inner typings
mkslanc Dec 4, 2023
bd7c3ed
Merge branch 'master' into better-types
mkslanc Dec 4, 2023
cc47699
resolve merge conflicts
mkslanc Dec 4, 2023
07b0241
cleanup
nightwing Dec 5, 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
2,428 changes: 1,303 additions & 1,125 deletions ace.d.ts

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"eslint": "^8.20.0",
"istanbul": "^0.4.5",
"standard-version": "^9.3.2",
"typescript": "^4.7.4"
"typescript": "^5.2.2"
},
"mappings": {
"ace": "."
Expand All @@ -45,7 +45,8 @@
"lint": "eslint \"src/**/*.js\"",
"fix": "eslint --fix \"src/**/*.js\"",
"changelog": "standard-version",
"prepack": "node tool/esm_resolver_generator.js && node Makefile.dryice.js css --target build-styles && rm -rf styles && mv build-styles/css styles"
"prepack": "node tool/esm_resolver_generator.js && node Makefile.dryice.js css --target build-styles && rm -rf styles && mv build-styles/css styles",
"tsc": "rimraf types && tsc --project tsconfig.json"
},
"standard-version": {
"skip": {
Expand Down
18 changes: 8 additions & 10 deletions src/ace.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
/**
* The main class required to set up an Ace instance in the browser.
*
* @class Ace
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currently we allow both import * as ace from "ace-code" import {ace} from "ace-code", i wonder if we can somehow align the namespace with this

* @namespace Ace
**/

"use strict";
"include loader_build";

var dom = require("./lib/dom");

var Range = require("./range").Range;
var Editor = require("./editor").Editor;
var EditSession = require("./edit_session").EditSession;
var Editor = require("./editor").Editor;
var UndoManager = require("./undomanager").UndoManager;
var Renderer = require("./virtual_renderer").VirtualRenderer;

Expand All @@ -29,9 +28,9 @@ exports.config = require("./config");

/**
* Embeds the Ace editor into the DOM, at the element provided by `el`.
* @param {String | Element} el Either the id of an element, or the element itself
* @param {Object } options Options for the editor
*
* @param {String | HTMLElement & {env?, value?}} el Either the id of an element, or the element itself
* @param {Object } [options] Options for the editor
* @returns {Editor}
**/
exports.edit = function(el, options) {
if (typeof el == "string") {
Expand All @@ -56,7 +55,6 @@ exports.edit = function(el, options) {
}

var doc = exports.createEditSession(value);

var editor = new Editor(new Renderer(el), doc, options);

var env = {
Expand All @@ -74,9 +72,9 @@ exports.edit = function(el, options) {

/**
* Creates a new [[EditSession]], and returns the associated [[Document]].
* @param {Document | String} text {:textParam}
* @param {TextMode} mode {:modeParam}
*
* @param {import('./document').Document | String} text {:textParam}
* @param {import("../ace").Ace.SyntaxMode} [mode] {:modeParam}
* @returns {EditSession}
**/
exports.createEditSession = function(text, mode) {
var doc = new EditSession(text, mode);
Expand Down
33 changes: 11 additions & 22 deletions src/anchor.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
"use strict";

/**
* @typedef Document
mkslanc marked this conversation as resolved.
Show resolved Hide resolved
* @type {import("./document").Document}
*/
var oop = require("./lib/oop");
var EventEmitter = require("./lib/event_emitter").EventEmitter;

Expand All @@ -11,22 +14,22 @@ class Anchor {
* Creates a new `Anchor` and associates it with a document.
*
* @param {Document} doc The document to associate with the anchor
* @param {Number} row The starting row position
* @param {Number} column The starting column position
* @param {Number|import("../ace").Ace.Point} row The starting row position
* @param {Number} [column] The starting column position
**/
constructor(doc, row, column) {
this.$onChange = this.onChange.bind(this);
this.attach(doc);

if (typeof column == "undefined")
if (typeof row != "number")
this.setPosition(row.row, row.column);
else
this.setPosition(row, column);
}

/**
* Returns an object identifying the `row` and `column` position of the current anchor.
* @returns {Ace.Point}
* @returns {import("../ace").Ace.Point}
**/
getPosition() {
return this.$clipPositionToDocument(this.row, this.column);
Expand All @@ -41,22 +44,9 @@ class Anchor {
return this.document;
}

/**
* Fires whenever the anchor position changes.
*
* Both of these objects have a `row` and `column` property corresponding to the position.
*
* Events that can trigger this function include [[Anchor.setPosition `setPosition()`]].
*
* @event change
* @param {Object} e An object containing information about the anchor position. It has two properties:
* - `old`: An object describing the old Anchor position
* - `value`: An object describing the new Anchor position
*
**/
/**
* Internal function called when `"change"` event fired.
* @param {Ace.Delta} delta
* @param {import("../ace").Ace.Delta} delta
*/
onChange(delta) {
if (delta.start.row == delta.end.row && delta.start.row != this.row)
Expand All @@ -73,8 +63,7 @@ class Anchor {
* Sets the anchor position to the specified row and column. If `noClip` is `true`, the position is not clipped.
* @param {Number} row The row index to move the anchor to
* @param {Number} column The column index to move the anchor to
* @param {Boolean} noClip Identifies if you want the position to be clipped
*
* @param {Boolean} [noClip] Identifies if you want the position to be clipped
**/
setPosition(row, column, noClip) {
var pos;
Expand Down Expand Up @@ -125,7 +114,7 @@ class Anchor {
* Clips the anchor position to the specified row and column.
* @param {Number} row The row index to clip the anchor to
* @param {Number} column The column index to clip the anchor to
* @returns {Ace.Point}
* @returns {import("../ace").Ace.Point}
*
**/
$clipPositionToDocument(row, column) {
Expand Down
7 changes: 7 additions & 0 deletions src/apply_delta.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
position.column >= 0 && position.column <= docLines[position.row].length;
}

function validateDelta(docLines, delta) {

Check warning on line 13 in src/apply_delta.js

View workflow job for this annotation

GitHub Actions / build (16.x)

'validateDelta' is defined but never used
// Validate action string.
if (delta.action != "insert" && delta.action != "remove")
throwDeltaError(delta, "delta.action must be 'insert' or 'remove'");
Expand Down Expand Up @@ -40,6 +40,12 @@
throwDeltaError(delta, "delta.range must match delta lines");
}

/**
* Applies a delta to a document.
* @param {string[]} docLines
* @param {import("../ace").Ace.Delta} delta
* @param [doNotValidate]
*/
exports.applyDelta = function(docLines, delta, doNotValidate) {
// disabled validation since it breaks autocompletion popup
// if (!doNotValidate)
Expand All @@ -54,6 +60,7 @@
if (lines.length === 1) {
docLines[row] = line.substring(0, startColumn) + delta.lines[0] + line.substring(startColumn);
} else {
// @ts-ignore
var args = [row, 1].concat(delta.lines);
docLines.splice.apply(docLines, args);
docLines[row] = line.substring(0, startColumn) + docLines[row];
Expand Down
Loading
Loading