Skip to content

Commit 09eda74

Browse files
committed
Update typescript and enable strict mode
1 parent e9ba0f5 commit 09eda74

20 files changed

+61
-234
lines changed

dist/client/findServer.js

Lines changed: 0 additions & 81 deletions
This file was deleted.

dist/main/atom/tooltipManager.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ function attach(editorView, editor) {
5151
clearExprTypeTimeout();
5252
exprTypeTimeout = setTimeout(() => showExpressionType(e), 100);
5353
});
54-
subscriber.subscribe(scroll, 'mouseout', (e) => clearExprTypeTimeout());
55-
subscriber.subscribe(scroll, 'keydown', (e) => clearExprTypeTimeout());
54+
subscriber.subscribe(scroll, 'mouseout', () => clearExprTypeTimeout());
55+
subscriber.subscribe(scroll, 'keydown', () => clearExprTypeTimeout());
5656
// Setup for clearing
5757
editor.onDidDestroy(() => deactivate());
5858
function showExpressionType(e) {

dist/main/atom/views/lineMessageView.js

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
33
const view = require("./view");
44
var $ = view.$;
55
class LineMessageView extends view.View {
6+
constructor() {
7+
super(...arguments);
8+
this.goToLine = () => {
9+
this.options.goToLine(this.options.file, this.options.line, this.options.col);
10+
};
11+
this.getSummary = () => {
12+
var pos = this.options.line.toString();
13+
if (this.options.file !== undefined) {
14+
pos += ', ' + this.options.file;
15+
}
16+
return {
17+
summary: pos + ' ' + this.options.message,
18+
rawSummary: true,
19+
handler: (element) => {
20+
$(element)
21+
.css('cursor', 'pointer')
22+
.click(this.goToLine);
23+
}
24+
};
25+
};
26+
}
627
static content() {
728
return this.div({
829
class: 'line-message'
@@ -39,23 +60,5 @@ class LineMessageView extends view.View {
3960
this.code.remove();
4061
}
4162
}
42-
goToLine() {
43-
this.options.goToLine(this.options.file, this.options.line, this.options.col);
44-
}
45-
getSummary() {
46-
var pos = this.options.line.toString();
47-
if (this.options.file !== undefined) {
48-
pos += ', ' + this.options.file;
49-
}
50-
return {
51-
summary: pos + ' ' + this.options.message,
52-
rawSummary: true,
53-
handler: function (element) {
54-
$(element)
55-
.css('cursor', 'pointer')
56-
.click(this.goToLine.bind(this));
57-
}.bind(this)
58-
};
59-
}
6063
}
6164
exports.LineMessageView = LineMessageView;

lib/client/client.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ export class TypescriptServiceClient {
2727
callbacks: {
2828
[seq: number]: {
2929
name: string
30-
reject(res)
31-
resolve(res)
30+
reject(err: Error): void
31+
resolve(res: protocol.Response): void
3232
started: number
3333
}
3434
} = {}
@@ -47,7 +47,7 @@ export class TypescriptServiceClient {
4747
readonly tsServerArgs = []
4848
readonly version: string
4949

50-
constructor(tsServerPath: string, version) {
50+
constructor(tsServerPath: string, version: string) {
5151
this.tsServerPath = tsServerPath
5252
this.version = version
5353
}
@@ -110,7 +110,7 @@ export class TypescriptServiceClient {
110110
return this.execute("saveto", args)
111111
}
112112

113-
private async execute(command: string, args) {
113+
private async execute(command: string, args: any) {
114114
if (!this.serverPromise) {
115115
throw new Error("Server is not running")
116116
}
@@ -161,10 +161,10 @@ export class TypescriptServiceClient {
161161
}
162162
}
163163

164-
private sendRequest(cp: ChildProcess, command: string, args, expectResponse: true): Promise<protocol.Response>
165-
private sendRequest(cp: ChildProcess, command: string, args, expectResponse: false): undefined
166-
private sendRequest(cp: ChildProcess, command: string, args, expectResponse: boolean): Promise<protocol.Response> | undefined
167-
private sendRequest(cp: ChildProcess, command: string, args, expectResponse: boolean): Promise<protocol.Response> | undefined {
164+
private sendRequest(cp: ChildProcess, command: string, args: any, expectResponse: true): Promise<protocol.Response>
165+
private sendRequest(cp: ChildProcess, command: string, args: any, expectResponse: false): undefined
166+
private sendRequest(cp: ChildProcess, command: string, args: any, expectResponse: boolean): Promise<protocol.Response> | undefined
167+
private sendRequest(cp: ChildProcess, command: string, args: any, expectResponse: boolean): Promise<protocol.Response> | undefined {
168168

169169
const req = {
170170
seq: this.seq++,
@@ -248,7 +248,7 @@ class MessageStream extends Transform {
248248
super({objectMode: true})
249249
}
250250

251-
_transform(line, encoding, callback) {
251+
_transform(line: string, encoding: string, callback: Function) {
252252
if (this.lineCount % 2 === 0) {
253253
this.push(JSON.parse(line))
254254
}

lib/client/findServer.ts

Lines changed: 0 additions & 95 deletions
This file was deleted.

lib/main/atom/autoCompleteProvider.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import * as Atom from "atom"
88
import * as fuzzaldrin from "fuzzaldrin"
99

1010
const importPathScopes = ["meta.import", "meta.import-equals", "triple-slash-directive"]
11-
type SuggestionWithDetails = Suggestion & {details?}
11+
12+
type SuggestionWithDetails = Suggestion & {
13+
details?: protocol.CompletionEntryDetails
14+
}
1215

1316
type Options = {
1417
getTypescriptBuffer: (filePath: string) => Promise<{
@@ -190,7 +193,7 @@ function getLocationQuery(opts: RequestOptions): FileLocationQuery {
190193
function getLastNonWhitespaceChar(buffer: TextBuffer.ITextBuffer, pos: TextBuffer.IPoint): string | undefined {
191194
let lastChar: string | undefined = undefined
192195
const range = new Atom.Range([0,0], pos)
193-
buffer.backwardsScanInRange(/\S/, range, ({matchText, stop}) => {
196+
buffer.backwardsScanInRange(/\S/, range, ({matchText, stop}: {matchText: string, stop: () => void}) => {
194197
lastChar = matchText
195198
stop()
196199
})

lib/main/atom/commands/build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ commands.set("typescript:build", deps => {
4747
}
4848
})
4949

50-
function _finally<T>(promise: Promise<T>, callback: (result) => any): Promise<T> {
50+
function _finally<T>(promise: Promise<T>, callback: (result: T) => any): Promise<T> {
5151
promise.then(callback, callback)
5252
return promise
5353
}

lib/main/atom/commands/checkAllFiles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ commands.set("typescript:check-all-files", deps => {
2222
// the files set is going to receive a a diagnostic event (typically some d.ts files). To counter
2323
// that, we cancel the listener and close the progress bar after no diagnostics have been received
2424
// for some amount of time.
25-
let cancelTimeout
25+
let cancelTimeout: any
2626

2727
const unregister = client.on("syntaxDiag", evt => {
2828
clearTimeout(cancelTimeout)

lib/main/atom/commands/registry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {StatusPanel} from "../../atom/components/statusPanel"
44
import {TypescriptBuffer} from "../../typescriptBuffer"
55

66
export interface Dependencies {
7-
clearErrors()
7+
clearErrors(): void
88
getTypescriptBuffer(filePath: string): Promise<{buffer: TypescriptBuffer, isOpen: boolean}>
99
getClient(filePath: string): Promise<TypescriptServiceClient>
1010
renameView: RenameView

lib/main/atom/components/tsView.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// http://www.html5rocks.com/en/tutorials/webcomponents/customelements/ (look at lifecycle callback methods)
33

44
export class TsView extends HTMLElement {
5-
editorElement;
6-
editor;
5+
editorElement: HTMLElement
6+
editor: AtomCore.IEditor
77
createdCallback() {
88
var preview = this.innerText;
99
this.innerText = "";

lib/main/atom/tooltipManager.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export function attach(editorView: JQuery, editor: AtomCore.IEditor) {
4545
// to debounce mousemove event's firing for some reason on some machines
4646
var lastExprTypeBufferPt: any;
4747

48-
subscriber.subscribe(scroll, 'mousemove', (e) => {
48+
subscriber.subscribe(scroll, 'mousemove', (e: MouseEvent) => {
4949
var pixelPt = pixelPositionFromMouseEvent(editorView, e)
5050
var screenPt = editor.element.screenPositionForPixelPosition(pixelPt)
5151
var bufferPt = editor.bufferPositionForScreenPosition(screenPt)
@@ -57,8 +57,8 @@ export function attach(editorView: JQuery, editor: AtomCore.IEditor) {
5757
clearExprTypeTimeout();
5858
exprTypeTimeout = setTimeout(() => showExpressionType(e), 100);
5959
});
60-
subscriber.subscribe(scroll, 'mouseout', (e) => clearExprTypeTimeout());
61-
subscriber.subscribe(scroll, 'keydown', (e) => clearExprTypeTimeout());
60+
subscriber.subscribe(scroll, 'mouseout', () => clearExprTypeTimeout());
61+
subscriber.subscribe(scroll, 'keydown', () => clearExprTypeTimeout());
6262

6363
// Setup for clearing
6464
editor.onDidDestroy(() => deactivate());
@@ -130,7 +130,7 @@ export function attach(editorView: JQuery, editor: AtomCore.IEditor) {
130130
}
131131

132132

133-
function pixelPositionFromMouseEvent(editorView, event: MouseEvent) {
133+
function pixelPositionFromMouseEvent(editorView: JQuery, event: MouseEvent) {
134134
var clientX = event.clientX, clientY = event.clientY;
135135
var linesClientRect = getFromShadowDom(editorView, '.lines')[0].getBoundingClientRect();
136136
var top = clientY - linesClientRect.top;

lib/main/atom/utils/ts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function spanToRange(span: TextSpan): TextBuffer.IRange {
2525
return locationsToRange(span.start, span.end)
2626
}
2727

28-
export function locationsToRange(start, end): TextBuffer.IRange {
28+
export function locationsToRange(start: LocationQuery, end: LocationQuery): TextBuffer.IRange {
2929
return new Range(locationToPoint(start), locationToPoint(end))
3030
}
3131

0 commit comments

Comments
 (0)