Skip to content

Commit

Permalink
chore(examples): add tsx example (#4855)
Browse files Browse the repository at this point in the history
  • Loading branch information
andoshin11 authored and pi0 committed Jan 29, 2019
1 parent 774823b commit 5101dc6
Show file tree
Hide file tree
Showing 11 changed files with 98 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/typescript-tsx/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# TSX example
14 changes: 14 additions & 0 deletions examples/typescript-tsx/components/HelloWorld/HelloWorld.tsx
Original file line number Diff line number Diff line change
@@ -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>
}
})
3 changes: 3 additions & 0 deletions examples/typescript-tsx/components/HelloWorld/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import HelloWorld from './HelloWorld'

export default HelloWorld
4 changes: 4 additions & 0 deletions examples/typescript-tsx/components/HelloWorld/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.title {
font-style: italic;
color: green;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const title: string;
14 changes: 14 additions & 0 deletions examples/typescript-tsx/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export default {
build: {
loaders: {
vueStyle: {
manualInject: true
},
css: {
modules: true,
importLoaders: 1,
localIdentName: '[local]_[hash:base64:5]'
}
}
}
}
22 changes: 22 additions & 0 deletions examples/typescript-tsx/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
13 changes: 13 additions & 0 deletions examples/typescript-tsx/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -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 changes: 11 additions & 0 deletions examples/typescript-tsx/shims-tsx.d.ts
Original file line number Diff line number Diff line change
@@ -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
}
}
}
8 changes: 8 additions & 0 deletions examples/typescript-tsx/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "@nuxt/typescript",
"compilerOptions": {
"baseUrl": ".",
"noImplicitThis": true,
"types": ["@types/node", "@nuxt/vue-app"]
}
}
7 changes: 7 additions & 0 deletions examples/typescript-tsx/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"defaultSeverity": "error",
"extends": ["tslint-config-standard"],
"rules": {
"prefer-const": true
}
}

0 comments on commit 5101dc6

Please sign in to comment.