打字稿代码样式TS2539:无法分配给"execFile",因为它不是变量 [英] typescript code style TS2539:Cannot assign to 'execFile' because it is not a variable
本文介绍了打字稿代码样式TS2539:无法分配给"execFile",因为它不是变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个密码
import * as path from 'path';
import * as globby from 'globby';
import { execFile } from 'child_process';
import * as util from 'util';
//import * as Promise from 'bluebird';
import * as fs from 'fs';
execFile = util.promisify(execFile);
当编译为js时
显示这样的错误日志
Error:(12, 1) TS2539:Cannot assign to 'execFile' because it is not a variable.
我应该以正确的方式重写代码以解决此问题,还是只保留它的原意
what should i rewrite code for fix this in right way, or just keep ingorne it
推荐答案
在compilerOptions
中为tsconfig设置types
,就像这样
Setting up types
for your tsconfig in compilerOptions
, like this
"compilerOptions": {
"target": "es5",
"lib": [ "es2015"],
"types": ["node"],
"module": "commonjs"
}
这篇关于打字稿代码样式TS2539:无法分配给"execFile",因为它不是变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文