3

I am new in typescript (in Javascript also actually), I need to convert two lines of javascript syntax below into typescript

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

I have tried to write like this, but it doesn't work:

import * as gcs() from '@google-cloud/storage'
import * as spawn.spawn from 'child-process-promise'
1
  • The second one should probably be import { spawn } from 'child-process-promise' Commented Sep 11, 2018 at 12:08

1 Answer 1

2

You can't do that in es6. You have to write:

import * as gcs from '@google-cloud/storage'
const something = gcs();
Sign up to request clarification or add additional context in comments.

2 Comments

It would be weird though for a namespace object to be callable. Maybe it works with transpilers and legacy (commonjs) modules, but I wouldn't count on that.
@Bergi well based on the question description gcs is callable i think

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.