Tram-One / tram-one

🚋 Legacy View Framework For Vanilla Javascript
http://tram-one.io/
MIT License
36 stars 8 forks source link

Type Updates - Tram One Generics v12.0.3 #194

Closed JRJurman closed 2 years ago

JRJurman commented 2 years ago

Summary

Update Tram-One types to use generics for component definitions!

This mimics React's component prop type definitions.

Version Update: Patch

This is a patch because it fixes a previously broken workflow. While this technically could introduce typescript errors where there weren't any before, those should be considered broken.

Example

type pageHeaderProps = {
  index: number;
};

const pageHeader: TramOneComponent<pageHeaderProps> = ({ index }) => {
  const targetGroupPage = useTargetGroupPage(index);

  return html`
    <h1 class="page-header">
      <span>${targetGroupPage.title || ""}</span>
    </h1>
  `;

Checklist

JRJurman commented 2 years ago

This was merged in as 12.0.2, but is actually 12.0.3 - sorry about that!