Giter Site home page Giter Site logo

template about av-ts HOT 12 CLOSED

herringtondarkholme avatar herringtondarkholme commented on May 21, 2024
template

from av-ts.

Comments (12)

HerringtonDarkholme avatar HerringtonDarkholme commented on May 21, 2024 1

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.

HerringtonDarkholme avatar HerringtonDarkholme commented on May 21, 2024

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.

mvujica avatar mvujica commented on May 21, 2024

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.

mvujica avatar mvujica commented on May 21, 2024

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.

HerringtonDarkholme avatar HerringtonDarkholme commented on May 21, 2024

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.

HerringtonDarkholme avatar HerringtonDarkholme commented on May 21, 2024

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.

mvujica avatar mvujica commented on May 21, 2024

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.

HerringtonDarkholme avatar HerringtonDarkholme commented on May 21, 2024

No, you cannot use props in Component. It will be overwritten by @props decorators.

from av-ts.

mvujica avatar mvujica commented on May 21, 2024

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.

HerringtonDarkholme avatar HerringtonDarkholme commented on May 21, 2024

Fine. And you can also try it in your browser for now http://plnkr.co/edit/KHhs7KDye3kwUvM8SNyZ?p=preview

from av-ts.

mvujica avatar mvujica commented on May 21, 2024

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.

mvujica avatar mvujica commented on May 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.