diff --git a/src/generators/Generator.ts b/src/generators/Generator.ts index 330f824333..002e52bbf9 100644 --- a/src/generators/Generator.ts +++ b/src/generators/Generator.ts @@ -16,10 +16,14 @@ import DomBlock from './dom/Block'; import SsrBlock from './server-side-rendering/Block'; import Stylesheet from '../css/Stylesheet'; import { Node, GenerateOptions, Parsed, CompileOptions } from '../interfaces'; -import { Computation, TemplateProperties } from './interfaces'; const test = typeof global !== 'undefined' && global.__svelte_test; +interface Computation { + key: string; + deps: string[] +} + export default class Generator { ast: Parsed; parsed: Parsed; @@ -38,7 +42,7 @@ export default class Generator { hasComponents: boolean; hasJs: boolean; computations: Computation[]; - templateProperties: TemplateProperties; + templateProperties: Record; code: MagicString; @@ -410,7 +414,7 @@ export default class Generator { const imports = this.imports; const computations: Computation[] = []; - const templateProperties: TemplateProperties = {}; + const templateProperties: Record = {}; let namespace = null; let hasJs = !!js; @@ -444,7 +448,7 @@ export default class Generator { ['helpers', 'events', 'components', 'transitions'].forEach(key => { if (templateProperties[key]) { - templateProperties[key].value.properties.forEach((prop: node) => { + templateProperties[key].value.properties.forEach((prop: Node) => { this[key].add(prop.key.name); }); } @@ -466,7 +470,7 @@ export default class Generator { const visited = new Set(); - function visit(key: string) { + const visit = function visit(key: string) { if (!dependencies.has(key)) return; // not a computation if (visited.has(key)) return; diff --git a/src/generators/interfaces.ts b/src/generators/interfaces.ts deleted file mode 100644 index 795122a8b5..0000000000 --- a/src/generators/interfaces.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { Node } from '../interfaces'; - -export interface Computation { - key: string; - deps: string[] -} - -export interface TemplateProperties { - computed?: Node; - components?: Node; - data?: Node; - events?: Node; - helpers?: Node; - methods?: Node; - namespace?: Node; - oncreate?: Node; - ondestroy?: Node; - transitions?: Node; - - // TODO remove in v2 - onrender?: Node; - onteardown?: Node; -} \ No newline at end of file diff --git a/src/generators/shared/utils/walkHtml.ts b/src/generators/shared/utils/walkHtml.ts index b7ea97aa55..fb9251b7b4 100644 --- a/src/generators/shared/utils/walkHtml.ts +++ b/src/generators/shared/utils/walkHtml.ts @@ -1,6 +1,6 @@ import { Node, Visitor } from '../../../interfaces'; -export default function walkHtml(html: Node, visitors) { +export default function walkHtml(html: Node, visitors: Record) { function visit(node: Node) { const visitor = visitors[node.type]; if (!visitor) throw new Error(`Not implemented: ${node.type}`); diff --git a/src/utils/namespaces.ts b/src/utils/namespaces.ts index dc5cee2752..a038dfa345 100644 --- a/src/utils/namespaces.ts +++ b/src/utils/namespaces.ts @@ -20,4 +20,6 @@ export const validNamespaces = [ xmlns, ]; -export default { html, mathml, svg, xlink, xml, xmlns }; +const namespaces: Record = { html, mathml, svg, xlink, xml, xmlns }; + +export default namespaces;