Skip to content

Commit ee359c3

Browse files
Merge pull request #108 from vuejs-fr/typescript
Mise à jour de `typescript.md`
2 parents d11eaa7 + a1fe643 commit ee359c3

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/v2/guide/typescript.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -156,38 +156,36 @@ var vm = new Vue({
156156
})
157157
```
158158

159-
## Annotating Return Types (EN)
159+
## Annotation des types de retour
160160

161-
Because of the circular nature of Vue's declaration files, TypeScript may have difficulties inferring the types of certain methods.
162-
For this reason, you may need to annotate the return type on methods like `render` and those in `computed`.
161+
Du fait de la nature circulaire de la déclaration des fichiers Vue, TypeScript peut avoir des difficultés à deviner les types de certaines méthodes. Pour ces raisons, vous devriez annoter les types de retour des méthodes comme `render` et ceux dans `computed`.
163162

164163
```ts
165164
import Vue, { VNode } from 'vue'
166165

167166
const Component = Vue.extend({
168167
data() {
169168
return {
170-
msg: 'Hello'
169+
msg: 'Bonjour'
171170
}
172171
},
173172
methods: {
174-
// need annotation due to `this` in return type
173+
// besoin d'une annotation car `this` fait parti du type de retour
175174
greet(): string {
176175
return this.msg + ' world'
177176
}
178177
},
179178
computed: {
180-
// need annotation
179+
// besoin d'une annotation
181180
greeting(): string {
182181
return this.greet() + '!'
183182
}
184183
},
185-
// `createElement` is inferred, but `render` needs return type
184+
// `createElement` est deviné, mais `render` à besoin d'une annotation de type de retour
186185
render(createElement): VNode {
187186
return createElement('div', this.greeting)
188187
}
189188
})
190189
```
191190

192-
If you find type inference or member completion isn't working, annotating certain methods may help address these problems.
193-
Using the `--noImplicitAny` option will help find many of these unannotated methods.
191+
Si vous vous apercevez que l'autocomplétion ne fonctionne pas, annoter certaines méthodes peut aider à résoudre ces problèmes. Utiliser l'option `--noImplicitAny` aidera à trouver bon nombre de ces méthodes non annotées.

0 commit comments

Comments
 (0)