Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 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
  • Apr 29 01:12
    dyping closed #1500
  • Apr 28 06:56
    dyping edited #1500
  • Apr 28 06:54
    dyping edited #1500
  • Apr 26 11:38
    dyping opened #1500
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:
kpgarrod
@kpgarrod
I see I was using export default in Controller1. If I just use export Controller1 then I can re-export
Microsoft/TypeScript#2726
@basarat: Thanks for the help anyway
Nelo Mitranim
@Mitranim
default exports are more of a carryover from cjs
In ES6, you nearly always want to use named exports
Basarat Ali Syed
@basarat

In ES6, you nearly always want to use named exports

I also find them much easier to refactor ;)

kpgarrod
@kpgarrod
thanks for the advice
kpgarrod
@kpgarrod
how do you change the indentation (number of spaces) for formatting?
kpgarrod
@kpgarrod
perfect! thanks
how do you run a command: Typescript: Dependency View?