Skip to content

Commit 6d559af

Browse files
committed
feat: convert codebase to TypeScript
``` flow-to-ts --write --delete-source --prettier ./lib/**/*.js npm run format ```
1 parent cbf4f7f commit 6d559af

17 files changed

+136
-84
lines changed
File renamed without changes.
File renamed without changes.

lib/canvas-layer.js renamed to lib/canvas-layer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export default class CanvasLayer {
2828
* @access private
2929
*/
3030
this.offscreenCanvas = document.createElement("canvas")
31+
3132
/**
3233
* The offscreen canvas context.
3334
* @type {CanvasRenderingContext2D}

lib/decoration-management.js renamed to lib/decoration-management.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,33 +36,38 @@ export default class DecorationManagement {
3636
* @access private
3737
*/
3838
this.decorationsById = new Map()
39+
3940
/**
4041
* The decorations stored in an array indexed with their marker id.
4142
* @type {Object}
4243
* @access private
4344
*/
4445
this.decorationsByMarkerId = new Map()
46+
4547
/**
4648
* The subscriptions to the markers `did-change` event indexed using the
4749
* marker id.
4850
* @type {Object}
4951
* @access private
5052
*/
5153
this.decorationMarkerChangedSubscriptions = new Map()
54+
5255
/**
5356
* The subscriptions to the markers `did-destroy` event indexed using the
5457
* marker id.
5558
* @type {Object}
5659
* @access private
5760
*/
5861
this.decorationMarkerDestroyedSubscriptions = new Map()
62+
5963
/**
6064
* The subscriptions to the decorations `did-change-properties` event
6165
* indexed using the decoration id.
6266
* @type {Object}
6367
* @access private
6468
*/
6569
this.decorationUpdatedSubscriptions = new Map()
70+
6671
/**
6772
* The subscriptions to the decorations `did-destroy` event indexed using
6873
* the decoration id.
@@ -96,7 +101,7 @@ export default class DecorationManagement {
96101
* - decoration: the decoration object that was created
97102
* @return {Disposable} a disposable to stop listening to the event
98103
*/
99-
onDidAddDecoration(callback: (event:Object) => void): Disposable {
104+
onDidAddDecoration(callback: (event: { [key: string]: any }) => void): Disposable {
100105
return this.emitter.on("did-add-decoration", callback)
101106
}
102107

@@ -112,7 +117,7 @@ export default class DecorationManagement {
112117
* - decoration: the decoration object that was created
113118
* @return {Disposable} a disposable to stop listening to the event
114119
*/
115-
onDidRemoveDecoration(callback: (event:Object) => void): Disposable {
120+
onDidRemoveDecoration(callback: (event: { [key: string]: any }) => void): Disposable {
116121
return this.emitter.on("did-remove-decoration", callback)
117122
}
118123

@@ -131,7 +136,7 @@ export default class DecorationManagement {
131136
* - decoration: the decoration object that was created
132137
* @return {Disposable} a disposable to stop listening to the event
133138
*/
134-
onDidChangeDecoration(callback: (event:Object) => void): Disposable {
139+
onDidChangeDecoration(callback: (event: { [key: string]: any }) => void): Disposable {
135140
return this.emitter.on("did-change-decoration", callback)
136141
}
137142

@@ -150,7 +155,7 @@ export default class DecorationManagement {
150155
* - decoration: the decoration object that was created
151156
* @return {Disposable} a disposable to stop listening to the event
152157
*/
153-
onDidChangeDecorationRange(callback: (event:Object) => void): Disposable {
158+
onDidChangeDecorationRange(callback: (event: { [key: string]: any }) => void): Disposable {
154159
return this.emitter.on("did-change-decoration-range", callback)
155160
}
156161

@@ -476,7 +481,7 @@ export default class DecorationManagement {
476481
* change object
477482
* @access private
478483
*/
479-
emitRangeChanges(type: string, range: { }, screenDelta) {
484+
emitRangeChanges(type: string, range: {}, screenDelta) {
480485
const startScreenRow = range.start.row
481486
const endScreenRow = range.end.row
482487
const lastRenderedScreenRow = this.minimap.getLastVisibleScreenRow()

lib/decoration.js renamed to lib/decoration.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default class Decoration {
2121
* @param {string} type the decoration type to match
2222
* @return {boolean} whether the decoration properties match the type
2323
*/
24-
static isType(decorationProperties: { }, type: string): boolean {
24+
static isType(decorationProperties: {}, type: string): boolean {
2525
if (Array.isArray(decorationProperties.type)) {
2626
if (decorationProperties.type.indexOf(type) >= 0) {
2727
return true
@@ -40,33 +40,39 @@ export default class Decoration {
4040
* be displayed
4141
* @param {Object} properties the decoration's properties
4242
*/
43-
constructor(marker: Marker, minimap: Minimap, properties: { }) {
43+
constructor(marker: Marker, minimap: Minimap, properties: {}) {
4444
/**
4545
* @access private
4646
*/
4747
this.marker = marker
48+
4849
/**
4950
* @access private
5051
*/
5152
this.minimap = minimap
53+
5254
/**
5355
* @access private
5456
*/
5557
this.emitter = new Emitter()
58+
5659
/**
5760
* @access private
5861
*/
5962
this.id = nextId()
63+
6064
/**
6165
* @access private
6266
*/
6367
this.properties = null
6468
this.setProperties(properties)
6569
this.properties.id = this.id
70+
6671
/**
6772
* @access private
6873
*/
6974
this.destroyed = false
75+
7076
/**
7177
* @access private
7278
*/
@@ -174,7 +180,7 @@ export default class Decoration {
174180
*
175181
* @param {Object} newProperties the new properties for the decoration
176182
*/
177-
setProperties(newProperties: { }) {
183+
setProperties(newProperties: {}) {
178184
if (this.destroyed) {
179185
return
180186
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

lib/dom-styles-reader.js renamed to lib/dom-styles-reader.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export default class DOMStylesReader {
2929
* @access private
3030
* unused
3131
*/
32+
3233
// this.hasTokenizedOnce = false
3334
}
3435

@@ -129,6 +130,7 @@ export default class DOMStylesReader {
129130
* @access private
130131
* unused
131132
*/
133+
132134
/*
133135
invalidateIfFirstTokenization () {
134136
if (this.hasTokenizedOnce) { return }
@@ -164,7 +166,6 @@ function rotateHue(value: string, filter: string): string {
164166
let [, , r, g, b, , a] = match
165167

166168
let [, hue] = filter.match(hueRegexp)
167-
168169
;[r, g, b, a, hue] = [r, g, b, a, hue].map(Number)
169170
;[r, g, b] = rotate(r, g, b, hue)
170171

lib/main.js renamed to lib/main.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ export { default as Minimap } from "./minimap"
2626
* @access private
2727
*/
2828
let active: boolean = false
29+
2930
/**
3031
* The toggle state of the package.
3132
*
3233
* @type {boolean}
3334
* @access private
3435
*/
3536
let toggled: boolean = false
37+
3638
/**
3739
* The `Map` where Minimap instances are stored with the text editor they
3840
* target as key.
@@ -41,13 +43,15 @@ let toggled: boolean = false
4143
* @access private
4244
*/
4345
export let editorsMinimaps = null
46+
4447
/**
4548
* The composite disposable that stores the package's subscriptions.
4649
*
4750
* @type {CompositeDisposable}
4851
* @access private
4952
*/
5053
let subscriptions: CompositeDisposable = null
54+
5155
/**
5256
* The disposable that stores the package's commands subscription.
5357
*
@@ -404,8 +408,7 @@ function initSubscriptions() {
404408

405409
emitter.emit("did-create-minimap", minimap)
406410
minimapElement.attach(textEditor.getElement())
407-
}),
408-
// empty color cache if the theme changes
411+
}), // empty color cache if the theme changes
409412
atom.themes.onDidChangeActiveThemes(() => {
410413
domStylesReader.invalidateDOMStylesCache()
411414
editorsMinimaps.forEach((minimap) => {

0 commit comments

Comments
 (0)