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

refactor(lib): add types #1164

Merged
merged 3 commits into from
Oct 26, 2023
Merged

refactor(lib): add types #1164

merged 3 commits into from
Oct 26, 2023

Conversation

NiedziolkaMichal
Copy link
Member

This PR adds strict type-checking to all files in the lib directory.

  • Plugin ESLint plugin:import/typescript was added because importing types.d.ts displayed an error.
  • %example-css-src% was removed from the JS editor, because none of the interactive examples uses it and it doesn't really make sense for this editor to have the ability to add CSS per example.
  • Fixed some typos
  • Removed {type} syntax from the docs, because it is no longer needed and in some cases stated types were incorrect.
  • Changed ${page.type} to ${page} in height-builder.ts because page.type is of the type never at this point.
  • Changed stats.hasWarnings() to stats.warnings in mdn-bob, because hasWarnings() didn't really provide type safety.
  • Function build was changed a bit. I extracted most of the behavior to fillPageTemplate so we don't repeat outputFileSync multiple times. Cases css and js were separated because js editor doesn't support jsExampleSrc or cssExampleSrc options.
  • In the getPageTmpl I have removed try/catch, so the result is never undefined. A possible error will be caught in the build function anyway.
  • Function processExampleCode was split into just processJsExample and getExampleCode, because the html case was never used. The function handleDeprecatedJSExampleFormat is actually never used too, but I will remove it in a separate PR.
  • Types from ./types/types.d.ts can now be used by YARI, so we can import height-data related interfaces.

@github-actions
Copy link
Contributor

This pull request has merge conflicts that must be resolved before it can be merged.

@github-actions
Copy link
Contributor

This pull request has merge conflicts that must be resolved before it can be merged.

@queengooborg
Copy link
Collaborator

There are some merge conflicts here, but once those are resolved I'd be happy to get this merged!

@caugner caugner changed the title refactor: Add types to lib files refactor(lib): add types Oct 26, 2023
@caugner
Copy link
Contributor

caugner commented Oct 26, 2023

I noticed an artifact on the JavaScript demos at http://localhost:4444/pages/js/array-concat.html: 🤔
image

Update: Okay, I'm actually seeing this one and %example-css-src% on main and v3.4.0. 😕

@caugner caugner merged commit 5a50ae1 into mdn:main Oct 26, 2023
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.

3 participants