Address new TypeScript warnings from VS Code.

This commit is contained in:
David Anson 2022-06-12 17:51:47 -07:00
parent 36adb5e4d2
commit 6934d24651
2 changed files with 6 additions and 6 deletions

View file

@ -393,7 +393,7 @@ module.exports.flattenLists = function flattenLists(tokens) {
nesting = 0; nesting = 0;
} }
else if (token.type === "blockquote_close") { else if (token.type === "blockquote_close") {
nesting = nestingStack.pop(); nesting = nestingStack.pop() || 0;
} }
if (token.map) { if (token.map) {
// Track last token with map // Track last token with map
@ -573,7 +573,7 @@ module.exports.addErrorDetailIf = function addErrorDetailIf(onError, lineNumber,
// Adds an error object with context via the onError callback // Adds an error object with context via the onError callback
module.exports.addErrorContext = function addErrorContext(onError, lineNumber, context, left, right, range, fixInfo) { module.exports.addErrorContext = function addErrorContext(onError, lineNumber, context, left, right, range, fixInfo) {
context = ellipsify(context, left, right); context = ellipsify(context, left, right);
addError(onError, lineNumber, null, context, range, fixInfo); addError(onError, lineNumber, undefined, context, range, fixInfo);
}; };
/** /**
* Returns an array of code block and span content ranges. * Returns an array of code block and span content ranges.
@ -975,7 +975,7 @@ function normalizeFixInfo(fixInfo, lineNumber) {
* @param {string} line Line of Markdown content. * @param {string} line Line of Markdown content.
* @param {Object} fixInfo RuleOnErrorFixInfo instance. * @param {Object} fixInfo RuleOnErrorFixInfo instance.
* @param {string} [lineEnding] Line ending to use. * @param {string} [lineEnding] Line ending to use.
* @returns {string} Fixed content. * @returns {string | null} Fixed content.
*/ */
function applyFix(line, fixInfo, lineEnding) { function applyFix(line, fixInfo, lineEnding) {
const { editColumn, deleteCount, insertText } = normalizeFixInfo(fixInfo); const { editColumn, deleteCount, insertText } = normalizeFixInfo(fixInfo);

View file

@ -392,7 +392,7 @@ module.exports.flattenLists = function flattenLists(tokens) {
nestingStack.push(nesting); nestingStack.push(nesting);
nesting = 0; nesting = 0;
} else if (token.type === "blockquote_close") { } else if (token.type === "blockquote_close") {
nesting = nestingStack.pop(); nesting = nestingStack.pop() || 0;
} }
if (token.map) { if (token.map) {
// Track last token with map // Track last token with map
@ -578,7 +578,7 @@ module.exports.addErrorDetailIf = function addErrorDetailIf(
module.exports.addErrorContext = function addErrorContext( module.exports.addErrorContext = function addErrorContext(
onError, lineNumber, context, left, right, range, fixInfo) { onError, lineNumber, context, left, right, range, fixInfo) {
context = ellipsify(context, left, right); context = ellipsify(context, left, right);
addError(onError, lineNumber, null, context, range, fixInfo); addError(onError, lineNumber, undefined, context, range, fixInfo);
}; };
/** /**
@ -1002,7 +1002,7 @@ function normalizeFixInfo(fixInfo, lineNumber) {
* @param {string} line Line of Markdown content. * @param {string} line Line of Markdown content.
* @param {Object} fixInfo RuleOnErrorFixInfo instance. * @param {Object} fixInfo RuleOnErrorFixInfo instance.
* @param {string} [lineEnding] Line ending to use. * @param {string} [lineEnding] Line ending to use.
* @returns {string} Fixed content. * @returns {string | null} Fixed content.
*/ */
function applyFix(line, fixInfo, lineEnding) { function applyFix(line, fixInfo, lineEnding) {
const { editColumn, deleteCount, insertText } = normalizeFixInfo(fixInfo); const { editColumn, deleteCount, insertText } = normalizeFixInfo(fixInfo);