Skip to content

Commit cc55664

Browse files
authored
Merge pull request #222 from Auge19/tsconfig
Configure TypeScript to be stricter
2 parents 76d46df + 9dca7c1 commit cc55664

File tree

66 files changed

+359
-311
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+359
-311
lines changed

builds/knockout/helpers/jasmine.extensions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jasmine.Matchers.prototype.toContainHtml = function (expectedHtml, postProcessCl
4444
};
4545

4646
jasmine.nodeText = function(node) {
47-
return node.nodeType == 3 ? node.data : 'textContent' in node ? node.textContent : node.innerText;
47+
return node.nodeType === Node.TEXT_NODE ? node.data : 'textContent' in node ? node.textContent : node.innerText;
4848
}
4949

5050
jasmine.Matchers.prototype.toContainText = function (expectedText, ignoreSpaces) {

builds/knockout/spec/bindingAttributeBehaviors.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ describe('Binding attribute syntax', function() {
390390
// Counts the number of virtual children, and overwrites the text contents of any text nodes
391391
for (var node = ko.virtualElements.firstChild(element); node; node = ko.virtualElements.nextSibling(node)) {
392392
countNodes++;
393-
if (node.nodeType === 3)
393+
if (node.nodeType === Node.TEXT_NODE)
394394
node.data = 'new text';
395395
}
396396
}
@@ -558,15 +558,15 @@ describe('Binding attribute syntax', function() {
558558
nodeHasBindings: function(node) {
559559
// IE < 9 can't bind text nodes, as expando properties are not allowed on them.
560560
// This will still prove that the binding provider was not executed on the children of a restricted element.
561-
if (node.nodeType === 3 && jasmine.ieVersion < 9) {
561+
if (node.nodeType === Node.TEXT_NODE && jasmine.ieVersion < 9) {
562562
node.data = "replaced";
563563
return false;
564564
}
565565

566566
return true;
567567
},
568568
getBindingAccessors: function(node, bindingContext) {
569-
if (node.nodeType === 3) {
569+
if (node.nodeType === Node.TEXT_NODE) {
570570
return {
571571
replaceTextNodeContent: function() { return "replaced"; }
572572
};

builds/knockout/spec/defaultBindings/foreachBehaviors.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ describe('Binding: Foreach', function() {
232232
preprocessingBindingProvider.prototype = originalBindingProvider;
233233
ko.bindingProvider.instance = new preprocessingBindingProvider();
234234
ko.bindingProvider.instance.preprocessNode = function(node) {
235-
if (node.nodeType === 3 && node.data.charAt(0) === "$") {
235+
if (node.nodeType === Node.TEXT_NODE && node.data.charAt(0) === "$") {
236236
var newNodes = [
237237
document.createComment('ko text: ' + node.data),
238238
document.createComment('/ko')
@@ -655,7 +655,7 @@ describe('Binding: Foreach', function() {
655655
{ name: ko.observable('Moon') },
656656
{ name: ko.observable('Ceres') }
657657
]), beforeRemove = function(elem) {
658-
if (elem.nodeType === 1) {
658+
if (elem.nodeType === Node.ELEMENT_NODE) {
659659
setTimeout(function() {
660660
ko.removeNode(elem);
661661
}, 1);

builds/knockout/spec/defaultBindings/textBehaviors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ describe('Binding: Text', function() {
6161
return true;
6262
},
6363
getBindingAccessors: function(node, bindingContext) {
64-
if (node.nodeType === 3) {
64+
if (node.nodeType === Node.TEXT_NODE) {
6565
return {
6666
replaceTextNodeContent: function() { return "should not see this value in the output"; }
6767
};

builds/knockout/spec/nodePreprocessingBehaviors.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ describe('Node preprocessing', function() {
4242
ko.bindingProvider.instance.preprocessNode = function(node) {
4343
// Example: Replace {{ someValue }} with text from that property.
4444
// This could be generalized to full support for string interpolation in text nodes.
45-
if (node.nodeType === 3 && node.data.indexOf("{{ someValue }}") >= 0) {
45+
if (node.nodeType === Node.TEXT_NODE && node.data.indexOf("{{ someValue }}") >= 0) {
4646
var prefix = node.data.substring(0, node.data.indexOf("{{ someValue }}")),
4747
suffix = node.data.substring(node.data.indexOf("{{ someValue }}") + "{{ someValue }}".length),
4848
newNodes = [
@@ -107,7 +107,7 @@ describe('Node preprocessing', function() {
107107
it('Should call a childrenComplete callback, passing all of the rendered nodes, accounting for node preprocessing and virtual element bindings', function () {
108108
// Set up a binding provider that converts text nodes to expressions
109109
ko.bindingProvider.instance.preprocessNode = function (node) {
110-
if (node.nodeType === 3 && node.data.charAt(0) === "$") {
110+
if (node.nodeType === Node.TEXT_NODE && node.data.charAt(0) === "$") {
111111
var newNodes = [
112112
document.createComment('ko text: ' + node.data),
113113
document.createComment('/ko')

builds/knockout/spec/templatingBehaviors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export var dummyTemplateEngine = function (templates) {
2424
this.makeTemplateSource = function(template) {
2525
if (typeof template == "string")
2626
return new dummyTemplateSource(template); // Named template comes from the in-memory collection
27-
else if ((template.nodeType == 1) || (template.nodeType == 8))
27+
else if ((template.nodeType === Node.ELEMENT_NODE) || (template.nodeType === Node.COMMENT_NODE))
2828
return new ko.templateSources.anonymousTemplate(template); // Anonymous template
2929
};
3030

packages/bind/docs/binding-preprocessing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ If you commonly include template content using virtual elements, the normal synt
103103
```javascript
104104
ko.bindingProvider.instance.preprocessNode = function(node) {
105105
// Only react if this is a comment node of the form <!-- template: ... -->
106-
if (node.nodeType == 8) {
106+
if (node.nodeType === Node.COMMENT_NODE) {
107107
var match = node.nodeValue.match(/^\s*(template\s*:[\s\S]+)/);
108108
if (match) {
109109
// Create a pair of comments to replace the single comment

packages/bind/spec/bindingAttributeBehaviors.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ describe('Binding attribute syntax', function () {
609609
// Counts the number of virtual children, and overwrites the text contents of any text nodes
610610
for (let node = virtualElements.firstChild(element); node; node = virtualElements.nextSibling(node)) {
611611
countNodes++
612-
if (node.nodeType === 3) {
612+
if (node.nodeType === Node.TEXT_NODE) {
613613
;(node as Text).data = 'new text'
614614
}
615615
}
@@ -826,21 +826,21 @@ describe('Binding attribute syntax', function () {
826826

827827
let originalBindingProvider = options.bindingProviderInstance
828828
class TestProvider extends Provider {
829-
get FOR_NODE_TYPES() {
830-
return [3]
829+
override get FOR_NODE_TYPES() {
830+
return [Node.TEXT_NODE]
831831
}
832-
nodeHasBindings(node) {
832+
override nodeHasBindings(node) {
833833
// IE < 9 can't bind text nodes, as expando properties are not allowed on them.
834834
// This will still prove that the binding provider was not executed on the children of a restricted element.
835-
if (node.nodeType === 3 && jasmine.ieVersion < 9) {
835+
if (node.nodeType === Node.TEXT_NODE && jasmine.ieVersion < 9) {
836836
node.data = 'replaced'
837837
return false
838838
}
839839

840840
return true
841841
}
842-
getBindingAccessors(node, bindingContext) {
843-
if (node.nodeType === 3) {
842+
override getBindingAccessors(node, bindingContext) {
843+
if (node.nodeType === Node.TEXT_NODE) {
844844
return {
845845
replaceTextNodeContent: function () {
846846
return 'replaced'

packages/bind/spec/bindingCompletionPromiseBehavior.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ describe('Binding Application Promise', function () {
1717
let bindingHandlers: BindingHandlerObject
1818

1919
class SyncBinding extends BindingHandler {
20-
get bindingCompleted() {
20+
override get bindingCompleted() {
2121
return this.value(true)
2222
}
23-
static get allowVirtualElements() {
23+
static override get allowVirtualElements() {
2424
return true
2525
}
2626
}
2727

2828
class AsyncBinding extends BindingHandler {
29-
get bindingCompleted() {
29+
override get bindingCompleted() {
3030
return options.Promise.resolve().then(() => this.value(true))
3131
}
32-
static get allowVirtualElements() {
32+
static override get allowVirtualElements() {
3333
return true
3434
}
3535
}
@@ -42,10 +42,10 @@ describe('Binding Application Promise', function () {
4242
)
4343
}
4444

45-
get controlsDescendants() {
45+
override get controlsDescendants() {
4646
return true
4747
}
48-
get bindingCompleted() {
48+
override get bindingCompleted() {
4949
return this.bindingCompletion.then(() => this.value(true))
5050
}
5151
}

packages/bind/spec/bindingDependencyBehaviors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ describe('Binding dependencies', function () {
289289
let observable = observableConstructor('substitute')
290290

291291
class TestProvider extends DataBindProvider {
292-
getBindingAccessors(node, bindingContext) {
292+
override getBindingAccessors(node, bindingContext) {
293293
let bindings = super.getBindingAccessors(node, bindingContext)
294294
if (bindings && bindings.text) {
295295
let newValue = observable()

0 commit comments

Comments
 (0)