These are chat archives for TypeStrong/atom-typescript

13th
May 2015
kpgarrod
@kpgarrod
May 13 2015 07:12
@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
May 13 2015 07:38

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
May 13 2015 07:39
@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
May 13 2015 07:41

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
May 13 2015 07:41
haha, mmm
Basarat Ali Syed
@basarat
May 13 2015 07:41
import * as controllers from './controllers' and then controllers.Controller1 should work
If you have export class Controller1 in controllers
kpgarrod
@kpgarrod
May 13 2015 07:46
mmm, do I need to import controller1 into controllers as well?
Basarat Ali Syed
@basarat
May 13 2015 07:46
nope. Should be available on controllers
kpgarrod
@kpgarrod
May 13 2015 07:49
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
May 13 2015 07:55
ah! export {default as Controller1} from './controller1';
Basarat Ali Syed
@basarat
May 13 2015 07:56
my export statement was meant to go inside controller1. But whatever works :rose:
kpgarrod
@kpgarrod
May 13 2015 07:58
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
May 13 2015 07:59
default exports are more of a carryover from cjs
In ES6, you nearly always want to use named exports
Basarat Ali Syed
@basarat
May 13 2015 08:07

In ES6, you nearly always want to use named exports

I also find them much easier to refactor ;)

kpgarrod
@kpgarrod
May 13 2015 08:10
thanks for the advice
kpgarrod
@kpgarrod
May 13 2015 10:16
how do you change the indentation (number of spaces) for formatting?
kpgarrod
@kpgarrod
May 13 2015 10:20
perfect! thanks
how do you run a command: Typescript: Dependency View?
Basarat Ali Syed
@basarat
May 13 2015 10:21
@kpgarrod ctrl + shift + p and type in dependency view
kpgarrod
@kpgarrod
May 13 2015 10:23
wow! that is very cool :)
Mike Graham
@cmichaelgraham
May 13 2015 11:01

@basarat :point_up: atom-typescript notes you are awesome :+1:

@AshleyGrant and I will make sure we incorporate these tips into the more polished subsequent versions of the :point_up: video chat

Basarat Ali Syed
@basarat
May 13 2015 11:08
Thanks for your kindness. I need to work to make it easier to display the package's world view of files (which tsconfig, which file names etc etc.)
Mike Graham
@cmichaelgraham
May 13 2015 11:15

hopefully it helps to get to see us bumping around as we experiment. it could probably be handled as a training issue. perhaps just a short section on getting started tips and tricks.

i really think once we incorporate your comments, there should be no issues with atom-typescript.

Mike Graham
@cmichaelgraham
May 13 2015 15:49
on the topic of default exports, i hacked this together and it seems to be working:
// Type definitions for Showdown 0.3.1
// Project: https://github.com/coreyti/showdown
// Definitions by: cbowdon <https://github.com/cbowdon>
// Definitions: https://github.com/borisyankov/DefinitelyTyped

declare module Showdown {

    /** Defined for information only - used in union type */
    interface Replace {
        /**
         * This is just the replacer function argument to String.prototype.replace, signature from lib.d.ts
         */
        replace(substring: string, ...args: any[]): string;
    }

// ... removed for brevity ...

    function forEach<T>(obj: T[], callback: (value: T, index: number, array: T[]) => any): void;
}

declare module "showdown" {
    var s: { Showdown };
    export default s.Showdown;
}
Mike Graham
@cmichaelgraham
May 13 2015 16:00
i also edited the knockout.d.ts at the bottom to make it happy:

declare module "knockout" {
    var ko: KnockoutStatic;
    export default ko;
}
moved the KnockoutStatic inside the module declare
and replaced the = with default