Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Add support for native TypeScript #979

Merged
merged 6 commits into from
Feb 23, 2022
Merged

Conversation

sarayourfriend
Copy link
Contributor

Fixes

Fixes #921 by @sarayourfriend

Description

Adds support for native TypeScript by adding the following dependencies:

  • @nuxt/typescript-build -> This adds TypeScript to our build pipeline
  • @typescript-eslint/* -> These packages enable TypeScript parsing and recommended rules for ESLint
  • @babel/preset-typescript -> This adds TypeScript to the babel configuration we use for running jest

Additionally, I've had to add a .pnpmfile.cjs (documentation for that here) in order to force resolve typescript to a modern version. We need this because @nuxt/typescript-build uses an older version of TypeScript that doesn't support some of the TS features we were already using (like casting to const with JSDoc and type parameter defaults in JSDoc).

Finally, I've converted deepFreeze to be native TypeScript to prove that this works top to bottom.

Testing Instructions

Checkout the branch and run pnpm dev. Ensure the application compiles with no errors. Visit the search results page to make sure that deepFreeze is actually being run and verify that there are no errors.

Make some changes to the code that will fail TypeScript compilation. For example, in deepFreeze.ts add the following:

const n: number = '123'

Confirm that pnpm types fails and that pnpm dev spits out a compilation error.

Finally, test the ESLint integration by adding something that will fail eslint in a TypeScript file and verify that the error shows.

The jest integration is tested by the tests passing locally and in CI. Ensure they pass locally by running pnpm test and check that the CI passes them as well.

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@sarayourfriend sarayourfriend added 🟧 priority: high Stalls work on the project or its dependents 🌟 goal: addition Addition of new feature 🤖 aspect: dx Concerns developers' experience with the codebase labels Feb 21, 2022
@sarayourfriend sarayourfriend requested a review from a team as a code owner February 21, 2022 18:03
Copy link
Contributor

@obulat obulat left a comment

Choose a reason for hiding this comment

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

Some magic with pnpm configurations, and lots of ts-ignores to take care of :)
I did everything in the testing instructions, and it works.

@sarayourfriend
Copy link
Contributor Author

lots of ts-ignores to take care of

Only two! And I think they're 100% legitimate uses of ts-ignore FWIW; that deepFreeze function is very "meta-JavaScript-y" in a way that TS doesn't really like (which is fine as long as we have good unit tests to verify behavior, then the external API of the function can be accurate according to the tests and we're free to ts-ignore, in my opinion)

@obulat
Copy link
Contributor

obulat commented Feb 22, 2022

Oh, sorry for misunderstanding. I actually saw the GitHubts-ignore warning for src/components/VAudioTrack/VAudioTrack.vue, and a lot of warnings about require.

@sarayourfriend sarayourfriend enabled auto-merge (squash) February 22, 2022 15:18
@sarayourfriend sarayourfriend merged commit 4552c37 into main Feb 23, 2022
@sarayourfriend sarayourfriend deleted the add/native-ts-support branch February 23, 2022 16:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🤖 aspect: dx Concerns developers' experience with the codebase 🌟 goal: addition Addition of new feature 🟧 priority: high Stalls work on the project or its dependents
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add native TS support for non-Vue SFC files
3 participants