Skip to content

Commit

Permalink
Made tsconfig even more strict and fixed compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
nozer committed Aug 14, 2018
1 parent 30c2b34 commit 8714db7
Show file tree
Hide file tree
Showing 21 changed files with 43 additions and 57 deletions.
14 changes: 5 additions & 9 deletions dist/browser/QuillDeltaToHtmlConverter.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,22 +569,20 @@ var QuillDeltaToHtmlConverter = (function () {
html = typeof afterCb === 'function' ? afterCb.apply(null, [groupType, html]) : html;
return html;
};
QuillDeltaToHtmlConverter.prototype._renderList = function (list, isOuterMost) {
QuillDeltaToHtmlConverter.prototype._renderList = function (list) {
var _this = this;
if (isOuterMost === void 0) { isOuterMost = true; }
var firstItem = list.items[0];
return funcs_html_1.makeStartTag(this._getListTag(firstItem.item.op))
+ list.items.map(function (li) { return _this._renderListItem(li, isOuterMost); }).join('')
+ list.items.map(function (li) { return _this._renderListItem(li); }).join('')
+ funcs_html_1.makeEndTag(this._getListTag(firstItem.item.op));
};
QuillDeltaToHtmlConverter.prototype._renderListItem = function (li, isOuterMost) {
var converterOptions = Object._assign({}, this.converterOptions);
QuillDeltaToHtmlConverter.prototype._renderListItem = function (li) {
li.item.op.attributes.indent = 0;
var converter = new OpToHtmlConverter_1.OpToHtmlConverter(li.item.op, this.converterOptions);
var parts = converter.getHtmlParts();
var liElementsHtml = this._renderInlines(li.item.ops, false);
return parts.openingTag + (liElementsHtml) +
(li.innerList ? this._renderList(li.innerList, false) : '')
(li.innerList ? this._renderList(li.innerList) : '')
+ parts.closingTag;
};
QuillDeltaToHtmlConverter.prototype._renderBlock = function (bop, ops) {
Expand Down Expand Up @@ -703,8 +701,7 @@ Array.prototype._intersperse = function (item) {

},{}],9:[function(require,module,exports){
"use strict";
Object._assign = function (target, varArg1, varArg2) {
if (varArg2 === void 0) { varArg2 = null; }
Object._assign = function (target) {
if (target == null) {
throw new TypeError('Cannot convert undefined or null to object');
}
Expand Down Expand Up @@ -934,7 +931,6 @@ var ListNester = (function () {
}
ListNester.prototype.nest = function (groups) {
var _this = this;
var result = [];
var listBlocked = this.convertListBlocksToListGroups(groups);
var groupedByListGroups = this.groupConsecutiveListGroups(listBlocked);
var nested = groupedByListGroups.map(function (group) {
Expand Down
4 changes: 2 additions & 2 deletions dist/commonjs/QuillDeltaToHtmlConverter.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ declare class QuillDeltaToHtmlConverter {
getGroupedOps(): TDataGroup[];
convert(): string;
_renderWithCallbacks(groupType: GroupType, group: TDataGroup, myRenderFn: () => string): string;
_renderList(list: ListGroup, isOuterMost?: boolean): string;
_renderListItem(li: ListItem, isOuterMost: boolean): string;
_renderList(list: ListGroup): string;
_renderListItem(li: ListItem): string;
_renderBlock(bop: DeltaInsertOp, ops: DeltaInsertOp[]): string;
_renderInlines(ops: DeltaInsertOp[], wrapInParagraphTag?: boolean): string;
_renderInline(op: DeltaInsertOp, contextOp: DeltaInsertOp | null): any;
Expand Down
10 changes: 4 additions & 6 deletions dist/commonjs/QuillDeltaToHtmlConverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,20 @@ var QuillDeltaToHtmlConverter = (function () {
html = typeof afterCb === 'function' ? afterCb.apply(null, [groupType, html]) : html;
return html;
};
QuillDeltaToHtmlConverter.prototype._renderList = function (list, isOuterMost) {
QuillDeltaToHtmlConverter.prototype._renderList = function (list) {
var _this = this;
if (isOuterMost === void 0) { isOuterMost = true; }
var firstItem = list.items[0];
return funcs_html_1.makeStartTag(this._getListTag(firstItem.item.op))
+ list.items.map(function (li) { return _this._renderListItem(li, isOuterMost); }).join('')
+ list.items.map(function (li) { return _this._renderListItem(li); }).join('')
+ funcs_html_1.makeEndTag(this._getListTag(firstItem.item.op));
};
QuillDeltaToHtmlConverter.prototype._renderListItem = function (li, isOuterMost) {
var converterOptions = Object._assign({}, this.converterOptions);
QuillDeltaToHtmlConverter.prototype._renderListItem = function (li) {
li.item.op.attributes.indent = 0;
var converter = new OpToHtmlConverter_1.OpToHtmlConverter(li.item.op, this.converterOptions);
var parts = converter.getHtmlParts();
var liElementsHtml = this._renderInlines(li.item.ops, false);
return parts.openingTag + (liElementsHtml) +
(li.innerList ? this._renderList(li.innerList, false) : '')
(li.innerList ? this._renderList(li.innerList) : '')
+ parts.closingTag;
};
QuillDeltaToHtmlConverter.prototype._renderBlock = function (bop, ops) {
Expand Down
3 changes: 1 addition & 2 deletions dist/commonjs/extensions/Object.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"use strict";
Object._assign = function (target, varArg1, varArg2) {
if (varArg2 === void 0) { varArg2 = null; }
Object._assign = function (target) {
if (target == null) {
throw new TypeError('Cannot convert undefined or null to object');
}
Expand Down
1 change: 0 additions & 1 deletion dist/commonjs/grouper/ListNester.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var ListNester = (function () {
}
ListNester.prototype.nest = function (groups) {
var _this = this;
var result = [];
var listBlocked = this.convertListBlocksToListGroups(groups);
var groupedByListGroups = this.groupConsecutiveListGroups(listBlocked);
var nested = groupedByListGroups.map(function (group) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "quill-delta-to-html",
"version": "0.9.2",
"version": "0.9.3",
"description": "Converts Quill's delta ops to HTML",
"main": "./dist/commonjs/main.js",
"types":"./dist/commonjs/main.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/OpToHtmlConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import './extensions/String';
import './extensions/Object';
import { IMention } from "./mentions/MentionSanitizer";
import './extensions/Array';
import { OpAttributeSanitizer, IOpAttributes } from "./OpAttributeSanitizer";
import { OpAttributeSanitizer } from "./OpAttributeSanitizer";


interface IOpToHtmlConverterOptions {
Expand Down
14 changes: 7 additions & 7 deletions src/QuillDeltaToHtmlConverter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import { InsertOpsConverter } from './InsertOpsConverter';
import { OpToHtmlConverter, IOpToHtmlConverterOptions, IHtmlParts } from './OpToHtmlConverter';
import { OpToHtmlConverter, IOpToHtmlConverterOptions } from './OpToHtmlConverter';
import { DeltaInsertOp } from './DeltaInsertOp';
import { Grouper } from './grouper/Grouper';
import {
Expand All @@ -9,7 +9,7 @@ import {
import { ListNester } from './grouper/ListNester';
import { makeStartTag, makeEndTag, encodeHtml } from './funcs-html';
import './extensions/Object';
import { NewLine, GroupType } from './value-types';
import { GroupType } from './value-types';


interface IQuillDeltaToHtmlConverterOptions {
Expand Down Expand Up @@ -142,24 +142,24 @@ class QuillDeltaToHtmlConverter {
return html;
}

_renderList(list: ListGroup, isOuterMost = true): string {
_renderList(list: ListGroup): string {

var firstItem = list.items[0];
return makeStartTag(this._getListTag(firstItem.item.op))
+ list.items.map((li: ListItem) => this._renderListItem(li, isOuterMost)).join('')
+ list.items.map((li: ListItem) => this._renderListItem(li)).join('')
+ makeEndTag(this._getListTag(firstItem.item.op));
}

_renderListItem(li: ListItem, isOuterMost: boolean): string {
var converterOptions = Object._assign({}, this.converterOptions);
_renderListItem(li: ListItem ): string {

//if (!isOuterMost) {
li.item.op.attributes.indent = 0;
//}
var converter = new OpToHtmlConverter(li.item.op, this.converterOptions);
var parts = converter.getHtmlParts();
var liElementsHtml = this._renderInlines(li.item.ops, false);
return parts.openingTag + (liElementsHtml) +
(li.innerList ? this._renderList(li.innerList, false) : '')
(li.innerList ? this._renderList(li.innerList) : '')
+ parts.closingTag;
}

Expand Down
2 changes: 1 addition & 1 deletion src/extensions/Object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ interface ObjectConstructor {


// Copied from mdn's Object.assign
Object._assign = function (target: any, varArg1: any, varArg2: any = null) {
Object._assign = function (target: any) {

// TypeError if undefined or null
if (target == null) {
Expand Down
4 changes: 1 addition & 3 deletions src/grouper/Grouper.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@

import { DeltaInsertOp } from './../DeltaInsertOp';
import { NewLine } from './../value-types';
import './../extensions/Array';

import {
VideoItem, InlineGroup, BlockGroup, ListGroup, ListItem, TDataGroup
VideoItem, InlineGroup, BlockGroup, TDataGroup
} from './group-types';
import { ListNester } from './ListNester';

class Grouper {

Expand Down
3 changes: 1 addition & 2 deletions src/grouper/ListNester.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@

import {
ListGroup, ListItem, BlockGroup, VideoItem, InlineGroup, TDataGroup
ListGroup, ListItem, BlockGroup, TDataGroup
} from './group-types';

class ListNester {
nest(groups: TDataGroup[]): TDataGroup[] {

var result: TDataGroup[] = [];
var listBlocked = this.convertListBlocksToListGroups(groups);
var groupedByListGroups = this.groupConsecutiveListGroups(listBlocked);

Expand Down
2 changes: 1 addition & 1 deletion test/DeltaInsertOp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import 'mocha';
import * as assert from "assert";

import {InsertData, InsertDataQuill} from './../src/InsertData';
import {InsertDataQuill} from './../src/InsertData';
import {DeltaInsertOp} from './../src/DeltaInsertOp';
import {DataType, AlignType, ListType} from './../src/value-types';

Expand Down
2 changes: 1 addition & 1 deletion test/InsertData.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import 'mocha';
import * as assert from "assert";

import { InsertData, InsertDataQuill, InsertDataCustom } from './../src/InsertData';
import {InsertDataQuill, InsertDataCustom } from './../src/InsertData';
import {DataType} from './../src/value-types';

describe('InsertData', function () {
Expand Down
2 changes: 0 additions & 2 deletions test/InsertOpDenormalizer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
import 'mocha';
import * as assert from 'assert';

import {DeltaInsertOp} from './../src/DeltaInsertOp';

import {
InsertOpDenormalizer
} from "./../src/InsertOpDenormalizer";
Expand Down
4 changes: 2 additions & 2 deletions test/InsertOpsConverter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'mocha';
import * as assert from 'assert';

import {DeltaInsertOp} from './../src/DeltaInsertOp';
import {InsertData, InsertDataCustom, InsertDataQuill} from './../src/InsertData';
import {InsertDataQuill} from './../src/InsertData';
import { InsertOpsConverter } from "./../src/InsertOpsConverter";

var data = [
Expand Down Expand Up @@ -69,7 +69,7 @@ describe('InsertOpsConverter', function () {
assert.equal(act, null);
});

["fdsf", {image: 'ff'}, {video: ''}, {formula: ''}].forEach((v, i) => {
["fdsf", {image: 'ff'}, {video: ''}, {formula: ''}].forEach((v) => {
var act = InsertOpsConverter.convertInsertVal(v);
assert.notEqual(act, null);
assert.ok(act instanceof InsertDataQuill);
Expand Down
4 changes: 2 additions & 2 deletions test/OpToHtmlConverter.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

import { OpToHtmlConverter } from "./../src/OpToHtmlConverter";
import { DeltaInsertOp } from './../src/DeltaInsertOp';
import { InsertData, InsertDataQuill, InsertDataCustom } from './../src/InsertData';
import { ListType, ScriptType, DirectionType, AlignType, DataType } from './../src/value-types';
import { InsertDataQuill } from './../src/InsertData';
import { ScriptType, DirectionType, AlignType, DataType } from './../src/value-types';

let assert = require('assert');

Expand Down
12 changes: 5 additions & 7 deletions test/QuillDeltaToHtmlConverter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import 'mocha';
import * as assert from 'assert';

import { DeltaInsertOp } from './../src/DeltaInsertOp';
import { OpToHtmlConverter } from './../src/OpToHtmlConverter';
import { QuillDeltaToHtmlConverter } from "./../src/QuillDeltaToHtmlConverter";
import { callWhenAlltrue, callWhenXEqualY } from './_helper';
import { callWhenXEqualY } from './_helper';

import { delta1 } from './data/delta1';
import { GroupType, ListType } from './../src/value-types';
Expand Down Expand Up @@ -154,7 +153,7 @@ describe('QuillDeltaToHtmlConverter', function () {
{ insert: { blah: 1 } }
];
let qdc = new QuillDeltaToHtmlConverter(ops);
qdc.renderCustomWith((op, ctx) => {
qdc.renderCustomWith((op) => {
if (op.insert.type === 'bolditalic') {
return '<b><i>' + op.insert.value + '</i></b>';
}
Expand All @@ -173,7 +172,7 @@ describe('QuillDeltaToHtmlConverter', function () {
{ insert: { colonizer: ':' }},
{ insert: "\n", attributes: { 'code-block': true } }
];
let renderer = (op: DeltaInsertOp, ctx: DeltaInsertOp) => {
let renderer = (op: DeltaInsertOp) => {
if (op.insert.type === 'colonizer') {
return op.insert.value;
}
Expand All @@ -197,7 +196,7 @@ describe('QuillDeltaToHtmlConverter', function () {
{ insert: { colonizer: ':' }},
{ insert: "\n", attributes: { header: 1 } }
];
let renderer = (op: DeltaInsertOp, ctx: DeltaInsertOp) => {
let renderer = (op: DeltaInsertOp) => {
if (op.insert.type === 'colonizer') {
return op.insert.value;
}
Expand Down Expand Up @@ -444,7 +443,7 @@ describe('QuillDeltaToHtmlConverter', function () {
];
let status = {x:0, y: 3};
let qdc = new QuillDeltaToHtmlConverter(ops);
qdc.beforeRender((gtype: any, data: any) => {
qdc.beforeRender((gtype: any) => {
gtype === 'block' && status.x++;
return '';
});
Expand All @@ -464,7 +463,6 @@ describe('QuillDeltaToHtmlConverter', function () {
});

it('should register and use callbacks if they are functions', function () {
var jobstatus = [false, false];
var c = new QuillDeltaToHtmlConverter([
{ insert: { video: "http" } }, { insert: 'aa' }]);
var dummy = (): any => '';
Expand Down
4 changes: 2 additions & 2 deletions test/grouper/Grouper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import * as assert from "assert";

import { Grouper } from './../../src/grouper/Grouper';
import { DeltaInsertOp } from './../../src/DeltaInsertOp';
import { InsertData, InsertDataQuill } from './../../src/InsertData';
import { ListGroup, ListItem, VideoItem, InlineGroup, BlockGroup, TDataGroup
import { InsertDataQuill } from './../../src/InsertData';
import { VideoItem, InlineGroup, BlockGroup
} from './../../src/grouper/group-types';
import {DataType} from './../../src/value-types';
describe('Grouper', function () {
Expand Down
3 changes: 1 addition & 2 deletions test/grouper/ListNester.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import * as assert from "assert";
import { Grouper } from './../../src/grouper/Grouper';
import { ListNester } from './../../src/grouper/ListNester';
import { DeltaInsertOp } from './../../src/DeltaInsertOp';
import { InsertData } from './../../src/InsertData';
import { ListGroup, ListItem, VideoItem, InlineGroup, BlockGroup, TDataGroup
import { ListGroup, ListItem, InlineGroup, BlockGroup
} from './../../src/grouper/group-types';
import {ListType} from './../../src/value-types';

Expand Down
1 change: 0 additions & 1 deletion test/mentions/MentionSanitizer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'mocha';
import * as assert from 'assert';

import {MentionSanitizer} from "./../../src/mentions/MentionSanitizer";
import { IMention } from '../../src/mentions/MentionSanitizer';

describe('MentionSanitizer', function () {

Expand Down
7 changes: 5 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"compilerOptions": {
"module": "commonjs",
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"sourceMap": false,
Expand All @@ -16,8 +15,12 @@
],
"declaration": true,
"noImplicitThis": true,
"noImplicitAny": true,
"strictNullChecks": true,
"alwaysStrict": true
"alwaysStrict": true,
"noUnusedParameters": true,
"noUnusedLocals": true,
"noFallthroughCasesInSwitch": true
},
"include": [
"src/**/*.ts"
Expand Down

0 comments on commit 8714db7

Please sign in to comment.