diff --git a/src/compile/Component.ts b/src/compile/Component.ts index a0386570e3..c7ca6b7feb 100644 --- a/src/compile/Component.ts +++ b/src/compile/Component.ts @@ -156,7 +156,7 @@ export default class Component { this.tag = options.customElement ? options.customElement === true ? this.meta.tag - : options.customElement + : options.customElement as string : this.name; this.walk_module_js(); @@ -553,7 +553,7 @@ export default class Component { walk_instance_js_post_template() { const script = this.instance_script; if (!script) return; - + this.hoist_instance_declarations(); this.extract_reactive_declarations(); this.extract_reactive_store_references(); diff --git a/src/compile/css/Stylesheet.ts b/src/compile/css/Stylesheet.ts index 2a22782a5a..2cfb960862 100644 --- a/src/compile/css/Stylesheet.ts +++ b/src/compile/css/Stylesheet.ts @@ -316,7 +316,7 @@ export default class Stylesheet { leave: (node: Node) => { if (node.type === 'Rule' || node.type === 'Atrule') stack.pop(); - if (node.type === 'Atrule') currentAtrule = stack[stack.length - 1]; + if (node.type === 'Atrule') currentAtrule = stack[stack.length - 1] as Atrule; } }); } else { @@ -330,7 +330,7 @@ export default class Stylesheet { const stack: Element[] = []; let parent: Node = node; while (parent = parent.parent) { - if (parent.type === 'Element') stack.unshift(parent); + if (parent.type === 'Element') stack.unshift(parent as Element); } for (let i = 0; i < this.children.length; i += 1) { diff --git a/src/compile/nodes/Element.ts b/src/compile/nodes/Element.ts index a7a330e826..362dbb784f 100644 --- a/src/compile/nodes/Element.ts +++ b/src/compile/nodes/Element.ts @@ -661,7 +661,7 @@ export default class Element extends Node { const classAttribute = this.attributes.find(a => a.name === 'class'); if (classAttribute && !classAttribute.isTrue) { if (classAttribute.chunks.length === 1 && classAttribute.chunks[0].type === 'Text') { - (classAttribute.chunks[0]).data += ` ${className}`; + (classAttribute.chunks[0] as Text).data += ` ${className}`; } else { (classAttribute.chunks).push( new Text(this.component, this, this.scope, { diff --git a/src/compile/render-dom/wrappers/EachBlock.ts b/src/compile/render-dom/wrappers/EachBlock.ts index b2741bfe3a..39f3407020 100644 --- a/src/compile/render-dom/wrappers/EachBlock.ts +++ b/src/compile/render-dom/wrappers/EachBlock.ts @@ -80,7 +80,7 @@ export default class EachBlockWrapper extends Wrapper { this.block = block.child({ comment: createDebuggingComment(this.node, this.renderer.component), name: renderer.component.getUniqueName('create_each_block'), - key: node.key, // TODO... + key: node.key as string, bindings: new Map(block.bindings) }); diff --git a/src/compile/render-dom/wrappers/Element/Binding.ts b/src/compile/render-dom/wrappers/Element/Binding.ts index cec3283322..6dc35cc46f 100644 --- a/src/compile/render-dom/wrappers/Element/Binding.ts +++ b/src/compile/render-dom/wrappers/Element/Binding.ts @@ -55,7 +55,7 @@ export default class BindingWrapper { const { name } = getObject(this.node.expression.node); const eachBlock = this.parent.node.scope.getOwner(name); - (eachBlock).has_binding = true; + (eachBlock as EachBlock).has_binding = true; } this.object = getObject(this.node.expression.node).name; diff --git a/src/compile/render-dom/wrappers/Element/index.ts b/src/compile/render-dom/wrappers/Element/index.ts index 21b0053fb5..97654fd19c 100644 --- a/src/compile/render-dom/wrappers/Element/index.ts +++ b/src/compile/render-dom/wrappers/Element/index.ts @@ -131,7 +131,7 @@ export default class ElementWrapper extends Wrapper { if (owner && owner.node.type === 'InlineComponent') { const name = attribute.getStaticValue(); - if (!(owner).slots.has(name)) { + if (!(owner as InlineComponentWrapper).slots.has(name)) { const child_block = block.child({ comment: createDebuggingComment(node, this.renderer.component), name: this.renderer.component.getUniqueName(`create_${sanitize(name)}_slot`) @@ -139,14 +139,14 @@ export default class ElementWrapper extends Wrapper { const fn = get_context_merger(this.node.lets); - (owner).slots.set(name, { + (owner as InlineComponentWrapper).slots.set(name, { block: child_block, fn }); this.renderer.blocks.push(child_block); } - this.slot_block = (owner).slots.get(name).block; + this.slot_block = (owner as InlineComponentWrapper).slots.get(name).block; block = this.slot_block; } } @@ -334,7 +334,7 @@ export default class ElementWrapper extends Wrapper { let open = `<${wrapper.node.name}`; - (wrapper).attributes.forEach((attr: AttributeWrapper) => { + (wrapper as ElementWrapper).attributes.forEach((attr: AttributeWrapper) => { open += ` ${fixAttributeCasing(attr.node.name)}${attr.stringify()}` }); @@ -776,9 +776,9 @@ export default class ElementWrapper extends Wrapper { const classAttribute = this.attributes.find(a => a.name === 'class'); if (classAttribute && !classAttribute.isTrue) { if (classAttribute.chunks.length === 1 && classAttribute.chunks[0].type === 'Text') { - (classAttribute.chunks[0]).data += ` ${className}`; + (classAttribute.chunks[0] as Text).data += ` ${className}`; } else { - (classAttribute.chunks).push( + (classAttribute.chunks as Node[]).push( new Text(this.component, this, this.scope, { type: 'Text', data: ` ${className}` diff --git a/src/compile/render-dom/wrappers/Fragment.ts b/src/compile/render-dom/wrappers/Fragment.ts index fcefae9ebb..e4d989f9a5 100644 --- a/src/compile/render-dom/wrappers/Fragment.ts +++ b/src/compile/render-dom/wrappers/Fragment.ts @@ -118,7 +118,7 @@ export default class FragmentWrapper { } if (stripWhitespace) { - const first = this.nodes[0]; + const first = this.nodes[0] as TextWrapper; if (first && first.node.type === 'Text') { first.data = trimStart(first.data); diff --git a/src/compile/render-dom/wrappers/IfBlock.ts b/src/compile/render-dom/wrappers/IfBlock.ts index 026f668b28..3d12c589ac 100644 --- a/src/compile/render-dom/wrappers/IfBlock.ts +++ b/src/compile/render-dom/wrappers/IfBlock.ts @@ -32,12 +32,12 @@ class IfBlockBranch extends Wrapper { ) { super(renderer, block, parent, node); - this.condition = (node).expression && (node).expression.render(block); + this.condition = (node as IfBlock).expression && (node as IfBlock).expression.render(block); this.block = block.child({ comment: createDebuggingComment(node, parent.renderer.component), name: parent.renderer.component.getUniqueName( - (node).expression ? `create_if_block` : `create_else_block` + (node as IfBlock).expression ? `create_if_block` : `create_else_block` ) }); diff --git a/src/compile/render-dom/wrappers/InlineComponent/index.ts b/src/compile/render-dom/wrappers/InlineComponent/index.ts index 42b962c0bd..5a97be48eb 100644 --- a/src/compile/render-dom/wrappers/InlineComponent/index.ts +++ b/src/compile/render-dom/wrappers/InlineComponent/index.ts @@ -49,7 +49,7 @@ export default class InlineComponentWrapper extends Wrapper { const { name } = getObject(binding.expression.node); const eachBlock = this.node.scope.getOwner(name); - (eachBlock).has_binding = true; + (eachBlock as EachBlock).has_binding = true; } block.addDependencies(binding.expression.dynamic_dependencies); diff --git a/src/compile/render-dom/wrappers/Slot.ts b/src/compile/render-dom/wrappers/Slot.ts index 5c279e5e26..ae81910dba 100644 --- a/src/compile/render-dom/wrappers/Slot.ts +++ b/src/compile/render-dom/wrappers/Slot.ts @@ -70,9 +70,9 @@ export default class SlotWrapper extends Wrapper { attributes.forEach(attribute => { attribute.chunks.forEach(chunk => { - if ((chunk).dependencies) { - addToSet(dependencies, (chunk).dependencies); - addToSet(dependencies, (chunk).contextual_dependencies); + if ((chunk as Expression).dependencies) { + addToSet(dependencies, (chunk as Expression).dependencies); + addToSet(dependencies, (chunk as Expression).contextual_dependencies); } });