Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Add first-party core support for TypeScript configuration, data, and template files #3616

Open
zachleat opened this issue Jan 9, 2025 · 2 comments
Labels
enhancement needs-votes A feature request on the backlog that needs upvotes or downvotes. Remove this label when resolved. typescript Type definitions and Typescript issues

Comments

@zachleat
Copy link
Member

zachleat commented Jan 9, 2025

In preparation for Node.js stable to ship TypeScript stripping as an unflagged feature https://nodejs.org/api/typescript.html

We already provide support for TypeScript via tsx, documented here: https://www.11ty.dev/docs/languages/typescript/

Default Configuration File Names

  • eleventy.config.ts
  • eleventy.config.mts
  • eleventy.config.cts

Default Data File Names

  • *.11tydata.ts
  • *.11tydata.mts
  • *.11tydata.cts

Default TypeScript Template File Names

  • *.11ty.ts
  • *.11ty.mts
  • *.11ty.cts

Dependency Tree Mapping

See https://github.com/11ty/eleventy-dependency-tree-esm and https://github.com/11ty/eleventy-dependency-tree for existing solutions.

@zachleat zachleat added enhancement typescript Type definitions and Typescript issues labels Jan 9, 2025
@zachleat zachleat changed the title Add first-party core support for TypeScript configuration, data, and template files Proposal: Add first-party core support for TypeScript configuration, data, and template files Jan 9, 2025
@zachleat
Copy link
Member Author

zachleat commented Jan 9, 2025

Some good info here too: https://2ality.com/2025/01/nodejs-strip-type.html

@zachleat zachleat added the needs-votes A feature request on the backlog that needs upvotes or downvotes. Remove this label when resolved. label Jan 9, 2025
@9999years
Copy link

Robust type signatures would be a huge boon for me — I was looking at Eleventy last week for a project that's outgrowing Zola but found the lack of type signatures very frustrating to use.

I almost wrote a big issue/proposal for this just last week, but decided against it. I'm not finding many alternatives to eleventy that look very appealing, though, so here I am :)

Robust type signatures would be a huge boon for me — I was working through pauleveritt/eleventy-tsx, but I found working with TSX for layouts really challenging. When I write a component like this:

export function MainLayout(props: any): JSX.Element {
  return (
    <html lang="en">
      <head>
        <title>{props.title}</title>
      </head>
      <body>
        <Heading name={props.title} />
        {props.content}
      </body>
    </html>
  );
}
export const render = MainLayout;

The props parameter has tons of keys which (I think?) come from the "data cascade", and because that's such a dynamic process, I have no idea what I'm "allowed" to do, which keys are available, etc.

A good example is the collections variable, which contains a lot of complex data, only some of which is documented — for example, am I supposed to be able to use collections.all[0].template.writeCount? None of the property names start with an underscore, so I assume they're all public, but I don't really feel like I can count on it.

I find reliable and rich type information really critical when I'm writing software, and was pretty sad that I couldn't leverage them here. I understand some of the data is dynamic, but some of it is guaranteed by Eleventy — I think TypeScript lets you express things like "there's a title: string property available, and other properties might be available with unknown types", and that would be really useful to have access to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement needs-votes A feature request on the backlog that needs upvotes or downvotes. Remove this label when resolved. typescript Type definitions and Typescript issues
Projects
None yet
Development

No branches or pull requests

2 participants