簡體   English   中英

打字稿代碼樣式TS2539:無法分配給“ execFile”,因為它不是變量

[英]typescript code style TS2539:Cannot assign to 'execFile' because it is not a variable

我有一個密碼

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.

我應該以正確的方式重寫代碼以解決此問題,還是只保留它的內容

設置types為您tsconfig compilerOptions ,這樣

"compilerOptions": {
    "target": "es5",
    "lib": [ "es2015"],
    "types": ["node"],
    "module": "commonjs"
  }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM