-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Allow component fields to be declared const
(Think PropTypes in React)
#880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I wonder if this is another argument for supporting TypeScript/Flow annotations? (See #418.) We could do this sort of thing: <script language='typescript'>
interface Data {
readonly foo: string;
};
export default <Options>{
data() {
return <Data>{
foo: 'x'
};
}
};
</script> Anyway, for posterity's sake, here's the workaround mentioned in Gitter — using |
@maxamante how are things going for you on this issue? |
Hello. @arxpoetica Rich's workaround helped me figure out a solution. You can close if you need to. |
Thx |
…y more readable (sveltejs#880) * Update App.svelte made the fonts larger and heavier for improved readability of the example * Update App.svelte made the fonts larger and heavier for improved readability of the example --------- Co-authored-by: Tee Ming <[email protected]>
Recently, I've implemented a component that has a field that needs to be declared
const
. Ideally, this field would be set on create and all changes to it would be thrown away. @TehShrike expressed in Gitter the desire for functionality like PropTypes/duck-type checking. At the suggestion, I thought of 'PropAttrs', that would allow a user to declare the field's desired properties and Svelte would perform checks on create/update. Thoughts?The text was updated successfully, but these errors were encountered: