diff --git a/packages/decorators/.npmignore b/packages/decorators/.npmignore deleted file mode 100644 index bb5c8a54..00000000 --- a/packages/decorators/.npmignore +++ /dev/null @@ -1,3 +0,0 @@ -__tests__/ -__mocks__/ -dist/packages \ No newline at end of file diff --git a/packages/decorators/README.md b/packages/decorators/README.md deleted file mode 100644 index d06feabb..00000000 --- a/packages/decorators/README.md +++ /dev/null @@ -1 +0,0 @@ -# @vue/decorators \ No newline at end of file diff --git a/packages/decorators/__tests__/prop.spec.ts b/packages/decorators/__tests__/prop.spec.ts deleted file mode 100644 index 0bcfc806..00000000 --- a/packages/decorators/__tests__/prop.spec.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { prop } from '../src/prop' -import { Component, createInstance } from '@vue/runtime-test' - -test('without options', () => { - let capturedThisValue - let capturedPropsValue - - class Foo extends Component<{ p: number }> { - @prop - p: number - - created() { - capturedThisValue = this.p - capturedPropsValue = this.$props.p - } - } - - createInstance(Foo, { - p: 1 - }) - expect(capturedThisValue).toBe(1) - expect(capturedPropsValue).toBe(1) - - // explicit override - createInstance(Foo, { - p: 2 - }) - expect(capturedThisValue).toBe(2) - expect(capturedPropsValue).toBe(2) -}) - -test('with options', () => { - let capturedThisValue - let capturedPropsValue - let capturedDataValue - - class Foo extends Component<{ p: number }> { - @prop({ - default: 1 - }) - p: number - // data property should be able to make use of prop - d: number = this.p + 1 - - created() { - capturedThisValue = this.p - capturedPropsValue = this.$props.p - capturedDataValue = this.d - } - } - - // default value - createInstance(Foo) - expect(capturedThisValue).toBe(1) - expect(capturedPropsValue).toBe(1) - expect(capturedDataValue).toBe(2) - - // explicit override - createInstance(Foo, { - p: 2 - }) - expect(capturedThisValue).toBe(2) - expect(capturedPropsValue).toBe(2) - expect(capturedDataValue).toBe(3) -}) diff --git a/packages/decorators/index.js b/packages/decorators/index.js deleted file mode 100644 index 6817e443..00000000 --- a/packages/decorators/index.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict' - -if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/decorators.cjs.prod.js') -} else { - module.exports = require('./dist/decorators.cjs.js') -} diff --git a/packages/decorators/package.json b/packages/decorators/package.json deleted file mode 100644 index e88e438a..00000000 --- a/packages/decorators/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "@vue/decorators", - "version": "3.0.0-alpha.1", - "description": "@vue/decorators", - "main": "index.js", - "module": "dist/decorators.esm-bundler.js", - "types": "dist/index.d.ts", - "repository": { - "type": "git", - "url": "git+https://github.com/vuejs/vue.git" - }, - "keywords": [ - "vue" - ], - "author": "Evan You", - "license": "MIT", - "bugs": { - "url": "https://github.com/vuejs/vue/issues" - }, - "homepage": "https://github.com/vuejs/vue/tree/dev/packages/decorators#readme" -} \ No newline at end of file diff --git a/packages/decorators/src/index.ts b/packages/decorators/src/index.ts deleted file mode 100644 index 969bdd1d..00000000 --- a/packages/decorators/src/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { prop } from './prop' -export { inject } from './inject' diff --git a/packages/decorators/src/inject.ts b/packages/decorators/src/inject.ts deleted file mode 100644 index daaf965b..00000000 --- a/packages/decorators/src/inject.ts +++ /dev/null @@ -1 +0,0 @@ -export function inject() {} diff --git a/packages/decorators/src/prop.ts b/packages/decorators/src/prop.ts deleted file mode 100644 index 5b310937..00000000 --- a/packages/decorators/src/prop.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { Component, PropValidator } from '@vue/runtime-core' -import { camelize } from '@vue/shared' - -export function prop( - target: Component | PropValidator, - key?: string -): any { - if (key) { - applyProp(target, key) - } else { - const options = target as PropValidator - return (target: any, key: string) => { - applyProp(target, key, options) - } - } -} - -function applyProp(target: any, key: string, options: PropValidator = {}) { - // here `target` is the prototype of the component class - Object.defineProperty(target, `__prop_${camelize(key)}`, { - value: options - }) -}