# DefineEmits and DefineProps compiler macros with default values in TypeScript

> This is how we: a. use the defineEmits() and defineProps() compiler macros with Composition API's Script Setup and TypeScript b. pass default values to…

- URL: https://graffino.com/til/defineemits-and-defineprops-compiler-macros-with-default-values-in-typescript
- Author: Rares Raulea
- Channel: vue
- Published: 2022-03-14
- Updated: 2026-02-27

This is how we:

 a. use the defineEmits() and defineProps() compiler macros with Composition API's Script Setup and TypeScript

b. pass default values to our component's props

```
<script setup>
const props = withDefaults(
  defineProps<{
    message: string, 
    isActive: boolean
  }>(), 
  {
    message: 'Default message', 
    isActive: false
  }
);

const emit = defineEmits<{
  (e: "customEventName", payload?: object) : void
}>();
</script>
```
