mirror of https://github.com/sveltejs/svelte
feat: better error for `bind:this` legacy API usage (#11498)
parent
85d680582b
commit
dca8861c5a
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
feat: better error for `bind:this` legacy API usage
|
@ -0,0 +1,20 @@
|
||||
import * as e from '../errors.js';
|
||||
import { current_component_context } from '../runtime.js';
|
||||
import { get_component } from './ownership.js';
|
||||
|
||||
export function legacy_api() {
|
||||
const component = current_component_context?.function;
|
||||
|
||||
/** @param {string} method */
|
||||
function error(method) {
|
||||
// @ts-expect-error
|
||||
const parent = get_component()?.filename ?? 'Something';
|
||||
e.component_api_changed(parent, method, component.filename);
|
||||
}
|
||||
|
||||
return {
|
||||
$destroy: () => error('$destroy()'),
|
||||
$on: () => error('$on(...)'),
|
||||
$set: () => error('$set(...)')
|
||||
};
|
||||
}
|
Loading…
Reference in new issue