Skip to content

Conversation

samchon
Copy link
Owner

@samchon samchon commented Jun 22, 2025

This pull request introduces enhancements and refinements to the typia library, focusing on improving error handling, JSON schema generation, and type safety. Key changes include the addition of detailed documentation for the TypeGuardError class, corrections to metadata handling in JSON schema generation, and expanded support for OpenAPI specifications in JSON schema types.

Enhancements to Error Handling:

  • src/TypeGuardError.ts: Added comprehensive documentation for the TypeGuardError class, including detailed descriptions of its properties (method, path, expected, value) and constructor. This improves clarity on how errors are reported when type assertions fail. [1] [2]
  • src/TypeGuardError.ts: Introduced an IProps interface to define the properties required for constructing a TypeGuardError, with examples for better usability.

Improvements to JSON Schema Support:

  • src/schemas/json/IJsonSchemaCollection.ts: Enhanced the IJsonSchemaCollection type with detailed documentation, highlighting differences between OpenAPI v3.0 and v3.1, and their respective features. Added support for type safety and traceability back to TypeScript definitions. [1] [2]
  • src/schemas/json/IJsonSchemaUnit.ts: Updated the IJsonSchemaUnit type with documentation to clarify its purpose for single-schema use cases, emphasizing its lightweight structure and compatibility with OpenAPI standards.

Bug Fixes:

@samchon samchon requested a review from Copilot June 22, 2025 01:12
@samchon samchon self-assigned this Jun 22, 2025
@samchon samchon added documentation Improvements or additions to documentation enhancement New feature or request labels Jun 22, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR replaces inline code blocks in MDX docs with a RemoteSource component that fetches and compiles remote examples, updates import/style consistency, and fixes a typo in JSON schema programmer metadata handling.

  • Introduce RemoteSource React component for dynamic MDX code loading
  • Update all validator and JSON-schema docs to use remote sources
  • Correct medadataList typo to metadataList in JsonSchemasProgrammer.ts

Reviewed Changes

Copilot reviewed 8 out of 14 changed files in this pull request and generated 3 comments.

File Description
website/src/components/RemoteSource.tsx New component to fetch, compile, and render remote MDX code blocks
website/pages/docs/**/*.mdx Replace inline fences with <RemoteSource /> for each example
src/programmers/json/JsonSchemasProgrammer.ts Fix typo from medadataList to metadataList

showLineNumbers?: boolean;
highlight?: string;
}) => {
const [component, setComponent] = useState<React.ReactElement | null>(null);
Copy link
Preview

Copilot AI Jun 22, 2025

Choose a reason for hiding this comment

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

[nitpick] Instead of returning null while loading, consider rendering a fallback or loading indicator to improve UX during MDX compilation.

Copilot uses AI. Check for mistakes.

Comment on lines 13 to 38
useEffect(() => {
const func = async () => {
const content: string = [
[
`${BRACKET}typescript`,
!!props.filename?.length
? ` filename=${JSON.stringify(props.filename)}`
: "",
props.showLineNumbers ? " showLineNumbers" : "",
!!props.highlight?.length ? ` {${props.highlight}}` : "",
].join(""),
await loader.get(props.url),
BRACKET,
].join("\n");
const result = await compileMdx(content);
setComponent(
<MDXRemote
compiledSource={result.result}
frontmatter={result.frontMatter}
scope={result.structurizedData}
/>,
);
};
func().catch(console.error);
}, [props.url, props.filename, props.showLineNumbers, props.highlight]);
return component;
Copy link
Preview

Copilot AI Jun 22, 2025

Choose a reason for hiding this comment

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

[nitpick] Logging errors to console may not be visible to end users. Consider capturing and displaying compilation errors in the UI.

Suggested change
useEffect(() => {
const func = async () => {
const content: string = [
[
`${BRACKET}typescript`,
!!props.filename?.length
? ` filename=${JSON.stringify(props.filename)}`
: "",
props.showLineNumbers ? " showLineNumbers" : "",
!!props.highlight?.length ? ` {${props.highlight}}` : "",
].join(""),
await loader.get(props.url),
BRACKET,
].join("\n");
const result = await compileMdx(content);
setComponent(
<MDXRemote
compiledSource={result.result}
frontmatter={result.frontMatter}
scope={result.structurizedData}
/>,
);
};
func().catch(console.error);
}, [props.url, props.filename, props.showLineNumbers, props.highlight]);
return component;
const [error, setError] = useState<string | null>(null);
useEffect(() => {
const func = async () => {
try {
const content: string = [
[
`${BRACKET}typescript`,
!!props.filename?.length
? ` filename=${JSON.stringify(props.filename)}`
: "",
props.showLineNumbers ? " showLineNumbers" : "",
!!props.highlight?.length ? ` {${props.highlight}}` : "",
].join(""),
await loader.get(props.url),
BRACKET,
].join("\n");
const result = await compileMdx(content);
setComponent(
<MDXRemote
compiledSource={result.result}
frontmatter={result.frontMatter}
scope={result.structurizedData}
/>,
);
} catch (err) {
setError(err instanceof Error ? err.message : "An unknown error occurred.");
}
};
func();
}, [props.url, props.filename, props.showLineNumbers, props.highlight]);
return error ? <div>Error: {error}</div> : component;

Copilot uses AI. Check for mistakes.

@@ -5,7 +5,10 @@ import { Tabs } from 'nextra/components'
import Alert from '@mui/material/Alert';
import AlertTitle from '@mui/material/AlertTitle';

import { RemoteSource } from "../../../src/components/RemoteSource";
Copy link
Preview

Copilot AI Jun 22, 2025

Choose a reason for hiding this comment

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

[nitpick] Imports of RemoteSource vary between named and default across MDX files; standardize on one import style to reduce confusion.

Copilot uses AI. Check for mistakes.

Copy link

pkg-pr-new bot commented Jun 22, 2025

Open in StackBlitz

npm i https://pkg.pr.new/typia@1594

commit: 1b1aa4e

@samchon samchon merged commit 08c0c38 into master Jun 22, 2025
10 checks passed
@samchon samchon deleted the feat/remote branch June 22, 2025 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant