chore: more specific typings, and add README note about Yarn (#4483)

pull/4498/head
Brian Takita 5 years ago committed by GitHub
parent 3f647a84f6
commit 3a37de364b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -32,6 +32,8 @@ cd svelte
npm install
```
> Do not use Yarn to install the dependencies, as the specific package versions in `package-lock.json` are used to build and test Svelte.
> Many tests depend on newlines being preserved as `<LF>`. On Windows, you can ensure this by cloning with:
> ```bash
> git -c core.autocrlf=false clone https://github.com/sveltejs/svelte.git

@ -239,7 +239,7 @@ export default class Component {
const program: any = { type: 'Program', body: result.js };
walk(program, {
enter: (node, parent, key) => {
enter: (node: Node, parent: Node, key) => {
if (node.type === 'Identifier') {
if (node.name[0] === '@') {
if (node.name[1] === '_') {
@ -526,7 +526,7 @@ export default class Component {
if (!script) return;
walk(script.content, {
enter(node) {
enter(node: Node) {
if (node.type === 'LabeledStatement' && node.label.name === '$') {
component.warn(node as any, {
code: 'module-script-reactive-declaration',
@ -715,7 +715,7 @@ export default class Component {
let scope_updated = false;
walk(content, {
enter(node, parent, prop, index) {
enter(node: Node, parent, prop, index) {
if (map.has(node)) {
scope = map.get(node);
}
@ -741,7 +741,7 @@ export default class Component {
component.warn_on_undefined_store_value_references(node, parent, scope);
},
leave(node) {
leave(node: Node) {
// do it on leave, to prevent infinite loop
if (component.compile_options.dev && component.compile_options.loopGuardTimeout > 0) {
const to_replace_for_loop_protect = component.loop_protect(node, scope, component.compile_options.loopGuardTimeout);
@ -785,7 +785,7 @@ export default class Component {
let scope = instance_scope;
walk(content, {
enter(node, parent) {
enter(node: Node, parent: Node) {
if (map.has(node)) {
scope = map.get(node);
}
@ -818,7 +818,7 @@ export default class Component {
}
},
leave(node) {
leave(node: Node) {
if (map.has(node)) {
scope = scope.parent;
}
@ -886,7 +886,7 @@ export default class Component {
let scope = instance_scope;
walk(this.ast.instance.content, {
enter(node, parent, key, index) {
enter(node: Node, parent, key, index) {
if (/Function/.test(node.type)) {
return this.skip();
}
@ -963,7 +963,7 @@ export default class Component {
}
},
leave(node, parent, _key, index) {
leave(node: Node, parent, _key, index) {
if (map.has(node)) {
scope = scope.parent;
}
@ -1064,7 +1064,7 @@ export default class Component {
walking.add(fn_declaration);
walk(fn_declaration, {
enter(node, parent) {
enter(node: Node, parent) {
if (!hoistable) return this.skip();
if (map.has(node)) {
@ -1112,7 +1112,7 @@ export default class Component {
}
},
leave(node) {
leave(node: Node) {
if (map.has(node)) {
scope = scope.parent;
}
@ -1155,7 +1155,7 @@ export default class Component {
const map = this.instance_scope_map;
walk(node.body, {
enter(node, parent) {
enter(node: Node, parent) {
if (map.has(node)) {
scope = map.get(node);
}
@ -1195,7 +1195,7 @@ export default class Component {
}
},
leave(node) {
leave(node: Node) {
if (map.has(node)) {
scope = scope.parent;
}

@ -1,7 +1,7 @@
import Node from './shared/Node';
import Component from '../Component';
import { walk } from 'estree-walker';
import { Identifier } from 'estree';
import { BasePattern, Identifier } from 'estree';
const applicable = new Set(['Identifier', 'ObjectExpression', 'ArrayExpression', 'Property']);
@ -22,7 +22,7 @@ export default class Let extends Node {
this.value = info.expression;
walk(info.expression, {
enter(node) {
enter(node: Identifier|BasePattern) {
if (!applicable.has(node.type)) {
component.error(node as any, {
code: 'invalid-let',
@ -31,16 +31,16 @@ export default class Let extends Node {
}
if (node.type === 'Identifier') {
names.push(node.name);
names.push((node as Identifier).name);
}
// slightly unfortunate hack
if (node.type === 'ArrayExpression') {
(node as any).type = 'ArrayPattern';
node.type = 'ArrayPattern';
}
if (node.type === 'ObjectExpression') {
(node as any).type = 'ObjectPattern';
node.type = 'ObjectPattern';
}
}
});

@ -143,7 +143,7 @@ export default class Expression {
}
},
leave(node) {
leave(node: Node) {
if (map.has(node)) {
scope = scope.parent;
}
@ -338,7 +338,7 @@ export default class Expression {
});
}
return (this.manipulated = node);
return (this.manipulated = node as Node);
}
}

@ -200,7 +200,7 @@ export default function dom(
let execution_context: Node | null = null;
walk(component.ast.instance.content, {
enter(node) {
enter(node: Node) {
if (map.has(node)) {
scope = map.get(node) as Scope;
@ -212,7 +212,7 @@ export default function dom(
}
},
leave(node) {
leave(node: Node) {
if (map.has(node)) {
scope = scope.parent;
}

Loading…
Cancel
Save