Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using popsicle with typescript #89

Closed
nubunto opened this issue Feb 17, 2017 · 3 comments
Closed

Using popsicle with typescript #89

nubunto opened this issue Feb 17, 2017 · 3 comments
Labels

Comments

@nubunto
Copy link

nubunto commented Feb 17, 2017

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!

@nubunto nubunto changed the title Using popsicle in typescript Using popsicle with typescript Feb 17, 2017
@blakeembrey
Copy link
Member

The definitions need to be installed with Typings first. TypeScript doesn't support browser resolution (microsoft/TypeScript#7753) or have the types used by this library (microsoft/types-publisher#4) yet.

@nubunto
Copy link
Author

nubunto commented Feb 17, 2017

Great, I'll look into it.

Thanks!

@blakeembrey
Copy link
Member

Feel free to let me know if you run into any other issues! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants