Skip to content

Commit

Permalink
Convert default value tests to typescript (#5104)
Browse files Browse the repository at this point in the history
  • Loading branch information
timleslie authored Mar 14, 2021
1 parent 70a4042 commit b84abeb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/modern-peaches-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystone-next/types': patch
---

Fixed type of `defaultValue` for fields.
3 changes: 2 additions & 1 deletion packages-next/types/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import type { KeystoneContext, SessionContext } from './context';

/* TODO: Review these types */
type FieldDefaultValueArgs<T> = { context: KeystoneContext; originalInput?: T };

export type FieldDefaultValue<T> =
| T
| null
| MaybePromise<(args: FieldDefaultValueArgs<T>) => T | null | undefined>;
| ((args: FieldDefaultValueArgs<T>) => MaybePromise<T | null | undefined>);

export type CreateContext = (args: {
sessionContext?: SessionContext<any>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
const { createItem } = require('@keystone-next/server-side-graphql-client-legacy');
const { text } = require('@keystone-next/fields');
const { createSchema, list } = require('@keystone-next/keystone/schema');
const { multiAdapterRunners, setupFromConfig } = require('@keystone-next/test-utils-legacy');
import { AdapterName, testConfig } from '@keystone-next/test-utils-legacy';
// @ts-ignore
import { createItem } from '@keystone-next/server-side-graphql-client-legacy';
import { text } from '@keystone-next/fields';
import { createSchema, list } from '@keystone-next/keystone/schema';
import { multiAdapterRunners, setupFromConfig } from '@keystone-next/test-utils-legacy';
import type { BaseFields } from '@keystone-next/types';

const setupList = (adapterName, fields) => () =>
const setupList = (adapterName: AdapterName, fields: BaseFields<any>) => () =>
setupFromConfig({
adapterName,
config: createSchema({
lists: {
config: testConfig({
lists: createSchema({
User: list({ fields }),
},
}),
}),
});

Expand Down

1 comment on commit b84abeb

@vercel
Copy link

@vercel vercel bot commented on b84abeb Mar 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.