From 6fe0e072e672a1852c0658684a9e1225a73df1cb Mon Sep 17 00:00:00 2001 From: Ben Hong Date: Sun, 22 Feb 2026 12:16:37 -0500 Subject: [PATCH] docs (#3331): clarify imported types on defineProps --- src/api/sfc-script-setup.md | 4 ++-- src/guide/typescript/composition-api.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/api/sfc-script-setup.md b/src/api/sfc-script-setup.md index c2a04391a9..3f6c6405cd 100644 --- a/src/api/sfc-script-setup.md +++ b/src/api/sfc-script-setup.md @@ -201,13 +201,13 @@ const emit = defineEmits<{ - When using type declaration, the equivalent runtime declaration is automatically generated from static analysis to remove the need for double declaration and still ensure correct runtime behavior. - - In dev mode, the compiler will try to infer corresponding runtime validation from the types. For example here `foo: String` is inferred from the `foo: string` type. If the type is a reference to an imported type, the inferred result will be `foo: null` (equal to `any` type) since the compiler does not have information of external files. + - In dev mode, the compiler will try to infer corresponding runtime validation from the types. For example here `foo: String` is inferred from the `foo: string` type. Imported types are also resolved, provided TypeScript is installed as a peer dependency. - In prod mode, the compiler will generate the array format declaration to reduce bundle size (the props here will be compiled into `['foo', 'bar']`) - In version 3.2 and below, the generic type parameter for `defineProps()` were limited to a type literal or a reference to a local interface. - This limitation has been resolved in 3.3. The latest version of Vue supports referencing imported and a limited set of complex types in the type parameter position. However, because the type to runtime conversion is still AST-based, some complex types that require actual type analysis, e.g. conditional types, are not supported. You can use conditional types for the type of a single prop, but not the entire props object. + This limitation was resolved in 3.3. The latest version of Vue supports referencing imported and a limited set of complex types in the type parameter position. However, because the type to runtime conversion is still AST-based, some complex types that require actual type analysis, e.g. conditional types, are not supported. You can use conditional types for the type of a single prop, but not the entire props object. ### Reactive Props Destructure {#reactive-props-destructure} diff --git a/src/guide/typescript/composition-api.md b/src/guide/typescript/composition-api.md index 96b3de015a..4b2d15431a 100644 --- a/src/guide/typescript/composition-api.md +++ b/src/guide/typescript/composition-api.md @@ -54,7 +54,7 @@ const props = defineProps() ``` -This also works if `Props` is imported from an external source. This feature requires TypeScript to be a peer dependency of Vue. +This also works if `Props` is imported from another file such as a relative import, a path alias (e.g,. `@/types`), or an external dependency (e.g., `node_modules`). This feature requires TypeScript to be a peer dependency of Vue. ```vue