Skip to content

Commit 94272cb

Browse files
committed
feat(commandpost): add strict: true option to tsconfig.json
1 parent c41bb6e commit 94272cb

File tree

6 files changed

+9
-31
lines changed

6 files changed

+9
-31
lines changed

lib/argument.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"use strict";
2-
31
// jsdoc, see constructor.
42
export default class Argument {
53
/** argument name */

lib/command.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"use strict";
2-
31
import Option from "./option";
42
import Argument from "./argument";
53

@@ -118,7 +116,7 @@ export default class Command<Opt, Arg> {
118116
*/
119117
constructor(name: string) {
120118
let args = name.split(/\s+/);
121-
this.name = args.shift();
119+
this.name = args.shift()!;
122120

123121
let findOptional = false;
124122
let findVariadic = false;
@@ -389,7 +387,7 @@ export default class Command<Opt, Arg> {
389387
let rest: string[] = [];
390388
let processedOptions: Option[] = [];
391389
while (args.length !== 0) {
392-
let arg = args.shift();
390+
let arg = args.shift()!;
393391
if (arg === "--") {
394392
rest = rest.concat(args);
395393
break;
@@ -443,7 +441,7 @@ export default class Command<Opt, Arg> {
443441
let result: string[] = [];
444442
for (let i = 0; i < args.length; i++) {
445443
let arg = args[i];
446-
let lastOpt: Option;
444+
let lastOpt: Option | undefined;
447445
if (0 < i) {
448446
lastOpt = this.options.filter(opt => opt.is(args[i - 1]))[0];
449447
}

lib/index.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"use strict";
2-
31
try {
42
// optional
53
require("source-map-support").install();
@@ -24,8 +22,6 @@ export { Command, Option, Argument };
2422
* @returns {Command<Opt, Arg>}
2523
*/
2624
export function create<Opt, Arg>(cmdName: string): Command<Opt, Arg> {
27-
"use strict";
28-
2925
return new Command<Opt, Arg>(cmdName);
3026
}
3127

@@ -36,8 +32,6 @@ export function create<Opt, Arg>(cmdName: string): Command<Opt, Arg> {
3632
* @returns {Promise<{}>}
3733
*/
3834
export function exec(cmd: Command<any, any>, argv: string[]): Promise<{}> {
39-
"use strict";
40-
4135
return Promise
4236
.resolve(null)
4337
.then(() => {

lib/option.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"use strict";
2-
31
import * as utils from "./utils";
42

53
// jsdoc, see constructor.
@@ -34,9 +32,9 @@ export default class Option {
3432
this.no = flags.indexOf("-no-") === -1;
3533
let splittedFlags = flags.split(/[ ,|]+/);
3634
if (splittedFlags.length > 1 && !/^[[<]/.test(splittedFlags[1])) {
37-
this.short = splittedFlags.shift();
35+
this.short = splittedFlags.shift()!;
3836
}
39-
this.long = splittedFlags.shift();
37+
this.long = splittedFlags.shift()!;
4038
this.description = description || "";
4139
if (typeof this.defaultValue === "undefined") {
4240
if (this.required || this.optional) {

lib/utils.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
"use strict";
2-
31
/**
42
* calc max length of strs.
53
* @param strs
64
* @returns {number}
75
* @private
86
*/
97
export function maxLength(strs: string[]): number {
10-
"use strict";
11-
128
return strs.map(str => str.length).reduce((p, c) => Math.max(p, c), 0);
139
}
1410

@@ -21,8 +17,6 @@ export function maxLength(strs: string[]): number {
2117
* @private
2218
*/
2319
export function pad(str: string, length: number, pad = " "): string {
24-
"use strict";
25-
2620
if (length <= str.length) {
2721
return str;
2822
}
@@ -42,8 +36,6 @@ export function pad(str: string, length: number, pad = " "): string {
4236
* @private
4337
*/
4438
export function chainToLowerCamelCase(str: string): string {
45-
"use strict";
46-
4739
let nextCamel = false;
4840
return str
4941
.split("")

tsconfig.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@
99
"types": [
1010
"node",
1111
"mocha"
12-
],
13-
"noImplicitAny": true,
14-
"strictNullChecks": false,
12+
],
13+
"strict": true,
1514
"noFallthroughCasesInSwitch": true,
1615
"noImplicitReturns": true,
17-
"noImplicitThis": true,
1816
"noUnusedLocals": true,
1917
"noUnusedParameters": true,
2018
"experimentalDecorators": true,
@@ -38,5 +36,5 @@
3836
],
3937
"exclude": [
4038
"node_modules"
41-
]
42-
}
39+
]
40+
}

0 commit comments

Comments
 (0)