First set of TS 2.0 adoption work

This commit is contained in:
Dirk Baeumer
2016-09-20 16:26:40 +02:00
parent d705f554bb
commit 963d1a5c94
25 changed files with 86 additions and 53 deletions

View File

@@ -214,13 +214,15 @@ export class TextEditorEdit {
replace(location: Position | Range | Selection, value: string): void {
let range: Range = null;
// @alex TS(2.0.2) - Selection is subclass of Range so the else if (location instanceof Selection) isn't reachable.
// Deleted it to keep sematic. You need to check if creating a new Range from a Selection is intended.
if (location instanceof Position) {
range = new Range(location, location);
} else if (location instanceof Range) {
range = location;
} else if (location instanceof Selection) {
} /* else if (location instanceof Selection) {
range = new Range(location.start, location.end);
} else {
} */ else {
throw new Error('Unrecognized location');
}
@@ -242,11 +244,13 @@ export class TextEditorEdit {
delete(location: Range | Selection): void {
let range: Range = null;
// @alex TS(2.0.2) - Selection is subclass of Range so the else if (location instanceof Selection) isn't reachable.
// Deleted it to keep sematic. You need to check if creating a new Range from a Selection is intended.
if (location instanceof Range) {
range = location;
} else if (location instanceof Selection) {
} /* else if (location instanceof Selection) {
range = new Range(location.start, location.end);
} else {
} */ else {
throw new Error('Unrecognized location');
}
@@ -393,7 +397,9 @@ class ExtHostTextEditor implements vscode.TextEditor {
() => this._proxy.$tryRevealRange(
this._id,
TypeConverters.fromRange(range),
revealType || TextEditorRevealType.Default
// @alex TS(2.0.2) - we still don't hack duck typing on enums. I added a cast since the
// values are the same. May be you want to write nicer code for this.
(revealType || TextEditorRevealType.Default) as any
),
true
);