You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/v2/guide/typescript.md
+7-9Lines changed: 7 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -156,38 +156,36 @@ var vm = new Vue({
156
156
})
157
157
```
158
158
159
-
## Annotating Return Types (EN)
159
+
## Annotation des types de retour
160
160
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`.
163
162
164
163
```ts
165
164
importVue, { VNode } from'vue'
166
165
167
166
const Component =Vue.extend({
168
167
data() {
169
168
return {
170
-
msg: 'Hello'
169
+
msg: 'Bonjour'
171
170
}
172
171
},
173
172
methods: {
174
-
//need annotation due to `this` in return type
173
+
//besoin d'une annotation car `this` fait parti du type de retour
175
174
greet():string {
176
175
returnthis.msg+' world'
177
176
}
178
177
},
179
178
computed: {
180
-
//need annotation
179
+
//besoin d'une annotation
181
180
greeting():string {
182
181
returnthis.greet() +'!'
183
182
}
184
183
},
185
-
// `createElement` is inferred, but `render` needs return type
184
+
// `createElement` est deviné, mais `render` à besoin d'une annotation de type de retour
186
185
render(createElement):VNode {
187
186
returncreateElement('div', this.greeting)
188
187
}
189
188
})
190
189
```
191
190
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