( instance: ComponentInternalInstance, setupResult: unknown, isSSR: boolean, )
| 927 | } |
| 928 | |
| 929 | export function handleSetupResult( |
| 930 | instance: ComponentInternalInstance, |
| 931 | setupResult: unknown, |
| 932 | isSSR: boolean, |
| 933 | ): void { |
| 934 | if (isFunction(setupResult)) { |
| 935 | // setup returned an inline render function |
| 936 | if (__SSR__ && (instance.type as ComponentOptions).__ssrInlineRender) { |
| 937 | // when the function's name is `ssrRender` (compiled by SFC inline mode), |
| 938 | // set it as ssrRender instead. |
| 939 | instance.ssrRender = setupResult |
| 940 | } else { |
| 941 | instance.render = setupResult as InternalRenderFunction |
| 942 | } |
| 943 | } else if (isObject(setupResult)) { |
| 944 | if (__DEV__ && isVNode(setupResult)) { |
| 945 | warn( |
| 946 | `setup() should not return VNodes directly - ` + |
| 947 | `return a render function instead.`, |
| 948 | ) |
| 949 | } |
| 950 | // setup returned bindings. |
| 951 | // assuming a render function compiled from template is present. |
| 952 | if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) { |
| 953 | instance.devtoolsRawSetupState = setupResult |
| 954 | } |
| 955 | instance.setupState = proxyRefs(setupResult) |
| 956 | if (__DEV__) { |
| 957 | exposeSetupStateOnRenderContext(instance) |
| 958 | } |
| 959 | } else if (__DEV__ && setupResult !== undefined) { |
| 960 | warn( |
| 961 | `setup() should return an object. Received: ${ |
| 962 | setupResult === null ? 'null' : typeof setupResult |
| 963 | }`, |
| 964 | ) |
| 965 | } |
| 966 | finishComponentSetup(instance, isSSR) |
| 967 | } |
| 968 | |
| 969 | type CompileFunction = ( |
| 970 | template: string | object, |
no test coverage detected