시작
React JSX를 소진적으로 작성합니다.
.ttx는 TSX에 tt을 더한 소스 형식입니다. JSX는 그대로 보존하고 expression container 안의 tt 구문은 일반 식과 같은 진단·평가 순서 계약으로 컴파일합니다.
example.ttx
import { useState } from "react";
variant LoadState {
Ready(message: string),
Empty,
Failed(message: string),
}
export const Status = () => {
const [state] = useState<LoadState>(LoadState.Ready("Hello ttx"));
return (
<section data-state={match (state) {
Ready => "ready",
Empty => "empty",
Failed => "failed",
}}>
{match (state) {
Ready(message) => <strong>{message}</strong>,
Empty => <span>Nothing here</span>,
Failed(message) => <mark>{message}</mark>,
}}
</section>
);
};기능
- 일반 TSX는 .ttx에서도 유효하며 JSX 태그와 텍스트는 바이트 그대로 통과합니다.
- JSX 자식과 속성 expression container 안에서 tt 구문을 사용할 수 있습니다.
- concise arrow 컴포넌트의 렉시컬 범위와 JSX 평가 순서를 보존합니다.
- 상대 .ttx import는 CLI, 에디터, @openload28/unplugin-tt에서 동일하게 동작합니다.