Comments (12)
Under consideration. If you prefer string template, it means your code needs extra overhead of client side compilation and size bloat. But I believe that user experience should overweight developer experience.
I don't want to promote this by default. Developer must enable it explicitly. So comes the module augmentation.
For now You can use the code above. Putting it in the entry file should apply to the whole project.
from av-ts.
Hi, I recommend you to use vue's Single File Component. This can be done by https://github.com/HerringtonDarkholme/vue-ts-loader
If you still need template string in ComponentMeta, try this.
declare module 'av-ts/dist/src/interface' {
export interface ComponentMeta {
template?: string
}
}
@Component({
template: '<div>'
})
class V extends Vue {}
This is module augmentation that makes Component
accept template field
from av-ts.
Thanks for update, well, I'm using Visual Studio 2015 and I really love code completion and syntax checking for typescript I really don't want to lose that and by using string template I still have single file component without transpiling.
Could you commit this to main code? I think It's nice feature.
from av-ts.
Ok I understand your point, but since it is enabled by default in plain js vue and sometimes preferred in original vue documentation (see use of camelCase names) I think It should be promoted to typescript decorators also. Again many thanks for help, now that I can use string template, I will test your library in my project.
from av-ts.
Yes, your point is also right. Even Vue's official documentation recommends standalone version for most users. Introducing a new type is a learning obstacle. Also having both ComponentMeta and ComponentOption will require users to augment modules twice.
Thanks for trying av-ts. Looking forward to your feedback.
from av-ts.
Hi, I'm considering just pass Vue's option object to Component
. You can try 2199aaa this commit. template
can be directly used.
from av-ts.
Is that like in "official" vue-class-component implementation? Than I can use props in Component also, is there a possibility of conflict with @props decorator?
from av-ts.
No, you cannot use props in Component. It will be overwritten by @props decorators.
from av-ts.
Ok, that is fine and many thanks for your time and work. I can't wait to test it later. Should I close the issue?
from av-ts.
Fine. And you can also try it in your browser for now http://plnkr.co/edit/KHhs7KDye3kwUvM8SNyZ?p=preview
from av-ts.
I'm in process of rewriting my vue 1.0 components as vue 2.0 classes with av-ts and everything is fine.
For future reference:
is this correct syntax for watching props?
@Watch(function (value) { // update logic }) @Prop value = p(String);
In my setup it's working fine!
from av-ts.
Also one small thing for using props: compiler complains if p is not imported so it should be:
import { Component, Prop, p, Watch, Lifecycle, Vue } from "av-ts";
from av-ts.
Related Issues (20)
- Static class properties are undefined HOT 2
- howto no data props - question HOT 4
- Lifecycle methods give error TS1241 HOT 3
- @Component decorator requires `template` key HOT 3
- Compiler error watching nested optional value HOT 2
- p({type: String}) doesn't work as expected HOT 1
- Try to improve `p` definition. HOT 1
- Some webpack related issue started from v0.8.0 HOT 2
- Failing unit tests on PhantomJS since av-ts 0.8.x HOT 5
- TypeError: 'caller' and 'arguments' are restricted function properties and cannot be accessed in this context. HOT 2
- @Lifecycle problem HOT 1
- Mixin type definition seems broken in ts 2.4 HOT 5
- Anything has to do to work with Vue 2.5? HOT 2
- @Data throws TS2345 about "Dict" when "strict: true" HOT 3
- Support `next(false)` in `beforeRouteEnter`
- how to write mapState function in vuex?? HOT 3
- TS3.0 introduced generic rest parameters HOT 3
- @Watch('value') warning: Argument type 'value' is not assignable to [string,string,string,string] HOT 1
- Is project alive? HOT 1
- Props throw `TypeError: Cannot redefine property: xxx` (with workaround) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from av-ts.