Skip to content

Typescript Clean Build#18

Open
Sayeem2004 wants to merge 12 commits intomainfrom
typescript-issues
Open

Typescript Clean Build#18
Sayeem2004 wants to merge 12 commits intomainfrom
typescript-issues

Conversation

@Sayeem2004
Copy link
Collaborator

This PR basically restructures the project to obtain a clean TS build that compiles even with "strict" TS checking. Even though there are still some "unknown" types that had to be used (because some dependencies like "bit-field" and "onml" didn't have types to import) their use is limited.

The methodology of converting 11ty to TS support is by doing a two step compilation process of (TS -> JS and JS -> 11ty).
A summary of the changes (listed in order of the file changes) is shown below:

  • In order to hide JS files from the GitHub, while also having 11ty parse them (because 11ty automatically ignores the files in .gitignore), I had to create a separate .eleventyignore file.
  • eleventy.config.js is a lot simpler now because the custom frontend TS logic is just replaced by the tsc compiler. Only things remaining now are some Passthrough Copies.
  • Added concurrently to package.json to run tsc and 11ty at the same time, added some more types packages, and had to override minimatch due to a vulnerability that 11ty hasn't fixed yet.
  • The files in _data stayed as JS, but they are super simple so its probably fine. All file imports should import the .js version of a file now.
  • layout.njk now allows for a list of custom CSS files to be added to a page, and the style.css was split into 4 to allow for better modularization in the future.
  • Since we are planning on keeping this site relatively simple, and you can customize URLs through the permalink tag in Nunjucks, I moved all our njk files into the pages folder rather than having a single folder for a single njk file.
  • To help reduce the size of individual TS files, I moved all hard coded data into hardcodedData.ts, and types into types.d.ts which doesn't need to be imported which is pretty nice. types.d.ts also declares some modules to help reduce types errors with "bit-field" and "onml" imports.
  • loadExtensions.ts, loadInstructions.ts, and search.ts all have enough type definitions to prevent tsc errors when running npm run check (alias to tsc --noEmit), but I did not type everything to reduce code clutter.

Copy link
Collaborator

@Xhether Xhether left a comment

Choose a reason for hiding this comment

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

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants