提交 55741c8c 编写于 作者: A Alex Dima

Fix TS adoption issues

上级 c0dd44ef
......@@ -785,9 +785,7 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
let searchRange:Range;
if (Range.isIRange(rawSearchScope)) {
// @alex TS(2.0.2) - isIRange tests for IRange but all our code assumes Range which now fails.
// Kept sematic using cast. But you should check.
searchRange = rawSearchScope as Range;
searchRange = this.validateRange(rawSearchScope);
} else {
searchRange = this.getFullModelRange();
}
......
......@@ -214,15 +214,11 @@ 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) {
range = new Range(location.start, location.end);
} */ else {
} else {
throw new Error('Unrecognized location');
}
......@@ -244,13 +240,9 @@ 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) {
range = new Range(location.start, location.end);
} */ else {
} else {
throw new Error('Unrecognized location');
}
......@@ -397,9 +389,7 @@ class ExtHostTextEditor implements vscode.TextEditor {
() => this._proxy.$tryRevealRange(
this._id,
TypeConverters.fromRange(range),
// @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
(revealType || TextEditorRevealType.Default)
),
true
);
......
......@@ -283,11 +283,7 @@ let _b24_getActualKeyCodeMap = (function() {
if (nativeMapping.value && _b24_interestingChars[nativeMapping.value]) {
// console.log(nativeMapping.value + " is made by " + nativeMapping.key_code);
let keyCode = NATIVE_KEY_CODE_TO_KEY_CODE[nativeMapping.key_code];
// @alex TS(2.0.2) - KeyCode.Unknown === 0 so if (keyCode) is true then KeyCode !== KeyCode.Unknown
// is superflous code which is now flagged as a compile error (actually as a type check error that
// is very hard to understand)
// Will comment out the keyCode !== KeyCode.Unknown check.
if (keyCode /* && keyCode !== KeyCode.Unknown */) {
if (keyCode) {
if (!result[nativeMapping.value] || result[nativeMapping.value] > keyCode) {
result[nativeMapping.value] = keyCode;
}
......@@ -297,11 +293,7 @@ let _b24_getActualKeyCodeMap = (function() {
if (nativeMapping.withShift && _b24_interestingChars[nativeMapping.withShift]) {
// console.log(nativeMapping.withShift + " is made by " + nativeMapping.key_code);
let keyCode = NATIVE_KEY_CODE_TO_KEY_CODE[nativeMapping.key_code];
// @alex TS(2.0.2) - KeyCode.Unknown === 0 so if (keyCode) is true then KeyCode !== KeyCode.Unknown
// is superflous code which is now flagged as a compile error (actually as a type check error that
// is very hard to understand)
// Will comment out the keyCode !== KeyCode.Unknown check.
if (keyCode /* && keyCode !== KeyCode.Unknown */) {
if (keyCode) {
if (!result[nativeMapping.withShift] || result[nativeMapping.withShift] > keyCode) {
result[nativeMapping.withShift] = keyCode;
}
......
......@@ -78,7 +78,7 @@ export class TokenStylesContribution {
public contributeStyles(themeId: string, themeDocument: IThemeDocument, cssRules: string[]): void {
let theme = new Theme(themeId, themeDocument);
theme.getSettings().forEach((s: IThemeSetting, index, arr) => {
// @alex TS(2.0.2) - s.scope is already a string[] so no need for all this checking.
// @martin TS(2.0.2) - s.scope is already a string[] so no need for all this checking.
// However will add a cast at split to keep semantic in case s.scope is wrongly typed.
let scope: string | string[] = s.scope;
let settings = s.settings;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册