These are chat archives for TypeStrong/atom-typescript

11th
May 2015
Micah Zoltu
@MicahZoltu
May 11 2015 01:42
In one of my typescript files I have declare class Promise<T> .... When I compile to ES5, this results in var Promise being added to my scope. When I try to do new Promise... I get undefined because TypeScript has hidden the global Promise.
Does anyone know what I am doing wrong?
Basarat Ali Syed
@basarat
May 11 2015 01:43
@Zoltu if you have declare class then you *shouldn't be getting a var.
Make sure you have declare
Micah Zoltu
@MicahZoltu
May 11 2015 01:43
declare class Promise<R> implements Thenable<R> {
(copy/paste)
In my transpiled JavaScript file:
    var Promise, AuthInfo, OAuthWrapper, OAuth;
Basarat Ali Syed
@basarat
May 11 2015 01:44
Is this the only Promise mention in that file ?
Micah Zoltu
@MicahZoltu
May 11 2015 01:44
Other than uses of it, yes.
Just putting declare class Foo {} in my file results in var Foo, ...
Maybe a bug in system module type?
(seems largely unrelated)
Basarat Ali Syed
@basarat
May 11 2015 01:48
Maybe. I can't repro
blob
^ even using it didn't do a var
Micah Zoltu
@MicahZoltu
May 11 2015 01:48
:'(
Basarat Ali Syed
@basarat
May 11 2015 01:49
@Zoltu yes a bug in system. Commonjs is okay:
blob
Micah Zoltu
@MicahZoltu
May 11 2015 01:49
Were you able to reproduce with system?
Basarat Ali Syed
@basarat
May 11 2015 01:50
system is not okay:
blob
Report it on microsoft/issues if you can :rose:
Micah Zoltu
@MicahZoltu
May 11 2015 01:50
Thanks for double checking. Appreciate it.
Basarat Ali Syed
@basarat
May 11 2015 01:51
no worries
Micah Zoltu
@MicahZoltu
May 11 2015 01:51
Mind if I borrow your screenshot?
Basarat Ali Syed
@basarat
May 11 2015 01:51
go for it :)
@Zoltu just a recommendation : move the declarations into a .d.ts ;) that will not generate a var and you get to use the global promise as is :rose:
Micah Zoltu
@MicahZoltu
May 11 2015 01:53
I have been trying to avoid d.ts files until they work correctly with my dependency management system (JSPM).
I guess I can't put it off any longer and I just have to suffer if I want to continue with TS.
Basarat Ali Syed
@basarat
May 11 2015 01:55
@Zoltu you can still use a .ts but just don't do any import / export in the ts:
blob
Micah Zoltu
@MicahZoltu
May 11 2015 01:57
How do I reference it in that scenario?
importing says it isn't external.
Hmm... atom-typescript seems to find the Promise, but not the other interfaces.
Basarat Ali Syed
@basarat
May 11 2015 01:59

importing says it isn't external.

You don't import it. Promise becomes ambiently available as part of the compilation context (Just needs to be mentioned from tsconfig.json)

Micah Zoltu
@MicahZoltu
May 11 2015 01:59
Like this one: interface Thenable<R> {
Basarat Ali Syed
@basarat
May 11 2015 02:03
yup
Micah Zoltu
@MicahZoltu
May 11 2015 02:04
This is expected behavior?
How does one make an interface ambiently available?
Basarat Ali Syed
@basarat
May 11 2015 02:05

How does one make an interface ambiently available?

By having it in a file that doesn't have an import or export.

Micah Zoltu
@MicahZoltu
May 11 2015 02:05
Does it have to be in a separate file from other interfaces/classes?
I dropped a declare class ... and three interface ... into one file. The declare class is resolving in atom-typescript (no errors when I try to use it) but the interfaces are giving me errors when I reference them.
Basarat Ali Syed
@basarat
May 11 2015 02:08

but the interfaces are giving me errors when I reference them

code please

Micah Zoltu
@MicahZoltu
May 11 2015 02:08
interface Thenable<R> {
    then<U>(onFulfilled?: (value: R) => U | Thenable<U>,  onRejected?: (error: any) => U | Thenable<U>): Thenable<U>;
}

declare class Promise<R> implements Thenable<R> {
    constructor(callback: (resolve : (value?: R | Thenable<R>) => void, reject: (error?: Error) => void) => void);
    then<U>(onFulfilled?: (value: R) => U | Thenable<U>,  onRejected?: (error: Error) => U | Thenable<U>): Promise<U>;
    catch<U>(onRejected?: (error: Error) => U | Thenable<U>): Promise<U>;
}

interface JQueryPromiseCallback<T> {
    (value?: T, ...args: any[]): void;
}

interface JQueryPromise<T> {
    done(doneCallback?: JQueryPromiseCallback<T>): JQueryPromise<T>;
    fail(failCallback?: JQueryPromiseCallback<any>): JQueryPromise<any>;
}
Basarat Ali Syed
@basarat
May 11 2015 02:09

the following should work in another file, does it not work?

var foo: Theanable<any>

Micah Zoltu
@MicahZoltu
May 11 2015 02:10
This may be a bug in atom. When I did a full reload (ctrl-alt-R) the file using it stopped giving me errors and now I get an error in that file saying at line 5, file C:/Users/Micah/Source/Zoltu.RepoCreator.Client/source/typings/Promises.tsDuplicate identifier 'Promise'.
Everything appears to compile okay though... I can just not look at that file. :P
Basarat Ali Syed
@basarat
May 11 2015 02:11

Everything appears to compile okay though... I can just not look at that file.

Yes. Just do a sync : ctrl+' happens when a file is deleted / moved

Micah Zoltu
@MicahZoltu
May 11 2015 02:13
ctrl+' didn't seem to do anything (do I need to press it in a certain context?) but restarting atom fixed the issue.
Thanks!
:rose:
Basarat Ali Syed
@basarat
May 11 2015 02:13
:heart:
Micah Zoltu
@MicahZoltu
May 11 2015 02:13
Hmm... the error on Promise came back again.
(not sure what triggered it)
Oh well, I'll ignore.
Let me know if you need any information for a bug report or anything. I have no idea what the problem is. :/
Basarat Ali Syed
@basarat
May 11 2015 02:14

Duplicate identifier 'Promise'.

You have target es5 right?

Micah Zoltu
@MicahZoltu
May 11 2015 02:18
Yeah.
Oh, wait.
Ah, better.
Nope, broke again.
I build with gulp which doesn't (currently) use tsconfig.json. I was switching from ES6 to ES5, forgot to update tsconfig.json to match.
After changing it, same problem though.
Basarat Ali Syed
@basarat
May 11 2015 02:26
@Zoltu you can press ctrl+shift+r when you have ts file open and type in Promise to see all the places where Promise is declared.
Micah Zoltu
@MicahZoltu
May 11 2015 02:27
Odd.
The first one points at the expected line declare class Promise<R> ...
Two more point at:
interface JQueryPromiseCallback<T> { // this line
    (value?: T, ...args: any[]): void;
}

interface JQueryPromise<T> { // this line
    done(doneCallback?: JQueryPromiseCallback<T>): JQueryPromise<T>;
    fail(failCallback?: JQueryPromiseCallback<any>): JQueryPromise<any>;
}
Does that search do partial matching?
Basarat Ali Syed
@basarat
May 11 2015 02:28
@Zoltu yes on partial matching
Micah Zoltu
@MicahZoltu
May 11 2015 02:28
Ah.
Basarat Ali Syed
@basarat
May 11 2015 02:30
I still suspect the target is wrong :(
es6
I don't see how it would think that promise is duplicated otherwise
Micah Zoltu
@MicahZoltu
May 11 2015 02:31
I am getting an error about the module.
Basarat Ali Syed
@basarat
May 11 2015 02:31

I am getting an error about the module.

What error

Micah Zoltu
@MicahZoltu
May 11 2015 02:31
Key: 'module' has an invalid value: system
Basarat Ali Syed
@basarat
May 11 2015 02:31
@Zoltu in atom?
Micah Zoltu
@MicahZoltu
May 11 2015 02:31
I thought I saw that atom-typescript added system support, but maybe I am mixing it up with gulp-typescript.
Yeah.
Basarat Ali Syed
@basarat
May 11 2015 02:32
@Zoltu which version of atom-ts are you on :D
Micah Zoltu
@MicahZoltu
May 11 2015 02:32
Hmm... let me update. 4.1.5 previously.
Basarat Ali Syed
@basarat
May 11 2015 02:33
@Zoltu yup 4.1.5 doesn't have system support. Updating should fix that :rose:
Micah Zoltu
@MicahZoltu
May 11 2015 02:33
K. Maybe it'll also fix the Promise issue.
Appears it did. :rose:
Out of curiosity, do you have a setup that allows you to easily test things out? Currently, my setup does not make it easy for me to see what happens when I change compiler settings and the like.
I'm slowly working through my project trying to solve build errors from switching to compile to ES5 and System module type... it is difficult to tell what is broken and what I just don't understand because my environment at the moment doesn't make it easy to compare single-file projects.
Micah Zoltu
@MicahZoltu
May 11 2015 02:44
atomTS: No definition found
(on pressing F12)
Basarat Ali Syed
@basarat
May 11 2015 02:49

Currently, my setup does not make it easy for me to see what happens when I change compiler settings and the like

Changes to tsconfig.json are automatically picked up. So save a modifed tsconfig.json and tab to a .ts file and press f6 to trigger a build. Navigate through build errors with f8 / shift+f8

Micah Zoltu
@MicahZoltu
May 11 2015 02:51
I got it working, though oddly at first it didn't appear to be doing anything. Then after poking at it a bit (but not changing anything) it suddenly started working.
It was around the time I added a second file, not sure if that matters.
Basarat Ali Syed
@basarat
May 11 2015 02:52
¯\(ツ)
Micah Zoltu
@MicahZoltu
May 11 2015 02:53
Well, it is working now and I was able to reproduce the bug I need to submit to the TypeScript guys.
Nelo Mitranim
@Mitranim
May 11 2015 04:50
:point_up: May 11 2015 2:39 AM Nice, thanks!
kpgarrod
@kpgarrod
May 11 2015 06:05

I have some lodash mixins. How should I include them in my webpack/typescript project?
e.g.:

<_.mixin({
< capitalize: function (input: string) {
< if (typeof input === 'string') {
< return input.charAt(0).toUpperCase() + input.substring(1).toLowerCase();
< } else {
< console.log("Attempting to capitalize non-string:", input);
< return input;
< }
< }
< })

Basarat Ali Syed
@basarat
May 11 2015 06:06
@kpgarrod you can include code samples using backticks : ` same as github
kpgarrod
@kpgarrod
May 11 2015 06:06
yes sorry, just fixing that up
   capitalize: function (input: string) {
     if (typeof input === 'string') {
       return input.charAt(0).toUpperCase() + input.substring(1).toLowerCase();
     } else {
       console.log("Attempting to capitalize non-string:", input);
       return input;
     }
   }
mmm, I lost something there
Basarat Ali Syed
@basarat
May 11 2015 06:07
looks like it
kpgarrod
@kpgarrod
May 11 2015 06:08
 _.mixin({
   capitalize: function (input: string) {
   }
})
Basarat Ali Syed
@basarat
May 11 2015 06:09
@kpgarrod put them in a file and put that file as a dependency of the main application.ts file
kpgarrod
@kpgarrod
May 11 2015 06:10
yes, but do I need export/import statemenet?
what do they look like?
Basarat Ali Syed
@basarat
May 11 2015 06:11
import * as _ from 'lodash';
 _.mixin({
   capitalize: function (input: string) {
   }
})
kpgarrod
@kpgarrod
May 11 2015 06:11
preferably es6 syntax
Basarat Ali Syed
@basarat
May 11 2015 06:11
@kpgarrod updated sample
kpgarrod
@kpgarrod
May 11 2015 06:12
thanks, I already have lodash imported to app.js
so now I need to export my mixins and import them to app.js, right?
Basarat Ali Syed
@basarat
May 11 2015 06:13

so now I need to export my mixins and import them to app.js, right?

Not if you are mixing in globally

wouldn't _.mixin('capitalize make capitalize a member of _ globally? (as long as its the same _ module location)
kpgarrod
@kpgarrod
May 11 2015 06:15
so I import lodash into my mixin file and then import my mixin file into app.js?
Basarat Ali Syed
@basarat
May 11 2015 06:15

then import my mixin file into app.js

Yes. Basically just to effectively monkey patch _ globally, which only needs to be done once.

kpgarrod
@kpgarrod
May 11 2015 06:16
yes, but then I still need an export in my mixin file, right?
Basarat Ali Syed
@basarat
May 11 2015 06:16
Yes. Just do export {_} :+1:
kpgarrod
@kpgarrod
May 11 2015 06:17
that's what I was missing, thanks :)
kpgarrod
@kpgarrod
May 11 2015 08:40

I seem to be having a couple of rather serious problems:

1) I am making changes to a file, a-t gives me an emitted message, but the changes don't appear in the js file

2) If I delete a file (with atom or finder) which is already in tsconfig, then build, the deleted file reappears!
the only way I can get rid of it is to manually delete it from tsconfig and then delete it from the file system
kpgarrod
@kpgarrod
May 11 2015 08:49
I upgraded atom to 0.198.0 this morning. looks like it could be related
I got some errors reported from atom
when reloading after deletin a file
Elisée Maurer
@elisee
May 11 2015 10:32
hi! thanks for a very cool plugin.
is there a way to prevent atom-typescript from auto-updating tsconfig.json with the list of files? We're versioning it and using it with other people who use different editors with different plugins and we'd rather not have files listed explicitly since they can be inferred automatically anyway.
Nelo Mitranim
@Mitranim
May 11 2015 10:38
Yes, just remove the filesGlob and files properties and update the plugin to 4.2+
Elisée Maurer
@elisee
May 11 2015 10:38
awesome, thanks! :)
Basarat Ali Syed
@basarat
May 11 2015 11:14
@Mitranim now I definitely see the value of your suggestion. Thanks for making me do this (not forcing filesGlob down to everyone) :D

@kpgarrod :

1) I am making changes to a file, a-t gives me an emitted message, but the changes don't appear in the js file

Should not happen. Need a repro. Try ctrl+shift+m in a .ts file to make sure that it is the same js as you think it is.

2) If I delete a file (with atom or finder) which is already in tsconfig, then build, the deleted file reappears!

Yes, on file deletion / insertion : since we do not do file watching : you need to ask atom-ts to do a file scan (the sync command : ctrl+') to re-evaluate its opinion of the file system.

kpgarrod
@kpgarrod
May 11 2015 11:31
@basarat: thanks! Now at least I'm not so baffled
I take it ctrl+shift+m is cmd+shift+m on mac? It doesn't appear to do anything for me
Matt Traynham
@mtraynham
May 11 2015 14:17
This is the chattiest room on gitter :)
everytime I come back it's like 99+ notifications
Nelo Mitranim
@Mitranim
May 11 2015 14:35
@mtraynham you haven't seen the aurelia room :D
Basarat Ali Syed
@basarat
May 11 2015 21:43
@kpgarrod that's a bug. I'll fix it shortly 🌹