-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
TypeScript tests
We use a lot of TypeScript code at Oppia, which lets us write JavaScript code that is strongly typed. We declare the types of variables, function arguments, and function return values. Then, TypeScript checks that there aren't any type errors when it compiles our code. For example, if you have a function that expects an int, TypeScript won't let you call the function with a string.
For help writing TypeScript code, check out our guide on defining types. This page will focus on the TypeScript tests we run to make sure the types are correct.
You can run the TypeScript tests like this:
Python:
python -m scripts.run_typescript_checks --strict_checks
Docker:
make run_tests.typescript
These tests compile all ts files in the codebase and check for errors (including type errors) during compilation. The compiled files are put in the folder local_compiled_js_for_test
, which is automatically deleted after the tests finish running. Note that this folder might not be deleted if you abort the tests early.
The tests pass if, at the end of the test output, you see the message:
Compilation successful!
If the tests fail, you'll see:
Errors found during compilation
Below this message will be errors describing what went wrong. For example, consider this error:
core/templates/services/exploration-features-backend-api.service.ts(49,7): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
This means that on line 49 of exploration-features-backend-api.service.ts
, you are passing a boolean to a function that expects a string.
Have an idea for how to improve the wiki? Please help make our documentation better by following our instructions for contributing to the wiki.
Core documentation
Developing Oppia
- FAQs
- Installing Oppia
- Getting started with the codebase
- Making your first PR
- Learning resources for developers
- Codebase Overview
- Coding Guidelines
- Coding style guide
- Guidelines for creating new files
- How to add a new page
- How to write frontend type definitions
- How to write design docs
- Revert and Regression Policy
- Server errors and solutions
-
Debugging
- If your presubmit checks fail
- If CI checks fail on your PR
- Finding the commit that introduced a bug
- Interpreting GitHub Actions Results
- Debugging Docs
- Debugging datastore locally
- Debugging end-to-end tests
- Debugging backend tests
- Debugging frontend tests
- Debug frontend code
- Debugging custom ESLint check tests
- Debugging custom Pylint check tests
- Debugging Stories
- Guidelines for launching new features
- Guidelines for making an urgent fix (hotfix)
- Lint Checks
- Oppia's code owners and checks to be carried out by developers
- Privacy aware programming
- Backend Type Annotations
- Bytes and string handling in Python 3
- Guidelines for Developers with Write Access to oppia/oppia
- Testing
- Release Process
Developer Reference
- Oppiabot
- Frontend
- Backend
- Translations
- Webpack
- Third-party libraries
- Extension frameworks
- Oppia-ml Extension
- Mobile development
- Mobile device testing
- Performance testing
- Build process
- Team structure
- Triaging Process
- Playbooks
- Wiki
- Past Events