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

Commit ce25256

Browse files
przemkowznck
andauthored
chore: add typescript example (#357)
Co-authored-by: Rahul Kadyan <hi@znck.me>
1 parent b934ddf commit ce25256

File tree

8 files changed

+310
-0
lines changed

8 files changed

+310
-0
lines changed

examples/typescript/package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "typescript",
3+
"version": "0.0.0",
4+
"private": true,
5+
"scripts": {
6+
"build": "rollup -c"
7+
},
8+
"dependencies": {
9+
"vue": "^3.0.0-beta.14",
10+
"rollup": "^2.10.9",
11+
"rollup-plugin-typescript2": "^0.27.1",
12+
"typescript": "^3.9.3",
13+
"rollup-plugin-vue": "link:../.."
14+
}
15+
}

examples/typescript/rollup.config.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import VuePlugin from 'rollup-plugin-vue'
2+
import typescript from 'rollup-plugin-typescript2'
3+
import path from 'path'
4+
5+
export default [
6+
{
7+
input: 'src/index.ts',
8+
output: {
9+
file: 'dist/app.js',
10+
format: 'esm',
11+
sourcemap: 'inline',
12+
},
13+
plugins: [
14+
VuePlugin(),
15+
typescript({
16+
// Absolute path to import correct config in e2e tests
17+
tsconfig: path.resolve(__dirname, 'tsconfig.json'),
18+
}),
19+
],
20+
external: ['vue'],
21+
},
22+
]

examples/typescript/src/App.vue

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<template>
2+
Foo {{ title }}
3+
</template>
4+
5+
<script lang="ts">
6+
import { defineComponent } from 'vue'
7+
8+
interface ComponentData {
9+
title: string
10+
}
11+
12+
export default defineComponent({
13+
name: 'App',
14+
data(): ComponentData {
15+
return {
16+
title: 'Bar',
17+
}
18+
}
19+
})
20+
</script>

examples/typescript/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import App from './App.vue'
2+
3+
export { App }
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
declare module '*.vue' {
2+
import { defineComponent } from 'vue'
3+
const Component: ReturnType<typeof defineComponent>
4+
export default Component
5+
}

examples/typescript/tsconfig.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"compilerOptions": {
3+
"module": "ESNext"
4+
},
5+
"include": ["**/*.ts", "**/*.tsx", "**/*.vue"]
6+
}

0 commit comments

Comments
 (0)