implicit props

pull/1864/head
Rich Harris 7 years ago
parent 4aa510d2d9
commit eeb4e3b0cb

@ -259,49 +259,14 @@ export default class Component {
this.stylesheet.warnOnUnusedSelectors(options.onwarn); this.stylesheet.warnOnUnusedSelectors(options.onwarn);
if (this.defaultExport) { if (!this.ast.js) {
const categories = { this.declarations = Array.from(this.expectedProperties);
components: 'component',
helpers: 'helper',
events: 'event definition',
transitions: 'transition',
actions: 'actions',
};
Object.keys(categories).forEach(category => { this.exports = this.declarations.map(name => ({
const definitions = this.defaultExport.declaration.properties.find(prop => prop.key.name === category); name,
if (definitions) { as: name
definitions.value.properties.forEach(prop => { }));
const { name } = prop.key;
if (!this.used[category].has(name)) {
this.warn(prop, {
code: `unused-${category.slice(0, -1)}`,
message: `The '${name}' ${categories[category]} is unused`
});
}
});
}
});
} }
this.refCallees.forEach(callee => {
const { parts } = flattenReference(callee);
const ref = parts[1];
if (this.refs.has(ref)) {
// TODO check method is valid, e.g. `audio.stop()` should be `audio.pause()`
} else {
const match = fuzzymatch(ref, Array.from(this.refs.keys()));
let message = `'refs.${ref}' does not exist`;
if (match) message += ` (did you mean 'refs.${match}'?)`;
this.error(callee, {
code: `missing-ref`,
message
});
}
});
} }
addSourcemapLocations(node: Node) { addSourcemapLocations(node: Node) {

@ -110,7 +110,7 @@ export default function dom(
builder.addBlock(deindent` builder.addBlock(deindent`
class ${name} extends @SvelteComponent { class ${name} extends @SvelteComponent {
__init(__set_inject_props, __set_inject_refs, __make_dirty) { __init(__set_inject_props, __set_inject_refs, __make_dirty) {
${component.javascript} ${component.javascript || component.exports.map(x => `let ${x.name};`)}
__set_inject_props(props => { __set_inject_props(props => {
// TODO only do this for export let|var // TODO only do this for export let|var

Loading…
Cancel
Save