Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ Example:

Enable generating type definitions with `tsc` if your source code is written in [TypeScript](http://www.typescriptlang.org/).

By default, it'll use the `tsconfig.json` file in your project root. If you want to use a different config, you can specify it using the `project` option.
By default, it'll use the `tsconfig.json` file in your project root. If you want to use a different config, you can specify it using the `project` option. Furthermore, the tsc binary will be resolved to ./node_modules/.bin/tsc. Use the `tsc` option to specify a different path.

Example:

Expand Down
16 changes: 10 additions & 6 deletions src/targets/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { platform } from 'os';
import { Input } from '../types';

type Options = Input & {
options?: { project?: string };
options?: { project?: string; tsc?: string };
};

export default async function build({
Expand Down Expand Up @@ -78,9 +78,9 @@ export default async function build({
);
}

let tsc =
path.join(root, 'node_modules', '.bin', 'tsc') +
(platform() === 'win32' ? '.cmd' : '');
let tsc = options?.tsc
? path.resolve(root, options.tsc)
: path.join(root, 'node_modules') + (platform() === 'win32' ? '.cmd' : '');

if (!(await fs.pathExists(tsc))) {
tsc = spawn
Expand All @@ -93,7 +93,9 @@ export default async function build({
'tsc'
)}. Consider adding ${chalk.blue('typescript')} to your ${chalk.blue(
'devDependencies'
)} instead.`
)} or specifying the ${chalk.blue(
'tsc'
)} option for the typescript target.`
);
}

Expand Down Expand Up @@ -127,7 +129,9 @@ export default async function build({
'node_modules'
)} or present in $PATH. Make sure you have added ${chalk.blue(
'typescript'
)} to your ${chalk.blue('devDependencies')}.`
)} to your ${chalk.blue('devDependencies')} or specify the ${chalk.blue(
'tsc'
)} option for typescript.`
);
}
} catch (e) {
Expand Down