From #1822 (comment):
"ava": {
"compileEnhancements": false,
"extensions": [
"ts"
],
"require": [
"ts-node/register",
"tsconfig-paths/register"
]
},
Because of how ts is specified, AVA won't apply its Babel pipeline to it. However, note that the babel option is not disabled.
The logic in these lines is broken:
const {projectDir, babelConfig} = this.options;
const compileEnhancements = this.options.compileEnhancements !== false;
const precompileFull = babelConfig ?
babelPipeline.build(projectDir, cacheDir, babelConfig, compileEnhancements) :
filename => {
throw new Error(`Cannot apply full precompilation, possible bad usage: ${filename}`);
};
const precompileEnhancementsOnly = compileEnhancements && this.options.extensions.enhancementsOnly.length > 0 ?
babelPipeline.build(projectDir, cacheDir, null, compileEnhancements) :
filename => {
throw new Error(`Cannot apply enhancement-only precompilation, possible bad usage: ${filename}`);
};
this._precompiler = {
cacheDir,
enabled: babelConfig || compileEnhancements,
precompileEnhancementsOnly,
precompileFull
};
Note how this._precompiler.enabled ends up being true. However precompileEnhancementsOnly is set to a function that always throws. Consequently, when compiling TypeScript files, precompileEnhancementsOnly is called and AVA crashes.
I think the logic should be such that a () => null function is when compileEnhancements is false, and the error-throwing function is used when it's not and this.options.extensions.enhancementsOnly.length is 0.
From #1822 (comment):
Because of how
tsis specified, AVA won't apply its Babel pipeline to it. However, note that thebabeloption is not disabled.The logic in these lines is broken:
Note how
this._precompiler.enabledends up beingtrue. HoweverprecompileEnhancementsOnlyis set to a function that always throws. Consequently, when compiling TypeScript files,precompileEnhancementsOnlyis called and AVA crashes.I think the logic should be such that a
() => nullfunction is whencompileEnhancementsisfalse, and the error-throwing function is used when it's not andthis.options.extensions.enhancementsOnly.lengthis0.