Skip to content

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

@adam-coster

Description

@adam-coster

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('..\..\..\..\@deepkit+type-compiler@1.0.1-alpha.75_typescript@4.7.4\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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions