deepkit-framework icon indicating copy to clipboard operation
deepkit-framework copied to clipboard

On Windows, `type-compiler` code injected into Typescript is partially invalid

Open adam-coster opened this issue 3 years ago • 0 comments

The @deepkit/type-compiler installation mutations Typescript's tsc.js and typescript.js files (perhaps other as well?).

On Windows (when installing with pnpm), part of the injected code looks like this:

try {
    typeTransformer = require('@deepkit/type-compiler');
} catch (error) {
    typeTransformer = require('..\..\..\..\@[email protected][email protected]\node_modules\@deepkit\type-compiler\dist\cjs');
}

Corresponding to the source: https://github.com/deepkit/deepkit-framework/blob/c1d6c415199804d966ce17ceb235a050de011da3/packages/type-compiler/install-transformer.ts#L23-L27

The \ path delimiters are not escaped in the path-string in the catch block, resulting in an invalid path.

This can be resolved by either escaping those characters (making them \\) or by using POSIX path delimiters (/), which are what Node expects anyway, even on Windows.

This issue would make deepkit impossible to use with tsc in cases where that try-block require doesn't work, though I'm not sure what scenarios could cause that to happen.

adam-coster avatar Aug 19 '22 23:08 adam-coster