Skip to content

Commit 9e8d848

Browse files
committed
a
1 parent 6de0db5 commit 9e8d848

8 files changed

+103
-25
lines changed

docs/delare.d.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

docs/en/_sidebar.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@
2121
- [TSX render](/en/tsx/tsx-render/tsx-render.md)
2222
- [Attribute types](/en/tsx/attribute-types/attribute-types.md)
2323
- Compatibility
24-
- [reflect-metadata](/en/compatibility/reflect-metadata/reflect-metadata.md)
24+
- [reflect-metadata](/en/compatibility/reflect-metadata/reflect-metadata.md)
25+
- Next version
26+
- [Next version](/en/next-version/next-version.md)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
import { Component, Vue, toNative, Prop } from 'vue-facing-decorator'
3+
4+
@Component({
5+
name: "MyComponent"
6+
})
7+
class MyComponent extends Vue {
8+
@Prop
9+
prop!: string
10+
11+
field = this.prop // this is deprecated, it will be undefined
12+
}
13+
14+
15+
export default toNative(MyComponent)
16+
17+
export { MyComponent }
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
2+
import { Component, Vue, toNative } from 'vue-facing-decorator'
3+
4+
@Component({
5+
name: "MyComponent"
6+
})
7+
class MyComponent extends Vue {
8+
9+
}
10+
11+
/*
12+
Cast to vue options API by toNative
13+
{
14+
name:"MyComponent"
15+
}
16+
*/
17+
18+
export default toNative(MyComponent)
19+
20+
export { MyComponent }
21+
22+
/*
23+
import MyComponent from 'MyComponent.vue'
24+
25+
@Component({
26+
components:[MyComponent] // use it as a component of another component
27+
})
28+
29+
30+
//or
31+
32+
33+
import { createApp } from 'vue'
34+
import MyComponent from 'MyComponent.vue'
35+
36+
createApp(MyComponent).mount('#root') // or other places which vue want an options API component
37+
*/
38+
39+
/*
40+
import { Component, Vue, toNative } from 'vue-facing-decorator'
41+
import { MyComponent } from 'MyComponent.vue'
42+
43+
// Extends component constructor directly
44+
45+
@Component
46+
class AnotherComponent extends MyComponent {
47+
48+
}
49+
50+
*/

docs/en/next-version/next-version.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
## Next version
2+
3+
We published a preview next version that is compatible with JavaScript decorator stage 3. To migrate to preview next vewsion, you need to change your project with some break changes.
4+
5+
In 3.x, decorator `Component` is same to `ComponentBase`, and you should cast class component to vue options API manually, see Breaking changes secion.
6+
7+
## Install
8+
9+
* `npm install vue-facing-decorator@beta`
10+
11+
* Update typescript to 5.x
12+
13+
* Set `compilerOptions.experimentalDecorators` to `false`, this will enable stage 3 decorator.
14+
15+
## Breaking changes
16+
17+
### Cast class component to vue options API
18+
19+
You must use `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.
20+
21+
[](./breaking-changes-toNative.ts ':include :type=code typescript')
22+
23+
### Depreactate init class property despends on another in constructor
24+
25+
This is not allowed now.
26+
27+
[](./breaking-changes-classProperty.ts ':include :type=code typescript')
28+
29+
### Remove `index-return-cons`
30+
31+
Remove `vue-facing-decorator/dist/index-return-cons`, you won't need this if `toNative` exists.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-facing-decorator",
3-
"version": "2.1.19",
3+
"version": "3.0.0-beta.1",
44
"description": "Vue typescript class and decorator based component.",
55
"main": "dist/index.js",
66
"module": "dist/esm/index.js",

src/index-return-cons.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

test/component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
import { expect } from 'chai';
33
import 'mocha';
4-
import { Component, Base, toNative } from '../dist'
4+
import { Component, Base, toNative } from '../dist/index-return-cons'
55
import { isEmptyObject } from './utils';
66

77
@Component

0 commit comments

Comments
 (0)