@@ -149,23 +149,26 @@ Utilise la troisième personne du singulier au présent de l'indicatif pour la d
149149- Exposer les références nécessaires avec ` defineExpose() `
150150
151151#### ✅ Props & Emits - Bonnes pratiques
152+
152153``` vue
153154<!-- ✅ Correct - Types TypeScript -->
154155<script setup lang="ts">
155156// Props simples
156157const props = defineProps<{
157- show?: boolean // false par défaut, pas besoin de withDefaults
158- title?: string // undefined par défaut
159- count?: number // undefined par défaut
158+ show?: boolean // false par défaut, pas besoin de withDefaults
159+ title?: string // undefined par défaut
160+ count?: number // undefined par défaut
160161}>()
161162
162163// Emits avec types
163164const emit = defineEmits<{
164165 'update:modelValue': [value: string]
165- ' close' : []
166- ' submit' : [data: FormData]
166+ close: []
167+ submit: [data: FormData]
167168}>()
169+ ```
168170
171+ ``` vue
169172// Props avec defaults personnalisés
170173const props = withDefaults(defineProps<{
171174 size?: 'sm' | 'md' | 'lg'
@@ -181,28 +184,28 @@ const props = withDefaults(defineProps<{
181184<script setup>
182185const props = defineProps({
183186 show: { type: Boolean, default: false }, // Verbeux
184- title: { type: String }
187+ title: { type: String },
185188})
186189const emit = defineEmits(['update:show', 'close']) // Pas de typage
187190</script>
188191```
189192
190193### Structure des composables
191194``` typescript
192- export function useFeatureName() {
195+ export function useFeatureName () {
193196 const data = ref ()
194197 const isLoading = ref (false )
195198 const error = ref ()
196199
197- async function fetchData() {
200+ async function fetchData () {
198201 // logique
199202 }
200203
201204 return {
202205 data: readonly (data ),
203206 isLoading: readonly (isLoading ),
204207 error: readonly (error ),
205- fetchData
208+ fetchData ,
206209 }
207210}
208211```
0 commit comments