在打字稿中导入函数和对象属性的语法是什么?

时间:2018-09-11 11:50:36

标签: typescript

我是打字稿的新手(实际上也是Javascript),我需要将下面两行javascript语法转换为打字稿

   const gcs = require('@google-cloud/storage')();
    const spawn = require('child-process-promise').spawn

我试图这样写,但是不起作用:

import * as gcs() from '@google-cloud/storage'
import * as spawn.spawn from 'child-process-promise'

1 个答案:

答案 0 :(得分:2)

您无法在es6中做到这一点。您必须写:

import * as gcs from '@google-cloud/storage'
const something = gcs();