Skip to content
This repository was archived by the owner on Jan 18, 2022. It is now read-only.

chore: add typescript example #357

Merged
merged 2 commits into from
Oct 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions examples/typescript/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "typescript",
"version": "0.0.0",
"private": true,
"scripts": {
"build": "rollup -c"
},
"dependencies": {
"vue": "^3.0.0-beta.14",
"rollup": "^2.10.9",
"rollup-plugin-typescript2": "^0.27.1",
"typescript": "^3.9.3",
"rollup-plugin-vue": "link:../.."
}
}
22 changes: 22 additions & 0 deletions examples/typescript/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import VuePlugin from 'rollup-plugin-vue'
import typescript from 'rollup-plugin-typescript2'
import path from 'path'

export default [
{
input: 'src/index.ts',
output: {
file: 'dist/app.js',
format: 'esm',
sourcemap: 'inline',
},
plugins: [
VuePlugin(),
typescript({
// Absolute path to import correct config in e2e tests
tsconfig: path.resolve(__dirname, 'tsconfig.json'),
}),
],
external: ['vue'],
},
]
20 changes: 20 additions & 0 deletions examples/typescript/src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<template>
Foo {{ title }}
</template>

<script lang="ts">
import { defineComponent } from 'vue'

interface ComponentData {
title: string
}

export default defineComponent({
name: 'App',
data(): ComponentData {
return {
title: 'Bar',
}
}
})
</script>
3 changes: 3 additions & 0 deletions examples/typescript/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import App from './App.vue'

export { App }
5 changes: 5 additions & 0 deletions examples/typescript/src/shims-vue.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare module '*.vue' {
import { defineComponent } from 'vue'
const Component: ReturnType<typeof defineComponent>
export default Component
}
6 changes: 6 additions & 0 deletions examples/typescript/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"compilerOptions": {
"module": "ESNext"
},
"include": ["**/*.ts", "**/*.tsx", "**/*.vue"]
}
Loading