Skip to content

Commit

Permalink
Remove Renamed Parse Module
Browse files Browse the repository at this point in the history
  • Loading branch information
sinclairzx81 committed Feb 6, 2025
1 parent 90acda0 commit 2adf6d6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 76 deletions.
60 changes: 0 additions & 60 deletions src/syntax/parse.ts

This file was deleted.

36 changes: 20 additions & 16 deletions src/syntax/syntax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,26 @@ import { Static } from '../parser/index'
import { Module } from './runtime'
import { Type } from './static'

// ------------------------------------------------------------------
// NoInfer
// ------------------------------------------------------------------
/** Parses a TSchema type from TypeScript syntax but does not infer schematics */
export function NoInfer<Context extends Record<PropertyKey, Types.TSchema>, Code extends string>(context: Context, code: Code, options?: Types.SchemaOptions): Types.TSchema | undefined
/** Parses a TSchema type from TypeScript syntax but does not infer schematics */
export function NoInfer<Code extends string>(code: Code, options?: Types.SchemaOptions): Types.TSchema | undefined
/** Parses a TSchema type from TypeScript syntax but does not infer schematics */
// prettier-ignore
export function NoInfer(...args: any[]): Types.TSchema | undefined {
const withContext = typeof args[0] === 'string' ? false : true
const [context, code, options] = withContext ? [args[0], args[1], args[2] || {}] : [{}, args[0], args[1] || {}]
const type = Module.Parse('Type', code, context)[0]
return Types.KindGuard.IsSchema(type)
? Types.CloneType(type, options)
: Types.Never(options)
}
// ------------------------------------------------------------------
// Syntax
// ------------------------------------------------------------------
/** Infers a TSchema type from TypeScript syntax. */
// prettier-ignore
export type TSyntax<Context extends Record<PropertyKey, Types.TSchema>, Code extends string> = (
Expand All @@ -46,21 +66,6 @@ export function Syntax<Code extends string>(code: Code, options?: Types.SchemaOp
export function Syntax(...args: any[]): never {
return NoInfer.apply(null, args as never) as never
}
/** Parses a TSchema type from TypeScript syntax but does not infer schematics */
export function NoInfer<Context extends Record<PropertyKey, Types.TSchema>, Code extends string>(context: Context, code: Code, options?: Types.SchemaOptions): Types.TSchema | undefined
/** Parses a TSchema type from TypeScript syntax but does not infer schematics */
export function NoInfer<Code extends string>(code: Code, options?: Types.SchemaOptions): Types.TSchema | undefined
/** Parses a TSchema type from TypeScript syntax but does not infer schematics */
// prettier-ignore
export function NoInfer(...args: any[]): Types.TSchema | undefined {
const withContext = typeof args[0] === 'string' ? false : true
const [context, code, options] = withContext ? [args[0], args[1], args[2] || {}] : [{}, args[0], args[1] || {}]
const type = Module.Parse('Type', code, context)[0]
return Types.KindGuard.IsSchema(type)
? Types.CloneType(type, options)
: Types.Never(options)
}

// ------------------------------------------------------------------
// Deprecated
// ------------------------------------------------------------------
Expand All @@ -81,7 +86,6 @@ export function Parse<Code extends string>(code: Code, options?: Types.SchemaOpt
export function Parse(...args: any[]): never {
return NoInfer.apply(null, args as never) as never
}

/**
* Parses a TSchema from TypeScript Syntax
* @deprecated Use NoInfer() function
Expand Down

0 comments on commit 2adf6d6

Please sign in to comment.