2

I've tried to setup Gulpfile configuration only with Typescript. Created in project's root folder named gulpfile.ts with index.ts:

import { task } from 'gulp';
import { clearBuild } from './tasks/clear-build';

task('build', clearBuild);
task('default', clearBuild);

tasks/clear-build.ts:

import { deleteAsync } from 'del';
import { paths } from '../configs/paths';

export function clearBuild(): Promise<string[]> {
  return deleteAsync(paths.buildBase);
}

configs/paths.ts:

const buildBase = './dist';

export const paths = {
  buildBase,
};

So when I try to start it running gulp it causes an error

[13:42:40] Requiring external module ts-node/register
Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import '/home/zhenya/Documents/code/gulp-project-v2/gulpfile.ts' is not supported resolving ES modules imported from /home/zhenya/Documents/code/gulp-project-v2/node_modules/gulp-cli/lib/shared/require-or-import.js
Did you mean to import /home/zhenya/Documents/code/gulp-project-v2/gulpfile.ts/index.ts?

Adding manually .ts to imports make Typescript complain:

An import path cannot end with a '.ts' extension. Consider importing './tasks/clear-build' instead.

So, what I need to do to make it only with Typescript?

0 Answers0