Skip to content

Commit fc66b7f

Browse files
committed
typescript -> ~3.5
Cannot go beyond 3.5 due to GlobalFetch being removed from TS defs in 3.6 @openstax/highlights-client uses GlobalFetch
1 parent 7faa202 commit fc66b7f

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"ts-loader": "^5.2.1",
4141
"tslint": "^5.11.0",
4242
"tslint-loader": "^3.6.0",
43-
"typescript": "<3.2",
43+
"typescript": "~3.5",
4444
"typescript-babel-jest": "^1.0.5"
4545
},
4646
"resolutions": {

src/serializationStrategies/XpathRangeSelector/xpath.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,19 @@ const floatThroughText = (element: Node, offset: number, container: Node): [Node
8989

9090
const resolveToNextElementOffsetIfPossible = (element: Node, offset: number) => {
9191
if (isTextOrTextHighlightOrScreenReaderNode(element) && element.parentNode && offset === getMaxOffset(element) && (!element.nextSibling || !isHighlightOrScreenReaderNode(element.nextSibling))) {
92-
return [element.parentNode, nodeIndex(element.parentNode.childNodes, element) + 1];
92+
return [element.parentNode, nodeIndex(element.parentNode.childNodes, element) + 1] as const;
9393
}
9494

95-
return [element, offset];
95+
return [element, offset] as const;
9696
};
9797

9898
const resolveToPreviousElementOffsetIfPossible = (element: Node, offset: number) => {
9999

100100
if (isTextOrTextHighlightOrScreenReaderNode(element) && element.parentNode && offset === 0 && (!element.previousSibling || !isHighlightOrScreenReaderNode(element.previousSibling))) {
101-
return [element.parentNode, nodeIndex(element.parentNode.childNodes, element)];
101+
return [element.parentNode, nodeIndex(element.parentNode.childNodes, element)] as const;
102102
}
103103

104-
return [element, offset];
104+
return [element, offset] as const;
105105
};
106106

107107
// kinda copied from https://developer.mozilla.org/en-US/docs/Web/XPath/Snippets#getXPathForElement
@@ -138,15 +138,15 @@ export function getXPathForElement(targetElement: Node, offset: number, referenc
138138
pos = 1;
139139

140140
while (element) {
141-
// highlights in text change the number of nodes in the nodelist,
141+
// highlights in text change the number of nodes in the nodelist,z
142142
// compensate by gobbling adjacent highlights and text
143143
if (isTextOrTextHighlightOrScreenReaderNode(focus) && isTextOrTextHighlightOrScreenReaderNode(element)) {
144144
while (isTextOrTextHighlightOrScreenReaderNode(element)) {
145145
element = element.previousSibling!;
146146
}
147147
pos += 1;
148148
} else {
149-
if (isElementNotHighlight(focus) && isElementNotHighlight(element) && element.nodeName === focus.nodeName) {
149+
if (isElementNotHighlight(focus) && isElementNotHighlight(element) && (element as Node).nodeName === (focus as Node).nodeName) {
150150
pos += 1;
151151
}
152152
element = element.previousSibling!;
@@ -222,7 +222,7 @@ export function getFirstByXPath(path: string, offset: number, referenceElement:
222222
node = null;
223223
}
224224

225-
if (isElement(node!) && node!.childNodes.length < offset) {
225+
if (isElement(node!) && (node as Node).childNodes.length < offset) {
226226
node = null;
227227
}
228228

@@ -234,7 +234,7 @@ function followPart(node: Node, part: string) {
234234
const findFirst = (nodeList: NodeList, predicate: (node: Node) => boolean) =>
235235
Array.prototype.find.call(nodeList, (node: Node) => predicate(node));
236236
const findFirstAfter = (nodeList: NodeList, afterThis: Node, predicate: (node: Node) => boolean) => findFirst(
237-
Array.prototype.slice.call(nodeList, Array.prototype.indexOf.call(nodeList, afterThis) + 1),
237+
Array.prototype.slice.call(nodeList, Array.prototype.indexOf.call(nodeList, afterThis) + 1) as unknown as NodeList,
238238
predicate
239239
);
240240

yarn.lock

+5-5
Original file line numberDiff line numberDiff line change
@@ -6008,16 +6008,16 @@ typescript-babel-jest@^1.0.5:
60086008
babel-jest "20.0.3"
60096009
typescript "^2.4.1"
60106010

6011-
typescript@<3.2:
6012-
version "3.1.8"
6013-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.1.8.tgz#20703f388d9fccc562ca4a049d8a7567c8e95ebd"
6014-
integrity sha512-R97qglMfoKjfKD0N24o7W6bS+SwjN/eaQNIaxR8S5HdLRnt7rCk6LCmE3tve1KN8gXKgbJU51aZHRRMAQcIbMA==
6015-
60166011
typescript@^2.4.1:
60176012
version "2.9.2"
60186013
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.9.2.tgz#1cbf61d05d6b96269244eb6a3bce4bd914e0f00c"
60196014
integrity sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==
60206015

6016+
typescript@~3.5:
6017+
version "3.5.3"
6018+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.5.3.tgz#c830f657f93f1ea846819e929092f5fe5983e977"
6019+
integrity sha512-ACzBtm/PhXBDId6a6sDJfroT2pOWt/oOnk4/dElG5G33ZL776N3Y6/6bKZJBFpd+b05F3Ct9qDjMeJmRWtE2/g==
6020+
60216021
uglify-js@^3.1.4:
60226022
version "3.19.3"
60236023
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.19.3.tgz#82315e9bbc6f2b25888858acd1fff8441035b77f"

0 commit comments

Comments
 (0)