From 8cbc769e77205a823fb5a49cbcc40668c0546c23 Mon Sep 17 00:00:00 2001 From: johnfn Date: Sat, 18 Jun 2016 12:13:07 -0700 Subject: [PATCH] Use --noImplicitAny. --- extension.ts | 6 +----- src/actions/actions.ts | 2 +- src/cmd_line/parser.ts | 2 +- src/cmd_line/subparser.ts | 9 ++++----- src/configuration/keyboard.ts | 8 ++++---- src/mode/modeHandler.ts | 2 +- src/motion/position.ts | 2 +- test/testSimplifier.ts | 6 +++--- tsconfig.json | 1 + 9 files changed, 17 insertions(+), 21 deletions(-) diff --git a/extension.ts b/extension.ts index dcee5ce3744..6d50702f188 100644 --- a/extension.ts +++ b/extension.ts @@ -63,8 +63,4 @@ function handleKeyEvent(key: string): Promise { } return modeHandler.handleKeyEvent(key); -} - -process.on('unhandledRejection', function(reason, p){ - console.log("Possibly Unhandled Rejection at: Promise ", p, " reason: ", reason); -}); +} \ No newline at end of file diff --git a/src/actions/actions.ts b/src/actions/actions.ts index 7cb39713ad4..78565fb77fb 100644 --- a/src/actions/actions.ts +++ b/src/actions/actions.ts @@ -200,7 +200,7 @@ export class Actions { } } -export function RegisterAction(action) { +export function RegisterAction(action: typeof BaseAction): void { Actions.allActions.push({ type: action, action: new action() }); } diff --git a/src/cmd_line/parser.ts b/src/cmd_line/parser.ts index 8be2ffdc029..f7497b02c3c 100644 --- a/src/cmd_line/parser.ts +++ b/src/cmd_line/parser.ts @@ -49,7 +49,7 @@ function parseCommand(state : ParserState, commandLine : node.CommandLine) : IPa var tok = state.next(); switch (tok.type) { case token.TokenType.CommandName: - var commandParser = commandParsers[tok.content]; + var commandParser = (commandParsers as any)[tok.content]; if (!commandParser) { throw new Error("not implemented or not a valid command"); } diff --git a/src/cmd_line/subparser.ts b/src/cmd_line/subparser.ts index e14a95b85b5..044574c5028 100644 --- a/src/cmd_line/subparser.ts +++ b/src/cmd_line/subparser.ts @@ -3,12 +3,11 @@ import {parseQuitCommandArgs} from './subparsers/quit'; import {parseWriteCommandArgs} from './subparsers/write'; -// TODO: add type for this dict. // maps command names to parsers for said commands. export const commandParsers = { - 'w': parseWriteCommandArgs, - 'write': parseWriteCommandArgs, + w: parseWriteCommandArgs, + write: parseWriteCommandArgs, - 'quit': parseQuitCommandArgs, - 'q': parseQuitCommandArgs + quit: parseQuitCommandArgs, + q: parseQuitCommandArgs }; diff --git a/src/configuration/keyboard.ts b/src/configuration/keyboard.ts index edb8bee12b3..54514cc488d 100644 --- a/src/configuration/keyboard.ts +++ b/src/configuration/keyboard.ts @@ -43,7 +43,7 @@ export interface IKeyMapper { class KeyMapperEsEsQwerty implements IKeyMapper { private _name = 'es-ES (QWERTY)'; - private _mappings = { + private _mappings: { [key: string]: string } = { '>': ':', '<': ';', '`': '<', @@ -66,7 +66,7 @@ class KeyMapperEsEsQwerty implements IKeyMapper { class KeyMapperDeDeQwertz implements IKeyMapper { private _name = 'de-DE (QWERTZ)'; - private _mappings = { + private _mappings: {[key: string]: string } = { '>': ':', '\\': '<', '<': ';', @@ -85,7 +85,7 @@ class KeyMapperDeDeQwertz implements IKeyMapper { class KeyMapperDaDKQwerty implements IKeyMapper { private _name = 'da-DK (QWERTY)'; - private _mappings = { + private _mappings: { [key: string]: string } = { '>': ':', '\\': '<', '<': ';', @@ -104,7 +104,7 @@ class KeyMapperDaDKQwerty implements IKeyMapper { class KeyMapperSvSEQwerty implements IKeyMapper { private _name = "sv-SE (QWERTY)"; - private _mappings = { + private _mappings: { [key: string]: string } = { 'oem_102': '<', 'shift+oem_102': '>', '>': ':', diff --git a/src/mode/modeHandler.ts b/src/mode/modeHandler.ts index 2eb7d5dbafc..fd330cbdb49 100644 --- a/src/mode/modeHandler.ts +++ b/src/mode/modeHandler.ts @@ -63,7 +63,7 @@ export class VimState { /** * The current full action we are building up. */ - public currentFullAction = []; + public currentFullAction: string[] = []; /** * The position the cursor will be when this action finishes. diff --git a/src/motion/position.ts b/src/motion/position.ts index 84e68e450e9..d0bd3337bac 100644 --- a/src/motion/position.ts +++ b/src/motion/position.ts @@ -295,7 +295,7 @@ export class Position extends vscode.Position { private makeWordRegex(characterSet: string) : RegExp { let escaped = characterSet && _.escapeRegExp(characterSet); - let segments = []; + let segments: string[] = []; segments.push(`([^\\s${escaped}]+)`); segments.push(`[${escaped}]+`); segments.push(`$^`); diff --git a/test/testSimplifier.ts b/test/testSimplifier.ts index 11563b714e9..75bb75f7149 100644 --- a/test/testSimplifier.ts +++ b/test/testSimplifier.ts @@ -12,7 +12,7 @@ export function getTestingFunctions(modeHandler: ModeHandler) { let niceStack = (new Error).stack.split('\n').splice(2, 1).join('\n'); test(testObj.title, async () => testWithObject(testObj) - .catch(reason => { + .catch((reason: Error) => { reason.stack = niceStack; throw reason; }) @@ -24,7 +24,7 @@ export function getTestingFunctions(modeHandler: ModeHandler) { let niceStack = (new Error).stack.split('\n').splice(2, 1).join('\n'); test.only(testObj.title, async () => testWithObject(testObj) - .catch(reason => { + .catch((reason: Error) => { reason.stack = niceStack; throw reason; }) @@ -148,7 +148,7 @@ class TestObjectHelper { function tokenizeKeySequence(sequence: string): string[] { let isBracketedKey = false; let key = ""; - let result = []; + let result: string[] = []; for (const char of sequence) { key += char; diff --git a/tsconfig.json b/tsconfig.json index 9d544b02bff..6ce1cba7029 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,6 +3,7 @@ "module": "commonjs", "target": "es6", "outDir": "out", + "noImplicitAny": true, "noLib": true, "sourceMap": true, "experimentalDecorators": true