Skip to content
This repository has been archived by the owner on Feb 23, 2022. It is now read-only.

Commit

Permalink
Adapted to work with new Vue.js and TypeScript versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan Wagner committed Apr 16, 2018
1 parent 71ba3b4 commit b478814
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 31 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/ignore/

# build directory
/build/

# Created by https://www.gitignore.io/api/macos,windows,linux,visualstudiocode,webstorm,sublimetext,node,git

### macOS ###
Expand Down Expand Up @@ -198,6 +201,6 @@ jspm_packages
# Optional REPL history
.node_repl_history


### Git ###
*.orig

17 changes: 4 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
# vue-typescript-import-dts [![Build Status](https://travis-ci.org/locoslab/vue-typescript-import-dts.svg?branch=master)](https://travis-ci.org/locoslab/vue-typescript-import-dts) [![npm version](https://badge.fury.io/js/vue-typescript-import-dts.svg)](https://badge.fury.io/js/vue-typescript-import-dts)
TypeScript declaration file that allows using `import` with `*.vue` files. The primary use case is a bundler environment like [Browserify](http://browserify.org/) with [vueify](https://github.com/vuejs/vueify). The file itself consists of 5 lines; this package is just for convenience.

## CommonJS vs. ES6 modules
There are two current versions: version 2.x for a CommonJS environment, e.g., Browserify/vueify and version 3.x for an ES6 environment that uses `export default`.
TypeScript declaration file that allows using `import` with `*.vue` files. The primary use case is a bundler environment like [webpack](https://webpack.js.org/). The file itself consists of 4 lines; this package is just for convenience.

## Usage
This package requires TypeScript 2 and Vue.js 2, which ships with new type definitions in the Vue.js package itself. Both must be installed separately in your project, which allows choosing a suitable version.

1. Install
* For ES6 modules: `npm install vue-typescript-import-dts --save-dev`
* For CommonJS: `npm install vue-typescript-import-dts@2 --save-dev`
* `npm install vue-typescript-import-dts --save-dev`

2. Import (one of):
* Import this module before the import of a `.vue` file: `import 'vue-typescript-import-dts'`
Expand All @@ -24,19 +20,14 @@ This package requires TypeScript 2 and Vue.js 2, which ships with new type defin
Then, it is possible to `import` a `*.vue` file:
* For ES6 modules: `import Child from './child.vue'`
* For CommonJS, one of:
- `import Child = require('./child.vue')`
- `import * as Child from './child.vue'`
* `import Child from './child.vue'`
Note: TypeScript will not type check, parse, or even verify the existence of the `.vue` file: this project only instructs the TypeScript compiler to assume the import of 'something' that ends with `.vue` succeeds and is a `Vue.ComponentOptions<Vue>` object.
Note: TypeScript will not type check, parse, or even verify the existence of the `.vue` file: this project only instructs the TypeScript compiler to assume the import of 'something' that ends with `.vue` succeeds and is a `Vue` object.
## Shameless Plug
If you are using TypeScript 2 together with Vue.js 2, you might also be interested in
* [vue-typescript-component](https://github.com/locoslab/vue-typescript-component) to use TypeScript classes as Vue.js components
* [vue-typescript-jest](https://github.com/locoslab/vue-typescript-jest) to test Vue.js components and TypeScript sources using Jest
* [vue-jest-utils](https://github.com/locoslab/vue-jest-utils) to simplify snapshot testing of Vue.js components using Jest and html2jade
* [vue-typescript-component-example](https://github.com/locoslab/vue-typescript-component-example) as an example for this package and the projects above that shows a TypeScript/Tsify/Vue.js/Vueify/Pug setup supporting Hot Module Replacement and unit/snapshot testing with Jest
## License
[MIT](http://opensource.org/licenses/MIT)
5 changes: 2 additions & 3 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
declare module '*.vue' {
import Vue = require('vue')
const value: Vue.ComponentOptions<Vue>
export default value
import Vue from 'vue'
export default Vue
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"prepublish": "tsc"
},
"devDependencies": {
"vue": "^2.0.0",
"typescript": "^2.0.3"
"vue": "^2.5.16",
"typescript": "^2.8.1"
}
}
2 changes: 1 addition & 1 deletion test/it-compiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
import Child from './child.vue'

// access something to generate code
const d1 = Child.methods
const d1 = Child.component
21 changes: 10 additions & 11 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"noImplicitAny": true,
"strictNullChecks": true,
"sourceMap": false,
"pretty": true,
"outDir": "ignore",
"lib": ["es5", "dom", "es2015.promise"]
"lib": ["dom", "es5", "es2015"],
"target": "es2015",
"module": "es6",
"moduleResolution": "node",
"sourceMap": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"allowJs": true,
"outDir": "build"
},
"exclude": [
"node_modules"
],
"exclude": ["node_modules", "build"],
"atom": {
"rewriteTsconfig": false
},
Expand Down

0 comments on commit b478814

Please sign in to comment.