Closed
Description
Pulled out a more specific request from #793
Expected Behaviour
When hitting (certain) internal TS errors such as microsoft/TypeScript#24932 (TS 2.9.1) and microsoft/TypeScript#26554 (TS 3.0.1), ts-loader
attempts to get the error diagnostics which can fail with a stack like:
/Users/mehdibenadda/Development/fun-cms/node_modules/typescript/lib/typescript.js:107386
return program.getOptionsDiagnostics(cancellationToken).concat(program.getGlobalDiagnostics(cancellationToken));
^
TypeError: Cannot read property 'getOptionsDiagnostics' of undefined
at Object.getCompilerOptionsDiagnostics (/Users/mehdibenadda/Development/fun-cms/node_modules/typescript/lib/typescript.js:107386:28)
at provideCompilerOptionDiagnosticErrorsToWebpack (/Users/mehdibenadda/Development/fun-cms/node_modules/ts-loader/dist/after-compile.js:39:31)
at /Users/mehdibenadda/Development/fun-cms/node_modules/ts-loader/dist/after-compile.js:17:9
at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/mehdibenadda/Development/fun-cms/node_modules/tapable/lib/HookCodeFactory.js:24:12), <anonymous>:16:1)
at AsyncSeriesHook.lazyCompileHook [as _callAsync] (/Users/mehdibenadda/Development/fun-cms/node_modules/tapable/lib/Hook.js:35:21)
at compilation.seal.err (/Users/mehdibenadda/Development/fun-cms/node_modules/webpack/lib/Compiler.js:497:30)
at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/mehdibenadda/Development/fun-cms/node_modules/tapable/lib/HookCodeFactory.js:24:12), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook [as _callAsync] (/Users/mehdibenadda/Development/fun-cms/node_modules/tapable/lib/Hook.js:35:21)
at hooks.optimizeAssets.callAsync.err (/Users/mehdibenadda/Development/fun-cms/node_modules/webpack/lib/Compilation.js:985:35)
...
Actual Behaviour
The original TS error is reported, e.g. for microsoft/TypeScript#26554
/Users/fabio/projects/0x-monorepo-one/node_modules/typescript/lib/typescript.js:14080
return path.replace(backslashRegExp, ts.directorySeparator);
^
TypeError: Cannot read property 'replace' of undefined
at Object.normalizeSlashes (/Users/fabio/projects/0x-monorepo-one/node_modules/typescript/lib/typescript.js:14080:21)
at getCommonSourceDirectory (/Users/fabio/projects/0x-monorepo-one/node_modules/typescript/lib/typescript.js:82737:68)
at verifyCompilerOptions (/Users/fabio/projects/0x-monorepo-one/node_modules/typescript/lib/typescript.js:84278:27)
at Object.createProgram (/Users/fabio/projects/0x-monorepo-one/node_modules/typescript/lib/typescript.js:82703:9)
at Converter.convert (/Users/fabio/projects/0x-monorepo-one/node_modules/typedoc/dist/lib/converter/converter.js:109:26)
at CliApplication.Application.convert (/Users/fabio/projects/0x-monorepo-one/node_modules/typedoc/dist/lib/application.js:84:37)
at CliApplication.bootstrap (/Users/fabio/projects/0x-monorepo-one/node_modules/typedoc/dist/lib/cli.js:62:32)
at CliApplication.Application [as constructor] (/Users/fabio/projects/0x-monorepo-one/node_modules/typedoc/dist/lib/application.js:44:15)
at new CliApplication (/Users/fabio/projects/0x-monorepo-one/node_modules/typedoc/dist/lib/cli.js:38:42)
at Object.<anonymous> (/Users/fabio/projects/0x-monorepo-one/node_modules/typedoc/bin/typedoc:4:1)
error Command failed with exit code 1.
Steps to Reproduce the Problem
For microsoft/TypeScript#26554, it should be enough to have a ts-loader
config that looks something like:
{
test: /\.tsx?$/,
loader: 'ts-loader',
options: {
compilerOptions: {
composite: true,
}
}
}
i.e. compiler options has composite
, but not rootDir
set.
Location of a Minimal Repository that Demonstrates the Issue.
microsoft/TypeScript#26554 (comment) links to a reproducing case.