Skip to content

Commit e626bc8

Browse files
committed
Use typescript strict mode
1 parent f285f77 commit e626bc8

29 files changed

Lines changed: 50 additions & 54 deletions

cli/argumentsParser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export function parseArguments(processArgs: string[]): CliOptions {
1010
return processArgs.length > 2 && processArgs.find(arg => arg.startsWith("--" + key)) !== undefined;
1111
}
1212

13-
function getArgumentValue(key: string): string {
13+
function getArgumentValue(key: string): string | null {
1414
const hasArguments = processArgs.length > 2;
1515
const split = (hasArguments
1616
? processArgs.find(arg => arg.startsWith("--" + key)) || ""

src/modelFactory/tableIndentationDetector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export abstract class TableIndentationDetector {
33
protected abstract getIndentationChars(leftPadsPerLine: string[]): string;
44

55
public getLeftPad(lines: string[]): string {
6-
const leftPadsPerLine: string[] = lines.map(l => l.match(/^\s*/)[0]);
6+
const leftPadsPerLine: string[] = lines.map(l => (l.match(/^\s*/) || [""])[0]);
77

88
return this.hasIndentation(leftPadsPerLine)
99
? this.getIndentationChars(leftPadsPerLine)

src/modelFactory/transformers/transformer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Table } from "../../models/table";
22

33
export abstract class Transformer {
44

5-
constructor (private _next: Transformer) { }
5+
constructor (private _next: Transformer | null) { }
66

77
protected abstract transform(input: Table): Table;
88

src/models/doc/document.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ export class Document {
1616
return new Range(0, this._lines.length);
1717
}
1818

19-
public getLines(range: Range): Line[] {
19+
public getLines(range: Range | null): Line[] {
2020
return range == null
2121
? this.lines
2222
: this.lines.slice(range.startLine, range.endLine + 1);
2323
}
2424

25-
public getText(range: Range = null): string {
25+
public getText(range: Range | null = null): string {
2626
const lines = this.getLines(range);
2727

2828
return lines.reduce((acc, curr, index) => {

src/models/table.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Row } from "./row";
33

44
export class Table {
55
private readonly _rows: Row[];
6-
private _longestColumnLengthsCache: number[] = null;
6+
private _longestColumnLengthsCache: number[] | null = null;
77

88
constructor(
99
rows: Row[],

src/prettyfiers/multiTablePrettyfier.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class MultiTablePrettyfier {
1818
}
1919

2020
let document = new Document(input);
21-
let tableRange: Range = null;
21+
let tableRange: Range | null = null;
2222
let tableSearchStartLine = 0;
2323

2424
while ((tableRange = this._tableFinder.getNextRange(document, tableSearchStartLine)) != null) {

src/prettyfiers/singleTablePrettyfier.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class SingleTablePrettyfier {
2222

2323
public prettifyTable(document: Document, range: Range) : string
2424
{
25-
let result: string = null;
25+
let result: string | null = null;
2626
let message: string = "";
2727
const selection: string = document.getText(range);
2828

@@ -44,6 +44,6 @@ export class SingleTablePrettyfier {
4444
if (!!message)
4545
this._loggers.forEach(_ => _.logInfo(message));
4646

47-
return result;
47+
return result!;
4848
}
4949
}

src/tableFinding/tableFinder.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export class TableFinder {
1010
private readonly _tableValidator: TableValidator
1111
) { }
1212

13-
public getNextRange(document: Document, startLine: number): Range {
13+
public getNextRange(document: Document, startLine: number): Range | null {
1414
// look for the separator row, assume table starts 1 row before & ends when invalid
1515
let rowIndex = startLine;
1616
let isInIgnoreBlock = false;
@@ -24,7 +24,7 @@ export class TableFinder {
2424

2525
if (!isInIgnoreBlock) {
2626
const isValidSeparatorRow = this._tableValidator.lineIsValidSeparator(document.lines[rowIndex].value);
27-
const nextRangeResult: { range: Range, ignoreBlockStarted: boolean } = isValidSeparatorRow
27+
const nextRangeResult: { range: Range | null, ignoreBlockStarted: boolean } = isValidSeparatorRow
2828
? this.getNextValidTableRange(document, rowIndex)
2929
: { range: null, ignoreBlockStarted: isInIgnoreBlock};
3030

@@ -40,7 +40,7 @@ export class TableFinder {
4040
return null;
4141
}
4242

43-
private getNextValidTableRange(document: Document, separatorRowIndex: number): { range: Range, ignoreBlockStarted: boolean} {
43+
private getNextValidTableRange(document: Document, separatorRowIndex: number): { range: Range | null, ignoreBlockStarted: boolean} {
4444
let firstTableFileRow = separatorRowIndex - 1;
4545
let lastTableFileRow = separatorRowIndex;
4646
let selection = null;

src/viewModels/tableViewModel.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ export class TableViewModel {
55
public get rowCount(): number { return this.rows.length; }
66

77
public leftPad: string = "";
8-
public header: RowViewModel;
9-
public separator: RowViewModel;
8+
public header!: RowViewModel;
9+
public separator!: RowViewModel;
1010
public rows: RowViewModel[] = [];
11-
public hasLeftBorder: boolean;
12-
public hasRightBorder: boolean;
11+
public hasLeftBorder!: boolean;
12+
public hasRightBorder!: boolean;
1313
}

test/stubs/markdownTextDocumentStub.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ import { EOL } from "os";
33
import { TextLineStub } from "./textLineStub";
44

55
export class MarkdownTextDocumentStub implements vscode.TextDocument {
6-
private _lines: string[];
7-
uri: vscode.Uri;
6+
private _lines!: string[];
7+
uri!: vscode.Uri;
88
fileName: string;
99
isUntitled: boolean;
1010
languageId: string;
1111
version: number;
1212
isDirty: boolean;
13-
lineCount: number;
14-
isClosed: boolean;
15-
eol: vscode.EndOfLine;
13+
lineCount!: number;
14+
isClosed!: boolean;
15+
eol!: vscode.EndOfLine;
1616
encoding: string;
1717

1818
constructor(text: string) {

0 commit comments

Comments
 (0)