Giter Club home page Giter Club logo

typescript's Introduction

@ava/typescript

Adds rudimentary TypeScript support to AVA.

This is designed to work for projects that precompile their TypeScript code, including tests. It allows AVA to load the resulting JavaScript, while configuring AVA to use the TypeScript paths.

In other words, say you have a test file at src/test.ts. You've configured TypeScript to output to build/. Using @ava/typescript you can run the build/test.js file using npx ava src/test.ts. AVA won't pick up any of the JavaScript files present in the build/ directory, unless they have a TypeScript counterpart in src/.

Enabling TypeScript support

Add this package to your project:

npm install --save-dev @ava/typescript

Then, enable TypeScript support either in package.json or ava.config.*:

package.json:

{
	"ava": {
		"typescript": {
			"rewritePaths": {
				"src/": "build/"
			}
		}
	}
}

Both keys and values of the rewritePaths object must end with a /. Paths are relative to your project directory.

Output files are expected to have the .js extension.

AVA searches your entire project for *.js, *.cjs, *.mjs and *.ts files (or other extensions you've configured). It will ignore such files found in the rewritePaths targets (e.g. build/). If you use more specific paths, for instance build/main/, you may need to change AVA's files configuration to ignore other directories.

Add additional extensions

You can configure AVA to recognize additional file extensions. To add (partial†) JSX support:

package.json:

{
	"ava": {
		"typescript": {
			"extensions": [
				"ts",
				"tsx"
			],
			"rewritePaths": {
				"src/": "build/"
			}
		}
	}
}

See also AVA's extensions option.

† Note that the preserve mode for JSX is not (yet) supported.

typescript's People

Contributors

novemberborn avatar adam-lynch avatar conaclos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.