Merge pull request #2881 from sveltejs/gh-2878

dont create unknown prop warnings for $$scope etc, or if component has $$props
pull/2882/head
Rich Harris 5 years ago committed by GitHub
commit bb153681b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -397,11 +397,11 @@ export default function dom(
});
let unknown_props_check;
if (component.compile_options.dev && writable_props.length) {
if (component.compile_options.dev && !component.var_lookup.has('$$props') && writable_props.length) {
unknown_props_check = deindent`
const writable_props = [${writable_props.map(prop => `'${prop.export_name}'`).join(', ')}];
Object.keys($$props).forEach(key => {
if (!writable_props.includes(key)) console.warn(\`<${component.tag}> was created with unknown prop '\${key}'\`);
if (!writable_props.includes(key) && !key.startsWith('$$')) console.warn(\`<${component.tag}> was created with unknown prop '\${key}'\`);
});
`;
}

@ -67,7 +67,7 @@ function instance($$self, $$props, $$invalidate) {
const writable_props = ['name'];
Object.keys($$props).forEach(key => {
if (!writable_props.includes(key)) console.warn(`<Component> was created with unknown prop '${key}'`);
if (!writable_props.includes(key) && !key.startsWith('$$')) console.warn(`<Component> was created with unknown prop '${key}'`);
});
$$self.$set = $$props => {

@ -153,7 +153,7 @@ function instance($$self, $$props, $$invalidate) {
const writable_props = ['things', 'foo', 'bar', 'baz'];
Object.keys($$props).forEach(key => {
if (!writable_props.includes(key)) console.warn(`<Component> was created with unknown prop '${key}'`);
if (!writable_props.includes(key) && !key.startsWith('$$')) console.warn(`<Component> was created with unknown prop '${key}'`);
});
$$self.$set = $$props => {

@ -153,7 +153,7 @@ function instance($$self, $$props, $$invalidate) {
const writable_props = ['things', 'foo'];
Object.keys($$props).forEach(key => {
if (!writable_props.includes(key)) console.warn(`<Component> was created with unknown prop '${key}'`);
if (!writable_props.includes(key) && !key.startsWith('$$')) console.warn(`<Component> was created with unknown prop '${key}'`);
});
$$self.$set = $$props => {

@ -67,7 +67,7 @@ function instance($$self, $$props, $$invalidate) {
const writable_props = ['foo'];
Object.keys($$props).forEach(key => {
if (!writable_props.includes(key)) console.warn(`<Component> was created with unknown prop '${key}'`);
if (!writable_props.includes(key) && !key.startsWith('$$')) console.warn(`<Component> was created with unknown prop '${key}'`);
});
$$self.$set = $$props => {

@ -0,0 +1,7 @@
<script>
export let foo = undefined;
</script>
<div>{foo}</div>
<div>{JSON.stringify($$props)}</div>

@ -0,0 +1,7 @@
export default {
compileOptions: {
dev: true
},
warnings: []
};

@ -0,0 +1,5 @@
<script>
import Foo from './Foo.svelte';
</script>
<Foo fo="sho"/>

@ -0,0 +1,6 @@
<script>
export let answer;
</script>
<h1>{answer}</h1>
<div><slot></slot></div>

@ -0,0 +1,7 @@
export default {
compileOptions: {
dev: true
},
warnings: []
};

@ -0,0 +1,7 @@
<script>
import Foo from './Foo.svelte';
</script>
<Foo answer={42}>
bar
</Foo>
Loading…
Cancel
Save