vue-facing-decorator
Version:
Vue typescript class and decorator based component.
57 lines (35 loc) • 1.51 kB
Markdown
# Description
In v3.0.0, v-f-d is compatible with both decorators API stage 3 and stage 2 now.
# Decorators API stage 3
To enable this, you need to update TypeScript to 5.x and set `compilerOptions.experimentalDecorators` to `false` (value `true` for stage 2).
> Currently some vue libraries(e.g. Volar) may not compatible with TypeScript 5.x.
# Breaking changes
### Cast class component to vue options API
Using `toNative` to cast a class component to vue options API, after that, the casted component could be used as a native vue component in where vue accepts it.
> Currently `toNative` is not necessary, because v-f-d use a vue internal API, but it is not stable and may missing in the future vue versions. So `toNative` is recommended.
```typescript
@Component
export class MyComp extends Vue{}
export default toNative(MyComp)
//Code also works currently:
@Component
export default class MyComp extends Vue{}
```
### Deprecate init class property despends on another in constructor
This is not allowed now.
```typescript
@Component({
name: "MyComponent"
})
export class MyComponent extends Vue {
@Prop
prop!: string
field = this.prop // this is deprecated, it will be undefined
}
export default toNative(MyComponent)
```
### Remove `index-return-cons`
Remove `vue-facing-decorator/dist/index-return-cons`, you won't need this if `toNative` exists.
# What's new
* `createDecorator` has a preserve option. see docs.
* `v-model` sets event name in emits option now.