chore(examples): add tsx example (#4855)

This commit is contained in:
andoshin11 2019-01-30 04:21:49 +09:00 committed by Pooya Parsa
parent 774823ba41
commit 5101dc6aae
11 changed files with 98 additions and 0 deletions

View File

@ -0,0 +1 @@
# TSX example

View File

@ -0,0 +1,14 @@
import Vue from 'vue'
import styles from './styles.css'
export default Vue.extend({
beforeCreate () {
// Render Inline CSS on SSR
if ((styles as any).__inject__) {
(styles as any).__inject__(this.$ssrContext)
}
},
render () {
return <h1 class={styles.title}>Hello world!</h1>
}
})

View File

@ -0,0 +1,3 @@
import HelloWorld from './HelloWorld'
export default HelloWorld

View File

@ -0,0 +1,4 @@
.title {
font-style: italic;
color: green;
}

View File

@ -0,0 +1 @@
export const title: string;

View File

@ -0,0 +1,14 @@
export default {
build: {
loaders: {
vueStyle: {
manualInject: true
},
css: {
modules: true,
importLoaders: 1,
localIdentName: '[local]_[hash:base64:5]'
}
}
}
}

View File

@ -0,0 +1,22 @@
{
"name": "typescript-tsx",
"private": true,
"version": "1.0.0",
"scripts": {
"dev": "nuxt-ts",
"build": "nuxt-ts build",
"start": "nuxt-ts start",
"generate": "nuxt-ts generate",
"lint": "tslint --project .",
"lint:fix": "tslint --project . --fix",
"post-update": "yarn upgrade --latest",
"watch:css": "tcm components -w"
},
"dependencies": {
"nuxt-ts": "latest"
},
"devDependencies": {
"tslint-config-standard": "^8.0.1",
"typed-css-modules": "^0.3.7"
}
}

View File

@ -0,0 +1,13 @@
import Vue from 'vue'
import HelloWorld from '../components/HelloWorld'
export default Vue.extend({
name: 'Home',
render () {
return (
<div>
<HelloWorld />
</div>
)
}
})

11
examples/typescript-tsx/shims-tsx.d.ts vendored Normal file
View File

@ -0,0 +1,11 @@
import Vue, { VNode } from 'vue'
declare global {
namespace JSX {
interface Element extends VNode {}
interface ElementClass extends Vue {}
interface IntrinsicElements {
[elem: string]: any
}
}
}

View File

@ -0,0 +1,8 @@
{
"extends": "@nuxt/typescript",
"compilerOptions": {
"baseUrl": ".",
"noImplicitThis": true,
"types": ["@types/node", "@nuxt/vue-app"]
}
}

View File

@ -0,0 +1,7 @@
{
"defaultSeverity": "error",
"extends": ["tslint-config-standard"],
"rules": {
"prefer-const": true
}
}