Home / File/ define-action-accept.ts — astro Source File

define-action-accept.ts — astro Source File

Architecture documentation for define-action-accept.ts, a typescript file in the astro codebase. 4 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  c1054320_492f_5365_4b6e_d6a37f8cb893["define-action-accept.ts"]
  e6a2dc9f_6948_1e06_e648_bf517c8e5501["../../../dist/actions/runtime/server.js"]
  c1054320_492f_5365_4b6e_d6a37f8cb893 --> e6a2dc9f_6948_1e06_e648_bf517c8e5501
  c6e6d952_1368_2c1c_2f3a_ad92a305600b["../../dist/zod.js"]
  c1054320_492f_5365_4b6e_d6a37f8cb893 --> c6e6d952_1368_2c1c_2f3a_ad92a305600b
  6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"]
  c1054320_492f_5365_4b6e_d6a37f8cb893 --> 6b0635f9_51ea_77aa_767b_7857878e98a6
  687364c6_0b6b_44e7_012a_aa483da82c1b["expect-type"]
  c1054320_492f_5365_4b6e_d6a37f8cb893 --> 687364c6_0b6b_44e7_012a_aa483da82c1b
  style c1054320_492f_5365_4b6e_d6a37f8cb893 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { describe, it } from 'node:test';
import { expectTypeOf } from 'expect-type';
import { defineAction } from '../../dist/actions/runtime/server.js';
import { z } from '../../dist/zod.js';

describe('defineAction accept', () => {
	it('accepts type `any` when input is omitted with accept json', async () => {
		const action = defineAction({
			handler: () => {},
		});
		expectTypeOf(action).parameter(0).toBeAny();
		expectTypeOf(action).parameter(0).not.toEqualTypeOf<FormData>();

		const jsonAction = defineAction({
			accept: 'json',
			handler: () => {},
		});
		expectTypeOf(jsonAction).parameter(0).toBeAny();
		expectTypeOf(jsonAction).parameter(0).not.toEqualTypeOf<FormData>();
	});
	it('accepts type `FormData` when input is omitted with accept form', async () => {
		const action = defineAction({
			accept: 'form',
			handler: () => {},
		});
		expectTypeOf(action).parameter(0).toEqualTypeOf<FormData>();
	});

	it('accept type safe values for input with accept json', async () => {
		const action = defineAction({
			input: z.object({ name: z.string() }),
			handler: () => {},
		});
		expectTypeOf(action).parameter(0).toEqualTypeOf<{ name: string }>();
	});

	it('accepts type `FormData` for all inputs with accept form', async () => {
		const action = defineAction({
			accept: 'form',
			input: z.object({ name: z.string() }),
			handler: () => {},
		});
		expectTypeOf(action).parameter(0).toEqualTypeOf<FormData>();
	});
});

Dependencies

  • ../../../dist/actions/runtime/server.js
  • ../../dist/zod.js
  • expect-type
  • node:test

Frequently Asked Questions

What does define-action-accept.ts do?
define-action-accept.ts is a source file in the astro codebase, written in typescript. It belongs to the IntegrationAdapters domain.
What does define-action-accept.ts depend on?
define-action-accept.ts imports 4 module(s): ../../../dist/actions/runtime/server.js, ../../dist/zod.js, expect-type, node:test.
Where is define-action-accept.ts in the architecture?
define-action-accept.ts is located at packages/astro/test/types/define-action-accept.ts (domain: IntegrationAdapters, directory: packages/astro/test/types).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free