Skip to content

Using popsicle with typescript #89

@nubunto

Description

@nubunto

Hello!

First of all, thanks for the effort directed at maintaining this library.

I'm building a typescript + mobx project, on which I'm using popsicle:

export default class AppState {
  @observable isLoggedIn: boolean
  @observable loggedUser: User

  @action logIn() {
    popsicle({
        url: 'http://localhost:3000/login',
        method: 'POST',
        json: true,
    })
    .use(popsicle.plugins.parse('json'))
    .then((response) => {
      const { body } = response
      if(body.ok) {
        this.loggedUser = body.user
      } else {
        console.log('SHIT', response)
      }
    })
    .catch((error) => console.log('LOGIN_ERROR', error))
  }
}

Unfortunately, when building (webpack), I get a lot of errors like this:

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/base.d.ts:16:9 
Cannot find name 'Url'.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/index.d.ts:1:47 
Cannot find module 'http'.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/index.d.ts:9:10 
Cannot find name 'CookieJar'.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/index.d.ts:15:18 
Cannot find name 'Buffer'.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/index.d.ts:15:42 
Cannot find name 'Buffer'.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/index.d.ts:16:20 
Cannot find name 'Buffer'.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/index.d.ts:17:19 
Cannot find name 'Buffer'.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/index.d.ts:21:41 
Cannot find name 'Promise'.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/index.d.ts:21:63 
Cannot find name 'Promise'.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/index.d.ts:23:28 
Cannot find name 'Promise'.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/jar.d.ts:2:48 
Cannot find name 'CookieJar'.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/plugins/common.d.ts:4:67 
Cannot find name 'Promise'.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/plugins/common.d.ts:4:89 
Cannot find name 'Promise'.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/plugins/common.d.ts:5:69 
Cannot find name 'Promise'.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/plugins/common.d.ts:5:91 
Cannot find name 'Promise'.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/plugins/common.d.ts:7:111 
Cannot find name 'Promise'.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/plugins/common.d.ts:7:133 
Cannot find name 'Promise'.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/plugins/index.d.ts:4:66 
Cannot find name 'Promise'.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/plugins/index.d.ts:4:88 
Cannot find name 'Promise'.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/request.d.ts:27:32 
Cannot find name 'Promise'.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/request.d.ts:35:64 
Cannot find name 'Promise'.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/request.d.ts:35:97 
Cannot find name 'Promise'.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/request.d.ts:52:14 
Cannot find name 'Promise'.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/request.d.ts:55:130 
Cannot find name 'Promise'.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/request.d.ts:56:55 
Cannot find name 'Promise'.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/request.d.ts:62:7 
A parameter initializer is only allowed in a function or constructor implementation.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/request.d.ts:62:14 
Cannot find name 'keyof'.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/request.d.ts:62:20 
'=' expected.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/request.d.ts:63:8 
A parameter initializer is only allowed in a function or constructor implementation.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/request.d.ts:63:15 
Cannot find name 'keyof'.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/request.d.ts:63:21 
'=' expected.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/request.d.ts:64:9 
A parameter initializer is only allowed in a function or constructor implementation.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/request.d.ts:64:16 
Cannot find name 'keyof'.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/request.d.ts:64:22 
'=' expected.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/request.d.ts:65:9 
A parameter initializer is only allowed in a function or constructor implementation.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/request.d.ts:65:16 
Cannot find name 'keyof'.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/request.d.ts:65:22 
'=' expected.

ERROR in [default] /home/bruno/cofundadores/mobx-tutorial/node_modules/popsicle/dist/request.d.ts:67:14 
Cannot find name 'Promise'.

I'm 80% sure that I'm doing something wrong, and this isn't an issue with popsicle. But, if someone can point me at the right direction, that would be great.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions