Skip to content

Commit

Permalink
Merge pull request #13 from joeistas/add-types
Browse files Browse the repository at this point in the history
Add typescript type definitions
  • Loading branch information
cristijora authored Jul 18, 2018
2 parents dd1f05a + 8451cdc commit 526da70
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 0 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
"main": "dist/vue2-transitions.cjs.js",
"module": "dist/vue2-transitions.m.js",
"unpkg": "dist/vue-transitions",
"typings": "types/index.d.ts",
"files": [
"dist",
"src"
],
"scripts": {
"prepublishOnly": "npm test && npm run build",
"test": "test-vue-app",
"test:types": "tsc -p ./types/test/tsconfig.json",
"build": "bili",
"example": "poi",
"build:example": "poi build"
Expand Down Expand Up @@ -81,6 +83,7 @@
"sass-loader": "^6.0.6",
"test-vue-app": "^1.0.0",
"typeface-lato": "^0.0.44",
"typescript": "^2.9.2",
"v-tippy": "^1.0.2",
"vue": "^2.5.13",
"vue-github-badge": "^1.0.1",
Expand Down
34 changes: 34 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import Vue, { VueConstructor, Component, PluginFunction } from 'vue'

declare const Transitions: Transitions
export default Transitions
export declare interface Transitions {
install: PluginFunction<TransitionOptions>
}

export declare interface TransitionOptions {
components?: { name: TransitionName }[]
}

export type TransitionName =
'fade-transition' |
'zoom-center-transition' |
'zoom-x-transition' |
'zoom-y-transition' |
'collapse-transition' |
'scale-transition' |
'slide-y-up-transition' |
'slide-y-down-transition' |
'slide-x-left-transition' |
'slide-x-right-transition'

export const FadeTransition: Component
export const ZoomCenterTansition: Component
export const ZoomXTransition: Component
export const ZoomYTransition: Component
export const CollapseTransition: Component
export const ScaleTransition: Component
export const SlideYUpTransition: Component
export const SlideYDownTransition: Component
export const SlideXLeftTransition: Component
export const SlideXRightTransition: Component
49 changes: 49 additions & 0 deletions types/test/index-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import Vue from 'vue'

import Transitions, {
FadeTransition,
ZoomCenterTansition,
ZoomXTransition,
ZoomYTransition,
CollapseTransition,
SlideYUpTransition,
SlideYDownTransition,
SlideXLeftTransition,
SlideXRightTransition,
TransitionOptions,
} from '../index'

// Test using Transitions plugin
Vue.use(Transitions)
Vue.use<TransitionOptions>(Transitions, {})
Vue.use<TransitionOptions>(
Transitions,
{
components: [
{ name: 'fade-transition' },
{ name: 'zoom-center-transition' },
{ name: 'zoom-x-transition' },
{ name: 'zoom-y-transition' },
{ name: 'collapse-transition' },
{ name: 'slide-y-up-transition' },
{ name: 'slide-y-down-transition' },
{ name: 'slide-x-left-transition' },
{ name: 'slide-x-right-transition' },
]
}
)

// Test component definitions
Vue.component('test-component', {
components: {
FadeTransition,
ZoomCenterTansition,
ZoomXTransition,
ZoomYTransition,
CollapseTransition,
SlideYUpTransition,
SlideYDownTransition,
SlideXLeftTransition,
SlideXRightTransition,
}
})
20 changes: 20 additions & 0 deletions types/test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"es2015"
],
"module": "commonjs",
"strict": true,
"noEmit": true,
"baseUrl": ".",
"paths": {
"vue2-transitions": ["../index.d.ts"]
}
},
"files": [
"../index.d.ts",
],
"compileOnSave": false
}
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6951,6 +6951,10 @@ typescript@^2.4.1:
version "2.6.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.6.2.tgz#3c5b6fd7f6de0914269027f03c0946758f7673a4"

typescript@^2.9.2:
version "2.9.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.9.2.tgz#1cbf61d05d6b96269244eb6a3bce4bd914e0f00c"

uglify-js@3.3.x, uglify-js@^3.0.9:
version "3.3.3"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.3.3.tgz#66f9b57f7dda913ad9f48a21b12e4e7377fdaf40"
Expand Down

0 comments on commit 526da70

Please sign in to comment.