Skip to content

Commit

Permalink
fix(types): improve typescript type definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
Demivan committed Feb 18, 2020
1 parent 1ea5b26 commit a07a8e3
Show file tree
Hide file tree
Showing 18 changed files with 5,505 additions and 92 deletions.
2 changes: 1 addition & 1 deletion examples/hello-world/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dependencies": {
"@fluent/bundle": "^0.15.0",
"@fluent/dedent": "^0.1.0",
"fluent-vue": "2.4.1",
"fluent-vue": "link:../..",
"vue-hot-reload-api": "^2.3.3"
},
"devDependencies": {
Expand Down
11 changes: 3 additions & 8 deletions examples/hello-world/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2267,14 +2267,9 @@ find-up@^3.0.0:
dependencies:
locate-path "^3.0.0"

[email protected]:
version "2.4.1"
resolved "https://registry.yarnpkg.com/fluent-vue/-/fluent-vue-2.4.1.tgz#f27401658f7cacefc3ae8cab54d292889ab132c8"
integrity sha512-XUZPZxR2peMAilN00+MjwUYpNNxNvQmghvxBXNqZuby/BYHd+IPJA/mudt+mpHW/R455LKheDi2QSoXK2wTnnQ==
dependencies:
"@fluent/sequence" "^0.4.0"
cached-iterable "^0.3.0"
tslib "^1.10.0"
"fluent-vue@link:../..":
version "0.0.0"
uid ""

for-in@^1.0.2:
version "1.0.2"
Expand Down
19 changes: 19 additions & 0 deletions examples/typescript/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "hello-world",
"version": "0.1.0",
"private": true,
"scripts": {
"start": "parcel serve public/index.html",
"build": "parcel build public/index.html"
},
"dependencies": {
"@fluent/bundle": "^0.15.0",
"@fluent/dedent": "^0.1.0",
"fluent-vue": "link:../..",
"vue-hot-reload-api": "^2.3.3"
},
"devDependencies": {
"@vue/component-compiler-utils": "^3.0.0",
"parcel-bundler": "^1.12.3"
}
}
12 changes: 12 additions & 0 deletions examples/typescript/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hello world - a fluent-vue example</title>
</head>
<body>
<div id="root"></div>
<script src="../src/index.ts"></script>
</body>
</html>
47 changes: 47 additions & 0 deletions examples/typescript/src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<template>
<div>
<h3>Examples</h3>

<h4>$t method</h4>
<div>
<span>
{{ $t('greeting', { name: 'World' }) }}
</span>
</div>

<h4>$ta method</h4>
<div>
<span v-bind="$ta('greeting')">{{ $t('greeting', { name: 'World' }) }}</span>
</div>

<h4>Directive</h4>
<div>
<span v-t:greeting="{ name: 'World' }"></span>
</div>

<h4>Component</h4>
<div>
<i18n path="greeting" tag="div">
<template #name>
<b>{{ $t('user-name') }}</b>
</template>
</i18n>
</div>
</div>
</template>

<script lang="ts">
import Vue from 'vue'
export default Vue.extend({
name: 'typescript',
computed: {
t () {
return this.$t('user-name')
},
ta () {
return this.$ta('greeting')
}
}
})
</script>
28 changes: 28 additions & 0 deletions examples/typescript/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import Vue from 'vue';
import { FluentBundle, FluentResource } from '@fluent/bundle';
import ftl from '@fluent/dedent';
import FluentVue from 'fluent-vue';

import App from './App.vue';

Vue.use(FluentVue)

const bundle = new FluentBundle('en')

bundle.addResource(new FluentResource('user-name = World'))
bundle.addResource(new FluentResource('aria-key = Aria value'))
bundle.addResource(new FluentResource(
ftl`
greeting = Hello, {$name}
.aria-label = Label value
`))

const fluent = new FluentVue({
bundles: [bundle]
})

new Vue({
el: "#root",
fluent,
render: h => h(App)
})
3 changes: 3 additions & 0 deletions examples/typescript/src/vue-shims.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
declare module '*.vue' {
export default Vue
}
18 changes: 18 additions & 0 deletions examples/typescript/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"target": "es5",
"strict": true,
"module": "es2015",
"moduleResolution": "node"
},
"include": [
"src/**/*.ts",
"src/**/*.vue"
],
"files": [
"src/vue-shims.d.ts"
],
"exclude": [
"node_modules"
]
}
Loading

0 comments on commit a07a8e3

Please sign in to comment.