diff --git a/src/compile/render-dom/index.ts b/src/compile/render-dom/index.ts index 1432813e9d9d..2bf8935150d8 100644 --- a/src/compile/render-dom/index.ts +++ b/src/compile/render-dom/index.ts @@ -395,11 +395,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}'\`); }); `; } diff --git a/test/js/samples/debug-empty/expected.js b/test/js/samples/debug-empty/expected.js index c82cbeddd3d0..6f079935902e 100644 --- a/test/js/samples/debug-empty/expected.js +++ b/test/js/samples/debug-empty/expected.js @@ -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(` was created with unknown prop '${key}'`); + if (!writable_props.includes(key) && !key.startsWith('$$')) console.warn(` was created with unknown prop '${key}'`); }); $$self.$set = $$props => { diff --git a/test/js/samples/debug-foo-bar-baz-things/expected.js b/test/js/samples/debug-foo-bar-baz-things/expected.js index 3e1571b8905e..eea35d5ba7ae 100644 --- a/test/js/samples/debug-foo-bar-baz-things/expected.js +++ b/test/js/samples/debug-foo-bar-baz-things/expected.js @@ -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(` was created with unknown prop '${key}'`); + if (!writable_props.includes(key) && !key.startsWith('$$')) console.warn(` was created with unknown prop '${key}'`); }); $$self.$set = $$props => { diff --git a/test/js/samples/debug-foo/expected.js b/test/js/samples/debug-foo/expected.js index 1af0fcaebee8..5b931d94643d 100644 --- a/test/js/samples/debug-foo/expected.js +++ b/test/js/samples/debug-foo/expected.js @@ -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(` was created with unknown prop '${key}'`); + if (!writable_props.includes(key) && !key.startsWith('$$')) console.warn(` was created with unknown prop '${key}'`); }); $$self.$set = $$props => { diff --git a/test/js/samples/dev-warning-missing-data-computed/expected.js b/test/js/samples/dev-warning-missing-data-computed/expected.js index 0c193934c059..5c4b2ece1bdc 100644 --- a/test/js/samples/dev-warning-missing-data-computed/expected.js +++ b/test/js/samples/dev-warning-missing-data-computed/expected.js @@ -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(` was created with unknown prop '${key}'`); + if (!writable_props.includes(key) && !key.startsWith('$$')) console.warn(` was created with unknown prop '${key}'`); }); $$self.$set = $$props => { diff --git a/test/runtime/samples/dev-warning-unknown-props-with-$$props/Foo.svelte b/test/runtime/samples/dev-warning-unknown-props-with-$$props/Foo.svelte new file mode 100644 index 000000000000..9e5c62339d98 --- /dev/null +++ b/test/runtime/samples/dev-warning-unknown-props-with-$$props/Foo.svelte @@ -0,0 +1,7 @@ + + +
{foo}
+
{JSON.stringify($$props)}
diff --git a/test/runtime/samples/dev-warning-unknown-props-with-$$props/_config.js b/test/runtime/samples/dev-warning-unknown-props-with-$$props/_config.js new file mode 100644 index 000000000000..62ad08624d9d --- /dev/null +++ b/test/runtime/samples/dev-warning-unknown-props-with-$$props/_config.js @@ -0,0 +1,7 @@ +export default { + compileOptions: { + dev: true + }, + + warnings: [] +}; diff --git a/test/runtime/samples/dev-warning-unknown-props-with-$$props/main.svelte b/test/runtime/samples/dev-warning-unknown-props-with-$$props/main.svelte new file mode 100644 index 000000000000..1566cf3e41e7 --- /dev/null +++ b/test/runtime/samples/dev-warning-unknown-props-with-$$props/main.svelte @@ -0,0 +1,5 @@ + + + diff --git a/test/runtime/samples/dev-warning-unknown-props-with-$$scope/Foo.svelte b/test/runtime/samples/dev-warning-unknown-props-with-$$scope/Foo.svelte new file mode 100644 index 000000000000..b9f7feec24e7 --- /dev/null +++ b/test/runtime/samples/dev-warning-unknown-props-with-$$scope/Foo.svelte @@ -0,0 +1,6 @@ + + +

{answer}

+
diff --git a/test/runtime/samples/dev-warning-unknown-props-with-$$scope/_config.js b/test/runtime/samples/dev-warning-unknown-props-with-$$scope/_config.js new file mode 100644 index 000000000000..62ad08624d9d --- /dev/null +++ b/test/runtime/samples/dev-warning-unknown-props-with-$$scope/_config.js @@ -0,0 +1,7 @@ +export default { + compileOptions: { + dev: true + }, + + warnings: [] +}; diff --git a/test/runtime/samples/dev-warning-unknown-props-with-$$scope/main.svelte b/test/runtime/samples/dev-warning-unknown-props-with-$$scope/main.svelte new file mode 100644 index 000000000000..a1656e86e096 --- /dev/null +++ b/test/runtime/samples/dev-warning-unknown-props-with-$$scope/main.svelte @@ -0,0 +1,7 @@ + + + + bar +