Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 21 09:57
    arcanis opened #1511
  • Sep 20 16:18
    reduxdj edited #1510
  • Sep 20 16:18
    reduxdj opened #1510
  • Sep 20 08:28
    mininek opened #1509
  • Aug 15 17:06
    chaffeqa opened #1508
  • Aug 08 16:07
    lierdakil closed #1507
  • Aug 08 16:07
    lierdakil labeled #1507
  • Aug 08 11:43
    rahamin1 opened #1507
  • Aug 07 12:07
    lierdakil labeled #1505
  • Aug 07 12:07
    lierdakil closed #1505
  • Aug 06 21:51
    TheEmrio closed #1506
  • Aug 05 14:22
    TheEmrio opened #1506
  • Jul 15 15:40
    Xapphire13 closed #1496
  • Jul 10 13:23
    akonwi opened #1505
  • Jul 10 04:44
    nelson6e65 edited #1504
  • Jul 10 04:40
    nelson6e65 opened #1504
  • Jul 08 06:40
    sshquack closed #846
  • Jun 17 16:02
    akonwi opened #1503
  • Jun 02 18:18
    tanfonto opened #1502
  • May 28 17:11
    jazzdragon opened #1501
Philipp Knecht
@fopsdev
experimenting with atom-typescript. having a lot of fun so far :smile: btw. @mtraynham : any plans for typescript definitions for https://github.com/mtraynham/lodash-joins?
kpgarrod
@kpgarrod
@fopsdev @mtraynham that's a really interesting library - surprising what you pick up in unexpected places
kpgarrod
@kpgarrod
are es6 promises implemented in the Typescript that a-t uses?
Nelo Mitranim
@Mitranim
Promise is a native API, you'll have to polyfill it for old environments. If you mean promise definitions, then apparently they're not yet included into the standard distribution =/
kpgarrod
@kpgarrod
I was thinking of Promise, not the defs. I suppose my question was whether Typescript provides a polyfill and I take it the answer is no
Nelo Mitranim
@Mitranim
Yeah it's not something the transpiler can inline, this is the de facto polyfill and it's not that small
kpgarrod
@kpgarrod
@mitranim: thanks. I am using angular 1.x, so I have $q, but I've got an issue that has been driving me crazy
Nelo Mitranim
@Mitranim
@kpgarrod you should use tsd and download angular definitions
kpgarrod
@kpgarrod
I use this kind of syntax: this.canActivate().then(this.activate); quite a lot
Nelo Mitranim
@Mitranim
your promise signatures will look like this: ng.IPromise<any>
kpgarrod
@kpgarrod
I have angular definitions
Nelo Mitranim
@Mitranim
alright then
getting ahead of myself
so what's the issue
kpgarrod
@kpgarrod
the problem with that syntax is that 'this' seems to get messed up
this.canActivate().then(() => { this.activate() });
works
Nelo Mitranim
@Mitranim
yes that's what you'll have to do
or .then(this.activate.bind(this))
no other way around this
kpgarrod
@kpgarrod
mmm, that is a big pain
Nelo Mitranim
@Mitranim
yeah that's a bit of a pain
we'll have to live with this
kpgarrod
@kpgarrod
OK, yes that bind is a good idea
Nelo Mitranim
@Mitranim
it's slower than .then(() => this.activate())
kpgarrod
@kpgarrod
probably milliseconds though right?
Nelo Mitranim
@Mitranim
a millisecond is a big deal...
anyway .bind is slower so use a function if you can
kpgarrod
@kpgarrod
if there are millions of them
got it
thanks
Basarat Ali Syed
@basarat
@kpgarrod this.canActivate().then(this.activate) would work if you define active as a lambda instead i.e. activate = ()=> instead of activate()
basically push the lambda to the point of definition instead of point of usage ;)
kpgarrod
@kpgarrod
@basarat: wow! I'm not sure I love the syntax, but I bow to your knowledge of the language
kpgarrod
@kpgarrod
say I have a file(1) with a number of imports (e.g. all the controllers in my app) and I want to import all of those controllers into two other files(2,3). How do I export all the imports from file 1 and re-import them to files 2 & 3?
Basarat Ali Syed
@basarat
@kpgarrod export * from "file"
kpgarrod
@kpgarrod
@basarat: sorry I'm being dumb here. So I have an export for each controller in 'controllers.ts' (instead of an import, right?). Then I import * as controllers from './controllers'; in my app.ts file and I try to use one of the controllers: var controller1 = controllers.Controller1. I get an error Controller1 does not exist on typeof controllers.js , although I get autocompletion for Controller1 on controllers.
Basarat Ali Syed
@basarat

I get an error Controller1 does not exist on typeof controllers.js

TypeScript error?

although I get autocompletion for Controller1 on controllers.

If its a completion provided by typescript you should see (badge) next to it. Otherwise its from the fuzzy finder and not reliable

kpgarrod
@kpgarrod
@basarat, I see. thanks for the tip
is there something wrong with what I am trying to do?
@basarat: sorry, yes typescript error
Basarat Ali Syed
@basarat

is there something wrong with what I am trying to do?

Nothing beyond the fact that I haven't done it personally so my advice might not be useful :D

kpgarrod
@kpgarrod
haha, mmm
Basarat Ali Syed
@basarat
import * as controllers from './controllers' and then controllers.Controller1 should work
If you have export class Controller1 in controllers
kpgarrod
@kpgarrod
mmm, do I need to import controller1 into controllers as well?
Basarat Ali Syed
@basarat
nope. Should be available on controllers
kpgarrod
@kpgarrod
so controllers only exports Controller1, but I can't seem to add a filepath to export class
export class Controller1 from './controller1'; gives me errors
kpgarrod
@kpgarrod
ah! export {default as Controller1} from './controller1';
Basarat Ali Syed
@basarat
my export statement was meant to go inside controller1. But whatever works :rose: