fix various TS complaints

pull/941/head
Rich Harris 8 years ago
parent ffe232e04a
commit 4e4ef173d6

@ -0,0 +1 @@
export const test = typeof process !== 'undefined' && process.env.TEST;

@ -322,7 +322,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 = <Atrule>stack[stack.length - 1];
}
});
} else {

@ -16,10 +16,9 @@ import clone from '../utils/clone';
import DomBlock from './dom/Block';
import SsrBlock from './server-side-rendering/Block';
import Stylesheet from '../css/Stylesheet';
import { test } from '../config';
import { Node, GenerateOptions, Parsed, CompileOptions, CustomElementOptions } from '../interfaces';
const test = typeof global !== 'undefined' && global.__svelte_test;
interface Computation {
key: string;
deps: string[]

@ -202,7 +202,7 @@ export default class Block {
}
// minor hack we need to ensure that any {{{triples}}} are detached first
this.builders.unmount.addBlockAtStart(this.builders.detachRaw);
this.builders.unmount.addBlockAtStart(this.builders.detachRaw.toString());
const properties = new CodeBuilder();

@ -14,11 +14,9 @@ import Generator from '../Generator';
import Stylesheet from '../../css/Stylesheet';
import preprocess from './preprocess';
import Block from './Block';
import { version } from '../../../package.json';
import { test } from '../../config';
import { Parsed, CompileOptions, Node } from '../../interfaces';
const test = typeof global !== 'undefined' && global.__svelte_test;
export class DomGenerator extends Generator {
blocks: (Block|string)[];
readonly: Set<string>;
@ -167,9 +165,9 @@ export default function dom(
builder.addBlock(block.toString());
});
const sharedPath = options.shared === true
const sharedPath: string = options.shared === true
? 'svelte/shared.js'
: options.shared;
: options.shared || '';
const prototypeBase =
`${name}.prototype` +
@ -444,7 +442,7 @@ export default function dom(
);
return generator.generate(result, options, {
banner: `/* ${filename ? `${filename} ` : ``}generated by Svelte v${version} */`,
banner: `/* ${filename ? `${filename} ` : ``}generated by Svelte v__VERSION__ */`,
sharedPath,
helpers,
name,

@ -28,7 +28,7 @@ export default function visitWindow(
node: Node
) {
const events = {};
const bindings = {};
const bindings: Record<string, string> = {};
node.attributes.forEach((attribute: Node) => {
if (attribute.type === 'EventHandler') {

@ -26,7 +26,7 @@ export default function visitEachBlock(
contextDependencies.set(node.context, dependencies);
if (node.destructuredContexts) {
for (const i = 0; i < node.destructuredContexts.length; i++) {
for (let i = 0; i < node.destructuredContexts.length; i += 1) {
contexts.set(node.destructuredContexts[i], `${node.context}[${i}]`);
contextDependencies.set(node.destructuredContexts[i], dependencies);
}

@ -65,7 +65,7 @@ export interface GenerateOptions {
name: string;
format: ModuleFormat;
banner?: string;
sharedPath?: string | boolean;
sharedPath?: string;
helpers?: { name: string, alias: string }[];
}

@ -23,6 +23,8 @@ interface ParserOptions {
filename?: string;
}
type ParserState = (parser: Parser) => (ParserState | void);
export class Parser {
readonly template: string;
readonly filename?: string;
@ -59,7 +61,7 @@ export class Parser {
this.stack.push(this.html);
let state = fragment;
let state: ParserState = fragment;
while (this.index < this.template.length) {
state = state(this) || fragment;
@ -94,7 +96,7 @@ export class Parser {
return this.stack[this.stack.length - 1];
}
acornError(err: Error) {
acornError(err: any) {
this.error(err.message.replace(/ \(\d+:\d+\)$/, ''), err.pos);
}

@ -1,6 +1,5 @@
{
"compilerOptions": {
"noImplicitAny": true,
"diagnostics": true,
"noImplicitThis": true,
"noEmitOnError": true,

Loading…
Cancel
Save