-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(extension-system): request result data types (#1295)
- Loading branch information
1 parent
0e5918c
commit 05a9717
Showing
22 changed files
with
169 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from './Simplify.js' | ||
export * from './InferResult/__.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { UnknownOrAnyToNever } from '../lib/prelude.js' | ||
import type { Context, ContextTypeLevel } from '../types/context.js' | ||
import type { Extension } from './__.js' | ||
|
||
export type AddTypeHooksFromExtension< | ||
$Context extends Context, | ||
$Extension extends Extension, | ||
> = AddExtensionTypeHooks<$Context, $Extension['typeHooks']> | ||
|
||
export type AddExtensionTypeHooks< | ||
$Context extends Context, | ||
$ExtensionTypeHooks extends Extension.TypeHooks.TypeHooks, | ||
> = | ||
& Omit<$Context, keyof ContextTypeLevel> | ||
& { | ||
typeHookOnRequestResult: [...$Context['typeHookOnRequestResult'], ...$ExtensionTypeHooks['onRequestResult']] | ||
typeHookOnRequestDocumentRootType: $Context['typeHookOnRequestDocumentRootType'] | ||
typeHookRequestResultDataTypes: | ||
| $Context['typeHookRequestResultDataTypes'] | ||
| UnknownOrAnyToNever<$ExtensionTypeHooks['requestResultDataTypes']> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import type { AddScalar } from '../../client/properties/scalar.js' | ||
import type { Extension } from '../../extension/__.js' | ||
import { assertEqual } from '../../lib/assert-equal.js' | ||
import type { Context } from '../context.js' | ||
import type { Schema } from '../Schema/__.js' | ||
import type { _SimplifyExcept, Simplify, SimplifyWithEmptyContext } from './Simplify.js' | ||
|
||
// dprint-ignore | ||
{ | ||
type DateScalar = Schema.Scalar<'Date', Date, string> | ||
type CEmpty = Context.States.Empty | ||
type CExt = Extension.AddExtensionTypeHooks<CEmpty, { | ||
onRequestDocumentRootType: [], | ||
onRequestResult: [] | ||
requestResultDataTypes: Text, | ||
}> | ||
type CScalar = AddScalar<Context.States.Empty, DateScalar> | ||
type CExtAndScalar = AddScalar<CExt, DateScalar> | ||
|
||
type _1 = Simplify<CEmpty , {x:Date|null}> | ||
// @ts-expect-error | ||
assertEqual<_1 , {x:Date|null}>() | ||
type _2 = Simplify<CExt , {x:Text|null}> | ||
assertEqual<_2 , {x:Text|null}>() | ||
type _3 = Simplify<CScalar , {x:Date|null}> | ||
assertEqual<_3 , {x:Date|null}>() | ||
type _4 = Simplify<CExtAndScalar , {x:Date|Text|null}> | ||
assertEqual<_4 , {x:Date|Text|null}>() | ||
|
||
|
||
|
||
assertEqual<SimplifyWithEmptyContext<{x:1|null}> , {x:1|null}>() | ||
assertEqual<SimplifyWithEmptyContext<null | {x:1}> , null | {x:1}>() | ||
assertEqual<SimplifyWithEmptyContext<null | {x?:1}> , null | {x?:1}>() | ||
assertEqual<SimplifyWithEmptyContext<null | {x?:1|null}> , null | {x?:1|null}>() | ||
|
||
assertEqual<_SimplifyExcept<Date, null | Date> , null | Date>() | ||
assertEqual<_SimplifyExcept<Date, {}> , {}>() | ||
assertEqual<_SimplifyExcept<Date, { a: Date }> , { a: Date }>() | ||
assertEqual<_SimplifyExcept<Date, { a: 1 }> , { a: 1 }>() | ||
assertEqual<_SimplifyExcept<Date, { a: { b: Date } }> , { a: { b: Date } }>() | ||
assertEqual<_SimplifyExcept<Date, { a: { b: Date } }> , { a: { b: Date } }>() | ||
assertEqual<_SimplifyExcept<Date, { a: null | { b: Date } }> , { a: null | { b: Date } }>() | ||
|
||
} |
Oops, something went wrong.