Skip to content

Commit 004bd18

Browse files
committed
feat(sfc/types): make <script setup> helper types available globally
1 parent 4c5844a commit 004bd18

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

packages/runtime-core/src/apiSetupHelpers.ts

+19
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,25 @@ import {
1111
} from './componentProps'
1212
import { warn } from './warning'
1313

14+
/**
15+
* The following helpers are compiler macros that are only usable inside
16+
* `<script setup>`. They are essentially part of the `<script setup>` API and
17+
* will be frequently used. Although they can be explicitly imported, they can
18+
* actually be used directly inside `<script setup>` blocks. Their types are
19+
* therefore also made globally available to ensure proper type inference.
20+
*/
21+
type _defineProps = typeof defineProps
22+
type _defineEmits = typeof defineEmits
23+
type _defineExpose = typeof defineExpose
24+
type _withDefaults = typeof withDefaults
25+
26+
declare global {
27+
const defineProps: _defineProps
28+
const defineEmits: _defineEmits
29+
const defineExpose: _defineExpose
30+
const withDefaults: _withDefaults
31+
}
32+
1433
// dev only
1534
const warnRuntimeUsage = (method: string) =>
1635
warn(

0 commit comments

Comments
 (0)