use thing as type notation instead of <type>thing everywhere

pull/1998/head
Richard Harris 7 years ago
parent 5e30e90e70
commit 3bab16bd9e

@ -156,7 +156,7 @@ export default class Component {
this.tag = options.customElement
? options.customElement === true
? this.meta.tag
: <string>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();

@ -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 = <Atrule>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(<Element>parent);
if (parent.type === 'Element') stack.unshift(parent as Element);
}
for (let i = 0; i < this.children.length; i += 1) {

@ -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') {
(<Text>classAttribute.chunks[0]).data += ` ${className}`;
(classAttribute.chunks[0] as Text).data += ` ${className}`;
} else {
(<Node[]>classAttribute.chunks).push(
new Text(this.component, this, this.scope, {

@ -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: <string>node.key, // TODO...
key: node.key as string,
bindings: new Map(block.bindings)
});

@ -55,7 +55,7 @@ export default class BindingWrapper {
const { name } = getObject(this.node.expression.node);
const eachBlock = this.parent.node.scope.getOwner(name);
(<EachBlock>eachBlock).has_binding = true;
(eachBlock as EachBlock).has_binding = true;
}
this.object = getObject(this.node.expression.node).name;

@ -131,7 +131,7 @@ export default class ElementWrapper extends Wrapper {
if (owner && owner.node.type === 'InlineComponent') {
const name = attribute.getStaticValue();
if (!(<InlineComponentWrapper>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);
(<InlineComponentWrapper>owner).slots.set(name, {
(owner as InlineComponentWrapper).slots.set(name, {
block: child_block,
fn
});
this.renderer.blocks.push(child_block);
}
this.slot_block = (<InlineComponentWrapper>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}`;
(<ElementWrapper>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') {
(<Text>classAttribute.chunks[0]).data += ` ${className}`;
(classAttribute.chunks[0] as Text).data += ` ${className}`;
} else {
(<Node[]>classAttribute.chunks).push(
(classAttribute.chunks as Node[]).push(
new Text(this.component, this, this.scope, {
type: 'Text',
data: ` ${className}`

@ -118,7 +118,7 @@ export default class FragmentWrapper {
}
if (stripWhitespace) {
const first = <TextWrapper>this.nodes[0];
const first = this.nodes[0] as TextWrapper;
if (first && first.node.type === 'Text') {
first.data = trimStart(first.data);

@ -32,12 +32,12 @@ class IfBlockBranch extends Wrapper {
) {
super(renderer, block, parent, node);
this.condition = (<IfBlock>node).expression && (<IfBlock>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(
(<IfBlock>node).expression ? `create_if_block` : `create_else_block`
(node as IfBlock).expression ? `create_if_block` : `create_else_block`
)
});

@ -49,7 +49,7 @@ export default class InlineComponentWrapper extends Wrapper {
const { name } = getObject(binding.expression.node);
const eachBlock = this.node.scope.getOwner(name);
(<EachBlock>eachBlock).has_binding = true;
(eachBlock as EachBlock).has_binding = true;
}
block.addDependencies(binding.expression.dynamic_dependencies);

@ -70,9 +70,9 @@ export default class SlotWrapper extends Wrapper {
attributes.forEach(attribute => {
attribute.chunks.forEach(chunk => {
if ((<Expression>chunk).dependencies) {
addToSet(dependencies, (<Expression>chunk).dependencies);
addToSet(dependencies, (<Expression>chunk).contextual_dependencies);
if ((chunk as Expression).dependencies) {
addToSet(dependencies, (chunk as Expression).dependencies);
addToSet(dependencies, (chunk as Expression).contextual_dependencies);
}
});

Loading…
Cancel
Save