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

Type check test files #248

Merged
merged 15 commits into from
Apr 12, 2023
Merged

Type check test files #248

merged 15 commits into from
Apr 12, 2023

Conversation

spalladino
Copy link
Collaborator

@spalladino spalladino commented Apr 12, 2023

This PR includes test files in tsconfig, so they are type checked. Now, any type error in a test file is surfaced when building (eg when running build:dev at the project root). This makes refactors that impact test files much easier to handle, since type errors are caught by the compiler and don't need running the tests.

To avoid bundling the tests with the published packages, every package.json now has a files field that defines what gets included, and explicitly removes tests. We are including:

  • Javascript compiled files
  • Typescript type declaration files
  • Typescript original sources
  • Debug mappings

Note that the first is the only one actually required for consuming the package. The second is highly recommended to be included, so ts consumers benefit from type definitions. The last two are pretty much optional, and assist clients with debugging, but we could drop them if we think package size becomes an issue.

Adding tests to build surfaced an error with our jest types. Apparently we hit an error with jest type definitions, which is being fixed here. I added a temporary (let's see for how long it survives in the repo!) patch to the type definition to fix it.

This PR changes a lot of files, but each commit should be pretty self-contained, so I suggest reviewing by each individual commit.

Fixes #219

@spalladino spalladino force-pushed the palla/rename-tsconfig-dest branch from 88c54b9 to fe95fff Compare April 12, 2023 19:32
},
"scripts": {
"prepare": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json",
"prepare:check": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json --check",
"build": "yarn clean && tsc -b tsconfig.dest.json",
"build:dev": "tsc -b tsconfig.dest.json --watch",
"build": "yarn clean && tsc -b tsconfig.json",
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can do this in a followup PR but because tsconfig.json is the default name, we can actually drop all these -b and p flags

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Or I can change it really quick with a yarn prepare!

@spalladino spalladino marked this pull request as ready for review April 12, 2023 19:49
@spalladino spalladino requested a review from ludamad April 12, 2023 19:49
"clean": "rm -rf ./dest .tsbuildinfo",
"formatting": "run -T prettier --check ./src && run -T eslint ./src",
"formatting:fix": "run -T prettier -w ./src",
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --passWithNoTests",
"start": "node ./dest",
"start:dev": "tsc-watch -p tsconfig.dest.json --onSuccess 'yarn start'",
"start:dev": "tsc-watch -p tsconfig.json --onSuccess 'yarn start'",
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: -p tsconfig.json can also be simplified

@@ -6,20 +6,20 @@
"typedoc": {
"entryPoint": "./src/index.ts",
"displayName": "Aztec.js",
"tsconfig": "./tsconfig.dest.json"
"tsconfig": "./tsconfig.json"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Eventually if we care, also can be removed

Copy link
Collaborator

@ludamad ludamad left a comment

Choose a reason for hiding this comment

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

LGTM. Also I rather power read 72 files over 14 commits any day ^_^

@spalladino spalladino merged commit 463269c into master Apr 12, 2023
@spalladino spalladino deleted the palla/rename-tsconfig-dest branch April 12, 2023 20:11
ludamad pushed a commit that referenced this pull request Jul 14, 2023
* adding adrians new transcript classes
* tests added for transcript and new manifest concept

---------

Co-authored-by: codygunton <[email protected]>
codygunton added a commit that referenced this pull request Jan 23, 2024
* adding adrians new transcript classes
* tests added for transcript and new manifest concept

---------

Co-authored-by: codygunton <[email protected]>
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.

Include tests in tsconfig and exclude in package json
2 participants