These are chat archives for Microsoft/TypeScript

6th
Dec 2016
ian lyons
@ianlyons
Dec 06 2016 03:51 UTC
i'm really struggling to include the definitions for a third-party lib... keep getting Cannot find module '<libname>'
anyone have a couple of minutes to help me out?
Daniel Tabuenca
@dtabuenc
Dec 06 2016 04:42 UTC
@ianlyons sure... what's the lib?
Joe
@foxjazz
Dec 06 2016 06:41 UTC
   let t1 = tis.targetTime;
                    let t2 = new Date();
              //      let dif = t1.getTime() - t2.getTime();

                //    tis.left = dif / 1000;
trying to get time difference betweein Date() and a targettime in seconds.
.getTime() isn't a function
Alexey Starfall
@acterhd
Dec 06 2016 06:59 UTC
Microsoft - want to say last word... Please, break your barrier and make your own NodeJS and browser, that natively support TypeScript
Make typescript that have much scope
Daniel Tabuenca
@dtabuenc
Dec 06 2016 07:01 UTC
@acterhd what would be the point?
you already have ts-node
seems like a waste of time better spent on making the language itself better
Daniel Tabuenca
@dtabuenc
Dec 06 2016 07:06 UTC
@foxjazz What's the type of t1 and tis.targetTime ?
Nadav Sinai
@nadavsinai
Dec 06 2016 07:29 UTC
@foxjazz I usually did using .valueOf() which gives you Unix timestamp in milliseconds, just divide by 1000 to get to seconds
Diff not did...
Daniel Tabuenca
@dtabuenc
Dec 06 2016 07:30 UTC
@nadavsinai getTime() is same as valueOf()
and preferred
valueOf() is mostly used internally in javascript application code generally should call getTime()
Nadav Sinai
@nadavsinai
Dec 06 2016 07:32 UTC
Why preferred? And if there is no .getTime() I guess t1 is not of Date type
Daniel Tabuenca
@dtabuenc
Dec 06 2016 07:33 UTC
@nadavsinai valueOf() is not meant to be used explicitly
it's not speicif cto date's it's just a way to get the primitive value of any object.
getTime() is specific and symetric to the corresponding setTime()
but if you just need a diff you don't need either.... since valueOf() is called implicitly so you can just do
let date1 = new Date();
let date2 = new Date();
let diff = date2-date1;
Alexey Starfall
@acterhd
Dec 06 2016 08:08 UTC
I want operator overloading in TS, that works like functions
a add b means right-left function
And have prioritt
Daniel Tabuenca
@dtabuenc
Dec 06 2016 08:10 UTC
typescript won't really add features outside of the type system that are not part of ecmascript standards.
that being said, there are proposals for value objects with overloadable operators in es7
but I guess that's old
don't know if it ever made it
Daniel Tabuenca
@dtabuenc
Dec 06 2016 08:17 UTC
looks like it's still on for 2017
con-ssc
@con-ssc
Dec 06 2016 08:17 UTC

Maybe use void(0) ;) undefined can be overwritten

Why undefined and not null?

  1. Because it spares us from having to think about both, so we picked one.
  2. Because undefined comes from optional properties and uninitialized variables - it's easier to rule out null than undefined.
  3. null is the weirder option (i.e. typeof null is "object").
Daniel Tabuenca
@dtabuenc
Dec 06 2016 08:19 UTC
people that worry about "undefined" being overwritten are funny.
has anyone actually encountered a situation in real-life where undefined was overwritten causing a problem?
who would overwrite undefined other than as a joke?
in the meantime we have people doing crazy long unefined checks
if( typeof(myVariable) !== 'undefined') .....
not to mention any modern browser that's es5 compliant won't really let you redefine it
Roman Roelofsen
@romanroe
Dec 06 2016 08:24 UTC
@DanielRosenwasser @con-ssc Thanks!
Roman Roelofsen
@romanroe
Dec 06 2016 08:31 UTC
And another question.... ;-) Why does 'readonly' only affects the type checker and does not create "truly" readonly properties with Object.defineProperty()?
Daniel Tabuenca
@dtabuenc
Dec 06 2016 08:40 UTC
I think because readonly is part of the type system (can be used on interfaces for example) and they generally as a principle try to avoid type system constructs leaking into runtime implementation.
Steven
@stevekane
Dec 06 2016 08:41 UTC
^
Daniel Tabuenca
@dtabuenc
Dec 06 2016 08:42 UTC
@romanroe if you want define property you use a getter
class Foo{
     get readonlyProperty(){
         return "this is read only"
     }
}
which will transpile to
 Object.defineProperty(Foo.prototype, "readonlyProperty", {
        get: function () {
            return "this is read only";
        },
        enumerable: true,
        configurable: true
    })
Roman Roelofsen
@romanroe
Dec 06 2016 09:11 UTC
@dtabuenc Thanks!
Kris Thomsen
@kristho91
Dec 06 2016 10:53 UTC

Isn't this the correct syntax to execute a callback in an Angular 1.5 component?

this.onSomethingChange({ value: this.someValue });

The callback stuff really gets me every single time I use it :(
Daniel Tabuenca
@dtabuenc
Dec 06 2016 10:54 UTC
where's the callback?
Kris Thomsen
@kristho91
Dec 06 2016 10:54 UTC
this.onSomethingChange is the callback (it has type Function) and is in the bindings with "&"
Daniel Tabuenca
@dtabuenc
Dec 06 2016 10:55 UTC
do you wnat the correct syntax for calling it? or for defining it's type?
Kris Thomsen
@kristho91
Dec 06 2016 10:56 UTC
for calling it. Because it seems like it does not get executed (don't get the "response" in the other end)
Daniel Tabuenca
@dtabuenc
Dec 06 2016 10:57 UTC
well... it really depends on what you are binding it to
Kris Thomsen
@kristho91
Dec 06 2016 10:58 UTC
I don't follow? :) It's binded to a Function?
Daniel Tabuenca
@dtabuenc
Dec 06 2016 10:58 UTC
so if you have
bindings:  {
    onSomethingChanged: '&'
}
Kris Thomsen
@kristho91
Dec 06 2016 10:58 UTC
Yes
Daniel Tabuenca
@dtabuenc
Dec 06 2016 10:58 UTC
then at it's simplest you just call it:
this.onSomethingChanged();
Kris Thomsen
@kristho91
Dec 06 2016 10:58 UTC
Sure, but it expects a parameter in the other end :)
that's the "value"-part
Daniel Tabuenca
@dtabuenc
Dec 06 2016 10:59 UTC
what does onSomethingChanged look like?
Kris Thomsen
@kristho91
Dec 06 2016 10:59 UTC
it just takes the value as parameter and console.log it right now
At least that's what I suspect it to do
expect *
Daniel Tabuenca
@dtabuenc
Dec 06 2016 11:00 UTC
ok.. but show me how you use it in a template
because it's how you use it in the template that matters
do you include the parameter in the template?
for example.....
<my-component on-something-changed="doSomethingWith(value)" ></my-component>
Kris Thomsen
@kristho91
Dec 06 2016 11:01 UTC
yes: on-something-changed="vm.doSomething(value)"
But it never hits the doSomething(value) function :(
Daniel Tabuenca
@dtabuenc
Dec 06 2016 11:03 UTC
You're calling it right.
Kris Thomsen
@kristho91
Dec 06 2016 11:03 UTC
I thought so... And it usually works that way too... But everytime I need to use it a new place, I have problems with it :(
Daniel Tabuenca
@dtabuenc
Dec 06 2016 11:04 UTC
My guess is the expression in your template is somehow wrong
like you are in the wrong scope or your controller as is bound to something different etc...
Kris Thomsen
@kristho91
Dec 06 2016 11:05 UTC
Nope, that seems fine :(
Daniel Tabuenca
@dtabuenc
Dec 06 2016 11:13 UTC
Try seeing if it gets called directly with no controller
    <span>Value: {{theValue }}</span>
    <my-componentx on-something-changed="theValue = value"></my-componentx>
see if the value is output correctly
also, no errors in the console?
Kris Thomsen
@kristho91
Dec 06 2016 11:14 UTC
No errors :(
Daniel Tabuenca
@dtabuenc
Dec 06 2016 11:14 UTC
and does this.onSomethingChanged look like it's being set?
Kris Thomsen
@kristho91
Dec 06 2016 11:15 UTC
Yes, and I have checked typos on every part I could think of
Daniel Tabuenca
@dtabuenc
Dec 06 2016 11:16 UTC
Don't know then... you must be doing something odd
somewhere
Kris Thomsen
@kristho91
Dec 06 2016 11:16 UTC
Lol, yeah ;) I know :D
The joy of being a programmer... :D
Kris Thomsen
@kristho91
Dec 06 2016 11:23 UTC
@dtabuenc Actually, are there a better type to defined the callback as instead of just Function?
Something like this? (param: { value: string }) => ng.IPromise<any>
Rudde
@Rudde
Dec 06 2016 11:57 UTC
How do I get TS 2.1 RC from npm?
Mordechai Zuber
@M-Zuber
Dec 06 2016 12:12 UTC
:wave: Hi ya'll
I have an object that has an Elasticsearch client as one of its properties.
I want to create needed indices when the parent object is created, can I just make my constructor async?
scippio
@scippio
Dec 06 2016 12:45 UTC
Hi all .. is possible do something like:
import { MyClass } from `${appRoot}/lib/MyClass` ?
Kris Thomsen
@kristho91
Dec 06 2016 13:06 UTC
@scippio Don't think so, since the "from" part is relative and not absolute :)
Simon Meskens
@SimonMeskens
Dec 06 2016 15:30 UTC
I'm debating whether I should put the time into #1213
Daniel Tabuenca
@dtabuenc
Dec 06 2016 16:00 UTC
@kristho91 yes that's how you do it.... I have stuff like this for example
 onUpdateQty: (updateQtyParams: { item: CatalogItem }) => void;
 onAddItem: (addItemParams: { item: CatalogItem, quantity: number }) => void;
 onRemoveItem: (removeItemParams: { item: CatalogItem }) => void;
@Rudde you npm install typescript@rc
@scippio You can't use variables in an import like that, but you can use path mapping to load things relative to a root though.
You'll need to also configure your bundling tool to remap those paths as well
nunofreitasbotelho
@nunofreitasbotelho
Dec 06 2016 16:23 UTC
private upstreams: Upstreams[] = [
        new Upstreams(
            'production_something',
            true,
            true,
            [
                new Criteria(
                    {
                        min:1,
                        max:99
                    },
                    'www.something.com',
                    [
                        new Cookie(
                            'letme',
                            'in',
                            'cookie.com',
                            3600,
                            '/cookie'
                        )
                    ],
                    '/criteria',
                    {
                        country: 'Portugal',
                        region: 'Porto',
                        city: 'Porto'
                    },
                    {
                        device: 'iPhone',
                        type: 'smartphone',
                        browser: 'chrome',
                        version: {from: 45, to:54}
                    },
                    false
                )
            ],
            [
                new Upstream(
                    'serve',
                    {host:8080, port:80, location:'somethinga.com', rewrite:'something'}
                )
            ]
        )
    ];

I'm getting this error:

[default] /Users/NunoFreitasBotelho/dev/angular/trafficsplitter/src/app/upstreams/upstreams.service.ts:17:13
Argument of type 'Criteria[]' is not assignable to parameter of type 'Criteria'.
Property 'bucket' is missing in type 'Criteria[]'.
[default] Checking finished with 1 errors

Bucket is an interface inside my Criteria class and its supposed to be those min and max values
Dominic Böttger
@DominicBoettger
Dec 06 2016 17:12 UTC
Do you know any technique to be able to return something in the constructor instead of a new instance? Like in java....
jacobus-brogly
@jacobus-brogly
Dec 06 2016 17:50 UTC
will this work?
npm search @types/arcgis-js-api
i see only @types version 3.18 is on npm (i looked at valid install targets)
i see the vendor also released version 4.1 some time ago on github but not updated npm
jacobus-brogly
@jacobus-brogly
Dec 06 2016 17:55 UTC
can i just copy paste the t.ds file over the index file and be done with it?
the 2 versions
Daniel Tabuenca
@dtabuenc
Dec 06 2016 17:59 UTC
@DominicBoettger What do you mean return something in the constructor? Java constructors never have return types do they?
@nunofreitasbotelho Can't help you without knowing what your actual types are... judging from the error message your types aren't matching the structure of your data.
@jacobus-brogly no I would not copy over the file into the @types/folder
just don't use the @types for that one if there is no npm package available for it
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:01 UTC
ok
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:01 UTC
just use typings command or download it manually
and add it to your files:[] array or your includes:[]
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:01 UTC
ok would download manually
tsconfig.json ?
ok
cool
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:02 UTC
yeah or or ///<reference></reference> from one of your existing .ts files
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:02 UTC
I was looking for the /// in the doc, but couldnt find it
i need coffee
seen it before
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:03 UTC
/// is not used much now with imports and modules
it's for referencing standalone scripts instead of modules
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:03 UTC
yeah
found an example
/// <reference path="node.d.ts"/>
lolz
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:04 UTC
if you use typings it generates one index.d.ts file in your app
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:04 UTC
that path is relative to the module right?
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:04 UTC
that then references anything installed by the typings command
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:04 UTC
@dtabuenc yeah i know but this is a vendor d.ts
and they havent published it on npm
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:05 UTC
I thought the 4.0 isn't published
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:05 UTC
only the prev version 3.18, but not 4.1
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:05 UTC
yeah so uninstall the 3.18
and do
typings install --global github:Esri/jsapi-resources/4.x/typescript/arcgis-js-api.d.ts
assuming you still have the typings command
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:05 UTC
typings i dont have that command
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:05 UTC
npm install -g typings
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:05 UTC
will it install in node_modules/@types??
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:05 UTC
no it won't
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:06 UTC
ok but where then?
in the current dir this command is run?
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:06 UTC
it's configurable
but usually it will put it in a typings/sub-folder
and it will put a typgins/index.d.ts
that references all the sub folders
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:06 UTC
uuuh
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:07 UTC
so you then just include the index.d.ts in your project
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:07 UTC
not cool
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:07 UTC
why?
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:07 UTC
i want to keep node_modules/@types only for published npm types
i will download to my local source folder
and use via ///
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:07 UTC
wait what?
it won't go into node_modules at all
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:08 UTC
where will it go?
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:08 UTC
in a typings folder
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:08 UTC
aaah
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:08 UTC
or wherever you configure it
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:09 UTC
and i include it in the code <reference path="../../typings/blablabla"/>
i still need to change tsconfig.json right
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:10 UTC
blob
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:10 UTC
whats that?
ok
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:10 UTC
that's the structure of how it stores it
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:10 UTC
ah
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:10 UTC
and you need to include typings/index.d.ts
in your tsconfig
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:11 UTC
ok
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:11 UTC
or reference it somewhere globally
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:11 UTC
what do you mean by the last sentence
use /// ?
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:11 UTC
that's an option but I would just add it to the files or includes in tsconfig
I think that's cleaner
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:12 UTC
"or reference it somewhere globally" <<-- what do you mean by this?
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:12 UTC
yeah ///
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:12 UTC
ok
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:12 UTC
but file array or includes works just as well
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:12 UTC
i am a noob in ts, just want to understand namenclature
yeah sure
ok lemmi do what you just said
moment...
just one more thing
about the npm published 3.18 version
normally i get the ts via the import ... from "modulename" right?
but here is the thing
that module doesnt exist only its types
if I had used 3.18, how would that have worked?
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:17 UTC
the definition declares various modules
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:17 UTC
i dont know what you just siad
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:18 UTC
I'm not sure how they distribute the package...
do they have npm modules for js?
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:18 UTC
no
they dont use npm
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:18 UTC
how do you consume the api?
or rather how do you get the api?
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:18 UTC
I have to use <script> tag to load it
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:18 UTC
and it's available as globals in the page?
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:19 UTC
i dont know what you just said
arcGIS doesnt use commonJS, it uses AMD
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:19 UTC
like normal javascript.... how do you use it?
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:19 UTC
and I use and "adapter" so i can use it in commonJS workflow
ok i give you a link to a sample
just vanilla js
this example
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:20 UTC
so you can still import types from the 3.18 defintion
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:20 UTC
you see they use AMD
HOW do i import it in my *.ts file?
wouldnt "import" look for a module?
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:21 UTC
import {BaseMapOptions} from 'esri'
for example
no it won't
because you are only using types
you aren't using a concret thing like a constructor
so typescript won't emit a require
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:22 UTC
ok so the ts would just know "hey, this is only types"
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:22 UTC
as long as you are using the imported things as juts types:
var myOptions: BaseMapOptions // <---- this is on the right hand side of a : so it's just type
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:22 UTC
I know how types work, I am trying to understand what tsc does
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:22 UTC
var myOptions = new BaseMapOptions(); // <------ this would be used as a value so it would trigger a require
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:23 UTC
if you look at the code it does issue
```
var map = new Map({...});
so tsc would through an error because the module isnt there right?
only the types
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:28 UTC
I thin kthey also provide a dummy module
npm install esri
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:30 UTC
how does tsc know to connect module 'esri' and '@types/arcgis-js-api'
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:31 UTC
by default everything in @types/* gets loaded into the compilation context
inside arcgis-js-api there is a declare module 'esri'
this is written in an older style
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:31 UTC
35 downloads the last month, is this a serious module?
'esri'
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:32 UTC
so for example you ahve to do
import Map = require('esri/map')
oh wait.. it will
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:32 UTC
var Map = require(...)
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:32 UTC
I don't know how this is supposed to work
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:33 UTC
why they publish types via npm but no module is weird
ok, what i will do is just install the @types somewhere (4.1) and include it in tsconfig
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:35 UTC
I guess it's weird because they only intend this to work with amd
so it's ok for it to issue the requires
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:35 UTC
@dtabuenc you understand my pain))
some guy made an AMD commonJS bridge for ArcGIS
I am using his "adapter" but I still need a typefile since i am using TS
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:36 UTC
yeah so it's complicated I would try to follow that guide
and let it issue the requires but then exclude those from bundling
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:37 UTC
I got it working
I only need to add types
Daniel Tabuenca
@dtabuenc
Dec 06 2016 18:41 UTC
yeah I've never dealt with a lib that completely uses AMD in their types
I'm not sure there's an easy way to get it to work
jacobus-brogly
@jacobus-brogly
Dec 06 2016 18:47 UTC
i dont want to much tooling for just one d.ts file
i will download manually
put it in ly ./src folder with the other .ts files
and include via ///
and also adjust in "files" of the tsconfig.json
this should work right?
jacobus-brogly
@jacobus-brogly
Dec 06 2016 19:00 UTC
/// <reference path="./arcgis-js-api.d.ts" />
i have added this, but it is not being picked up by visual studio code
oh fuck
Map<K,V> is also a type in es6
hello?
jacobus-brogly
@jacobus-brogly
Dec 06 2016 19:06 UTC
this is in the d.ts file
 interface MapConstructor {
    new(properties?: MapProperties): Map;
  }

  export const Map: MapConstructor;
is there a namespace conflict
?
Jeff Hansen
@jeffijoe
Dec 06 2016 19:08 UTC

Is it possible to combine tagged unions? Like so:

export interface IAmountOffCoupon {
  offType: 'AMOUNT_OFF'
  amountOff: number
}

export interface IPercentOffCoupon {
  offType: 'PERCENT_OFF'
  percentOff: number
}

export interface IRegularCoupon {
  couponType: 'REGULAR'
}

export interface ISpecialDiscountCoupon {
  couponType: 'SPECIAL_DISCOUNT'
}

export interface IReferralCodeCoupon {
  couponType: 'REFERRAL_CODE'
  referrerUserId: string
}

export type Coupon = (IAmountOffCoupon | IPercentOffCoupon)
  & (IRegularCoupon | ISpecialDiscountCoupon | IReferralCodeCoupon)

When I do this, I get an error for the following:

  {
    id: 'JEFF17HA',
    couponType: 'REFERRAL_CODE',
    referrerUserId: 'auth0|583f5b0050d162d918a352e2',
    offType: 'AMOUNT_OFF',
    amountOff: 20
  }

The error ends with:

Types of property 'offType' are incompatible.
            Type '"AMOUNT_OFF"' is not assignable to type '"PERCENT_OFF"'.
Steven
@stevekane
Dec 06 2016 19:12 UTC
that type hurts the brain
Jeff Hansen
@jeffijoe
Dec 06 2016 19:12 UTC
Well, what do you suggest?
Steven
@stevekane
Dec 06 2016 19:13 UTC
unsure, trying to process it
I assume the goal is to say it's always but only one of these algebraic combinations?
Jeff Hansen
@jeffijoe
Dec 06 2016 19:13 UTC
Basically just trying to compose coupons
Steven
@stevekane
Dec 06 2016 19:13 UTC
ya I think I dig the approach
Jeff Hansen
@jeffijoe
Dec 06 2016 19:13 UTC
So basically there's the couponType and offType and I want to be able to mix and match them as I see fit
Steven
@stevekane
Dec 06 2016 19:14 UTC
ya I think you don't want a tagged union here actually
Jeff Hansen
@jeffijoe
Dec 06 2016 19:14 UTC
What do I want then?
Steven
@stevekane
Dec 06 2016 19:14 UTC
function overloading
of polymorphic dispatch
I was stuck in that pool recently myself actually
you have a generic type
Coupon
that is parameterized by two tagged unions
Jeff Hansen
@jeffijoe
Dec 06 2016 19:15 UTC
So I'll need to cast it all the time?
jacobus-brogly
@jacobus-brogly
Dec 06 2016 19:16 UTC
fuck I understand declare module now
wow
Steven
@stevekane
Dec 06 2016 19:16 UTC
interface Coupon {
  couponType: OffType
  offType: CouponType
}

type OffType = Reg | Spec | Ref
type CouponType = Amount | Percent
jacobus-brogly
@jacobus-brogly
Dec 06 2016 19:16 UTC
I am loving typescript
Steven
@stevekane
Dec 06 2016 19:16 UTC
@jeffijoe this is the model I would use
Jeff Hansen
@jeffijoe
Dec 06 2016 19:17 UTC
Hmm
Steven
@stevekane
Dec 06 2016 19:17 UTC
sorry let me amend the typo
you would use a tagged union
if the set union was not complete
basically if only certain combos were valid
of couponType/offType
but if the total set of unions is valid, then this model is bettter i think
Jeff Hansen
@jeffijoe
Dec 06 2016 19:18 UTC
You wanna split the unions into nested objects right?
Steven
@stevekane
Dec 06 2016 19:18 UTC
ya
it's a classic product type really
Jeff Hansen
@jeffijoe
Dec 06 2016 19:19 UTC
Honestly I get frustrated having to pull these things just to satisfy typescript :P
Steven
@stevekane
Dec 06 2016 19:19 UTC
my response to that is that you're trying to do the right thing
and that you'll benefit from it
the type system is really about modeling what is true in your domain
nothing at all about satisfying typescript
if you cannot get it to type-check it's likely a problem with your model
jacobus-brogly
@jacobus-brogly
Dec 06 2016 19:20 UTC
@stevekane I got a weird situation
Steven
@stevekane
Dec 06 2016 19:20 UTC
I say "likely" because that's not always true of course
Jeff Hansen
@jeffijoe
Dec 06 2016 19:20 UTC
I would just prefer having it in a flat object :P
Steven
@stevekane
Dec 06 2016 19:20 UTC
?
interface Coupon {
  couponType: { kind: 'Reg' } | { kind: 'Spec' } | { kind: 'Rec' }
  offType: { kind: 'Amount' } | { kind: 'Percent' }
}
not sure why it's highlighting it all awkwardly
Jeff Hansen
@jeffijoe
Dec 06 2016 19:22 UTC
Thats a nested object
Steven
@stevekane
Dec 06 2016 19:23 UTC
I am baffled @jeffijoe
Jeff Hansen
@jeffijoe
Dec 06 2016 19:23 UTC
couponType and offType would be objects themselves
Steven
@stevekane
Dec 06 2016 19:23 UTC
ya
what were you hoping would happen
Jeff Hansen
@jeffijoe
Dec 06 2016 19:23 UTC
No, I was hoping to keep it flat
Composing tagged unions
:P
But apparently that's not possible
Steven
@stevekane
Dec 06 2016 19:23 UTC
those are kind of just words
are you saying the object woudl have tags
but all flattened?
Jeff Hansen
@jeffijoe
Dec 06 2016 19:24 UTC
I'm saying the tags are just different properties
If you look at my original code, thats what I want - but where it works with type inference

If I do

<IReferralCodeCoupon & IAmountOffCoupon> {
    id: 'JEFF17HA',
    couponType: 'REFERRAL_CODE',
    referrerUserId: 'idhere',
    offType: 'AMOUNT_OFF',
    amountOff: 20
  }

it works

Steven
@stevekane
Dec 06 2016 19:25 UTC
ah I see your goal
gulp is giving an error
Steven
@stevekane
Dec 06 2016 19:26 UTC
you're wanting 2-dimensions of discrimination I think
if I understand your goal
jacobus-brogly
@jacobus-brogly
Dec 06 2016 19:27 UTC
[20:26:32] Browserfy Error { Error: Cannot find module 'esri/views/MapView' from '/home/jacobbogers/reactjs/reactjs-by-example-master/donorfind/src/client'
Steven
@stevekane
Dec 06 2016 19:27 UTC
like two discriminators for two different expectations
Jeff Hansen
@jeffijoe
Dec 06 2016 19:27 UTC
Yeah
And the & should compose them together
:D
Steven
@stevekane
Dec 06 2016 19:28 UTC
well frankly you can do this
with a tiny amount of work on your part
in this case
just enumerate the cases
in a single discriminated union
jacobus-brogly
@jacobus-brogly
Dec 06 2016 19:28 UTC
I have included "src/client/*.d.ts" in m tsconfig.json
Steven
@stevekane
Dec 06 2016 19:28 UTC
only 6 possible combinations
and you're asserting via your preference for a tagged union
that the set is closed to extension
Jeff Hansen
@jeffijoe
Dec 06 2016 19:30 UTC
At the moment I just defined the interfaces and tried out the inferrence
But I'd like to be able to do if (coupon.couponType === 'REFERRAL_CODE') { coupon.referralId; }
With type checking of course
Steven
@stevekane
Dec 06 2016 19:31 UTC
my point is that you don't actually have to express your type this way
you only need a single discriminator
Jeff Hansen
@jeffijoe
Dec 06 2016 19:32 UTC
How? :O
Steven
@stevekane
Dec 06 2016 19:32 UTC
type Coupon 
  = // all six combinations here with a single unique "name" string
because your type will be closed regardless
meaning you're saying there are only and exactly 6 possible combinations
w/ the type structure you're trying to create
so just do the union yourself and call it a day
Jeff Hansen
@jeffijoe
Dec 06 2016 19:32 UTC
No, there are 2 types of types (get a load of that, lol)
There's the couponType (is it a regular coupon or a referral code?), and the offType (is it an amount off, or a percent off?)
jacobus-brogly
@jacobus-brogly
Dec 06 2016 19:33 UTC
I am importing from a d.ts file via "import" but now the compiler is nagging that i cannot see the module in node_modules
wtf?
Jeff Hansen
@jeffijoe
Dec 06 2016 19:33 UTC
A coupon should have an offType as well as a couponType but I should be able to mix and match those as I wish
So you can have a referral code thats either an amount off or a percent off
Or a regular code thats either an amount off or a percent off
But if it's a REFERRAL_CODE it also has the referrerUserId field
Steven
@stevekane
Dec 06 2016 19:35 UTC
type TwoTags 
  = { name: 'REF_AMT', // both fields }
  | { name: 'REF_PER', // both fields } 
  | { name: 'REG_AMT', // both fields }
  | { name: 'REG_PER', // both fields }
  | { name: 'SPEC_AMT', //both fields }
  | { name: 'SPEC_PER', // both fields }
editing sorry, stupid gitter
jacobus-brogly
@jacobus-brogly
Dec 06 2016 19:37 UTC
what is the difference between "import * from xxx and import x = require ('..')
Steven
@stevekane
Dec 06 2016 19:37 UTC
I'm saying you have exactly 6 unique combinations in-fact
so just join them yourself
Jeff Hansen
@jeffijoe
Dec 06 2016 19:37 UTC
Eeeerrhh... :P
Steven
@stevekane
Dec 06 2016 19:38 UTC
that's exactly what you're trying to do
literally exactly
lol
This message was deleted
Jeff Hansen
@jeffijoe
Dec 06 2016 19:38 UTC
Yeah, but I dont wanna specify each combination up front
Steven
@stevekane
Dec 06 2016 19:38 UTC
wellllllllllllllllllllllllll
you cannot have everything @jeffijoe lol
you're doing exactly that anyway
in your intended use
you're asserting a closed set of combinations
Jeff Hansen
@jeffijoe
Dec 06 2016 19:38 UTC
I can... with JavaScript :rocket:
:P
Steven
@stevekane
Dec 06 2016 19:38 UTC
and just trying to save a nominal amount of typing
type CouponCore = { // stuff for any coupon }
type TwoTags 
  = { name: 'REF_AMT', /* both fields*/ } & CouponCore
  | { name: 'REF_PER', /* both fields*/ } & CouponCore
  | { name: 'REG_AMT', /* both fields*/ } & CouponCore
  | { name: 'REG_PER', /* both fields*/ } & CouponCore
  | { name: 'SPEC_AMT', /* both fields*/ } & CouponCore
  | { name: 'SPEC_PER', /* both fields*/ } & CouponCore
Jeff Hansen
@jeffijoe
Dec 06 2016 19:41 UTC
@stevekane I'm just gonna accept the bad inference, cause other than that my original attempt works
Steven
@stevekane
Dec 06 2016 19:41 UTC
haha
ok
glad we consumed our time
Jeff Hansen
@jeffijoe
Dec 06 2016 19:41 UTC
Thanks for your help though, appreciate it
Steven
@stevekane
Dec 06 2016 19:41 UTC
ya no worries
as a pro-tip tho
your total set of coupons
is literally never closed
so you're better off modeling it extensibly
this is like a classic case
Jeff Hansen
@jeffijoe
Dec 06 2016 19:42 UTC
Never closed?
Steven
@stevekane
Dec 06 2016 19:42 UTC
coupons are such a classical extension point of software
that modeling them as a closed or finite set
Jeff Hansen
@jeffijoe
Dec 06 2016 19:42 UTC
blob
Steven
@stevekane
Dec 06 2016 19:42 UTC
means you'll have to update everywhere that consumes them
as types are added
Jeff Hansen
@jeffijoe
Dec 06 2016 19:42 UTC
Here's the correct errors showing, yay
jacobus-brogly
@jacobus-brogly
Dec 06 2016 19:42 UTC
hello?
Steven
@stevekane
Dec 06 2016 19:43 UTC
@jacobus-brogly I don't know, I hate packing managers and modules with a passion
I have stripped all that shit out of my life
jacobus-brogly
@jacobus-brogly
Dec 06 2016 19:43 UTC

´´´
/// <reference path="arcgis-js-api.d.ts" />

import as MapView from "esri/views/MapView";
import
as ESRIMap from "esri/Map";
import * as esriLoader from 'esri-loader';
´´´

Steven
@stevekane
Dec 06 2016 19:43 UTC
it's a total waste of your time
Jeff Hansen
@jeffijoe
Dec 06 2016 19:43 UTC
@jacobus-brogly the imports stuff, import * is ESNext syntax, = require is TypeScript
Steven
@stevekane
Dec 06 2016 19:43 UTC
yes, the above is true
as to the implication, I have no idea
I think you should use import everywhere
Jeff Hansen
@jeffijoe
Dec 06 2016 19:44 UTC
Use the esnext version when you can
jacobus-brogly
@jacobus-brogly
Dec 06 2016 19:44 UTC
ok so in visual code, it all works, i get intellisense with the correct types
Jeff Hansen
@jeffijoe
Dec 06 2016 19:44 UTC
When you emit ES6 code it will use the modules format and not transpile to require
jacobus-brogly
@jacobus-brogly
Dec 06 2016 19:44 UTC
but during compilation it nags about "the module" not existing
ah wait
Steven
@stevekane
Dec 06 2016 19:45 UTC
usually that's a diff in naming
between the module and the type defs
( at least that's what I've seen people say in here )
@jeffijoe it might be interesting to show your use-case in a ticket
they provide really good/prompt feedback
and your concept seems reasonable from the POV of avoiding typing
which is legitimate
Jeff Hansen
@jeffijoe
Dec 06 2016 19:47 UTC
Ill do that :)
Jeff Hansen
@jeffijoe
Dec 06 2016 19:53 UTC
@stevekane Microsoft/TypeScript#12692
Judging from the fact that everything works smoothly if I just type cast when creating objects, it tells me if might be a bug in the type checker
@stevekane thanks again! Have a good one
Steven
@stevekane
Dec 06 2016 19:55 UTC
cya
Daniel Tabuenca
@dtabuenc
Dec 06 2016 20:27 UTC
@stevekane he can't use import everywhere because of how the library is designed
it's all AMD and virtual modules
the library is just a pain to work with
Steven
@stevekane
Dec 06 2016 20:28 UTC
ah
it might be inviting a lot of pain
seems like if the project doesn't require typescript
Daniel Tabuenca
@dtabuenc
Dec 06 2016 20:29 UTC
they wrote their typings so that it issues require calls for stuff
and they expect it to be AMD require format
he's using some commonjs adapter for it
but I don't think that's necessarily compatible with how the typings are written
jacobus-brogly
@jacobus-brogly
Dec 06 2016 20:34 UTC
ok
@dtabuenc funny i got it like working 50%
let me explain
if i use gulp typescript (not the browserify plugin) then it compiles correctly
let me show you my code
this is called "ambient typedecleration" as i only have a .d.ts file but no commonJS modules
this code shows correctly in visual studio code and compiles with the gulp target "ts-files"
the final .js still keep the "import as ESRIMAP..." statements because it thinks it is a real module somewhere in node_modules
so when browserify tries to bundle it , it nags about not finding the module))
can I use d.ts files with ///<reference /> without an "import" ?
Daniel Tabuenca
@dtabuenc
Dec 06 2016 20:38 UTC
yes
you can get all the types just fine
even if you use import
the problem is for things like Map
because they are declared inside a module inside the d.ts. file
jacobus-brogly
@jacobus-brogly
Dec 06 2016 20:39 UTC
yeah I would need to rename it or change the d.ts file
yeah fuck man
Daniel Tabuenca
@dtabuenc
Dec 06 2016 20:39 UTC
so quick question... how do you use Map without ts ?
is it just available globally?
jacobus-brogly
@jacobus-brogly
Dec 06 2016 20:40 UTC
yeah
Map is part of js
Daniel Tabuenca
@dtabuenc
Dec 06 2016 20:40 UTC
but you don't have to require it ?
is that because of the adapter you are using?
jacobus-brogly
@jacobus-brogly
Dec 06 2016 20:40 UTC
well in tsconfig i specify "es6"
Daniel Tabuenca
@dtabuenc
Dec 06 2016 20:40 UTC
no I'm talking about if you weren't using typescript
how do you get ahold of the Map class ?
jacobus-brogly
@jacobus-brogly
Dec 06 2016 20:40 UTC
it is just there
Daniel Tabuenca
@dtabuenc
Dec 06 2016 20:41 UTC
so global?
jacobus-brogly
@jacobus-brogly
Dec 06 2016 20:41 UTC
yes
Daniel Tabuenca
@dtabuenc
Dec 06 2016 20:41 UTC
so in that case you could do something like
declare const Map : Map;
I'm not sure if you will run into conflicts
jacobus-brogly
@jacobus-brogly
Dec 06 2016 20:41 UTC
well yeah
but i can just change the d.ts file right?
Daniel Tabuenca
@dtabuenc
Dec 06 2016 20:42 UTC
yeah
you can make your own
that fits more with how you are using it
that d.ts. file is really assuming you are using everythying through AMD
jacobus-brogly
@jacobus-brogly
Dec 06 2016 20:42 UTC
but lets leave the Map for now
Daniel Tabuenca
@dtabuenc
Dec 06 2016 20:42 UTC
hence all the sub-modules
for any types... it will work
types won't generate requires if you use them on the right side (as types) and not the left( as value)
of a :
jacobus-brogly
@jacobus-brogly
Dec 06 2016 20:42 UTC
huh?
lets take this one step at a time
can i still use types without importing them via import?
Daniel Tabuenca
@dtabuenc
Dec 06 2016 20:43 UTC
so if you do
import Map = require('esri/Map');
var myMap: Map;
that won't issue a require in your transpiled code
you have to use the old-school import syntax
jacobus-brogly
@jacobus-brogly
Dec 06 2016 20:43 UTC
al so the second line is an alias
Daniel Tabuenca
@dtabuenc
Dec 06 2016 20:43 UTC
the only thing you can import directly is stuff defined in the 'esri' module
So you'd do something like
import {MapOptions} from 'esri';
import Map = require('esri/Map');
it's a cluster fuck I know.. but that's due to how they chose to do things.
but if you ever do new Map() it will issue a require
but one thing you can do is just map it to "external" or something in webpack
so that it ignores those requires
jacobus-brogly
@jacobus-brogly
Dec 06 2016 20:45 UTC
the first line would generate an emit to look for a module though?
Daniel Tabuenca
@dtabuenc
Dec 06 2016 20:45 UTC
no
typescript will always optimize the requires away
jacobus-brogly
@jacobus-brogly
Dec 06 2016 20:45 UTC
let me try
Daniel Tabuenca
@dtabuenc
Dec 06 2016 20:45 UTC
if you don't actually use any of the imports as value*
jacobus-brogly
@jacobus-brogly
Dec 06 2016 20:46 UTC
wtf does that mean
let map = new Map({})
i do this
let view = new MapView({})
and this
so
Daniel Tabuenca
@dtabuenc
Dec 06 2016 20:47 UTC
yeah so those would issue the require
jacobus-brogly
@jacobus-brogly
Dec 06 2016 20:47 UTC
wait
Daniel Tabuenca
@dtabuenc
Dec 06 2016 20:47 UTC
but you can map those as externals in webpack
jacobus-brogly
@jacobus-brogly
Dec 06 2016 20:47 UTC
its more like so
esriLoader.dojoRequire([
        'esri/Map',
        'esri/views/MapView',
        'dojo/domReady!'
        ],
     (xxxMap:Map, xxxMapView:MapView) => {
    // create map with the given options at a DOM node w/ id 'mapNode' 
    let map = new xxxMap({
       basemap: 'dark-gray'
    });
    let view = new xxxMapView({
so indeed Map and MapView are not directly used on right hand side
Daniel Tabuenca
@dtabuenc
Dec 06 2016 20:48 UTC
right you might be fine
if it doesn't issue the require you are fine
if it does, you just need to map those as external in webpack
jacobus-brogly
@jacobus-brogly
Dec 06 2016 20:48 UTC
ok lemmi try this
import Map = require("esri/Map");
is there a way to import Map as ESRIMap?
import {Map as ESRIMAP} from 'esri/Map'
like this?
Daniel Tabuenca
@dtabuenc
Dec 06 2016 20:49 UTC
import ESRIMAp = require("esri/Map")
jacobus-brogly
@jacobus-brogly
Dec 06 2016 20:49 UTC
ok
Daniel Tabuenca
@dtabuenc
Dec 06 2016 20:49 UTC
you can then addthis to your webpack:
externals: {
    'esri/Map': 'Map'
}
Steven
@stevekane
Dec 06 2016 20:50 UTC
well damn
just had an a-ha moment regarding webgl
Daniel Tabuenca
@dtabuenc
Dec 06 2016 20:50 UTC
what that does is it tells webpack that when someone requires('esri/Map') it will just return the global Map
Steven
@stevekane
Dec 06 2016 20:50 UTC
was doing something wrong for months..
jacobus-brogly
@jacobus-brogly
Dec 06 2016 20:50 UTC
i am not using webpack @dtabuenc
Daniel Tabuenca
@dtabuenc
Dec 06 2016 20:50 UTC
oh I thought you were... you using browserify?
I don't know if they have a similar way around it in browserify
jacobus-brogly
@jacobus-brogly
Dec 06 2016 20:51 UTC
now vscode is complaining
"cannot use new with an expression whos type lacks a call to construct signatue"
lolwut
ok this is weird
Daniel Tabuenca
@dtabuenc
Dec 06 2016 20:52 UTC
you might be using the api wrong I don't know
jacobus-brogly
@jacobus-brogly
Dec 06 2016 20:52 UTC
xxxxMap:ESRIMap
/esri/MAP does have a construct signatur
vs code will allow xxx = new Map (from esri)
but not new xxxxMap
in the d.ts file

declare module "esri/Map" {
  import Map = __esri.Map;
  export = Map;
}
Daniel Tabuenca
@dtabuenc
Dec 06 2016 20:56 UTC
it doesn't seem like you are using it right.
jacobus-brogly
@jacobus-brogly
Dec 06 2016 20:56 UTC
interface Map extends Accessor, LayersMixin {
    allLayers: Collection;
    basemap: Basemap;
    ground: Ground;
  }
Daniel Tabuenca
@dtabuenc
Dec 06 2016 20:56 UTC
var myNumber: number;

new myNumber() /// doesn't make sense
and that's what you are doing....
jacobus-brogly
@jacobus-brogly
Dec 06 2016 20:56 UTC
yeah basicly
so this is stupid
Daniel Tabuenca
@dtabuenc
Dec 06 2016 20:57 UTC
var xxxMap: ESRIMap = new ESRIMap()
should work
but you can't turn around and do
new xxxMap()
that doesn't make sense
jacobus-brogly
@jacobus-brogly
Dec 06 2016 20:58 UTC
that would emit to require the module right
?
something we dont want?
because we only have the types?
the transpiled code looks like this
"use strict";
var MapView = require("esri/views/MapView");
var ESRIMap = require("esri/Map");
ok, i guess i cant work with ESRI types,
or something smart must be done with the module system
Daniel Tabuenca
@dtabuenc
Dec 06 2016 21:01 UTC
import esri = require("esri");
import MapType= require("esri/Map");

declare const Map: {new(): MapType};
declare type Map = MapType;
new Map();
you have to declare them as globals like that.
that should transpile to just
new Map();
you can put those declarations in a global place somewhere
in a d.ts
like this:
declare const Map: {new(): __esri.Map};
declare type Map = __esri.Map;
jacobus-brogly
@jacobus-brogly
Dec 06 2016 21:04 UTC
there are a lot of other things on esri/Map other then the new
Daniel Tabuenca
@dtabuenc
Dec 06 2016 21:04 UTC
and that will make Map available throughout your application
and then don't use imports
jacobus-brogly
@jacobus-brogly
Dec 06 2016 21:05 UTC
ok so the "new" will be solved
what about other props on the Map object?
Daniel Tabuenca
@dtabuenc
Dec 06 2016 21:05 UTC
it should have them
var myMap = new Map();
var allLayers = myMap.allLayers;
so you basically have to define the global constructors
jacobus-brogly
@jacobus-brogly
Dec 06 2016 21:06 UTC
but if i call them then it will emit a search for the "esri/Map" module?
Daniel Tabuenca
@dtabuenc
Dec 06 2016 21:06 UTC
as ambient global constants
no
there will be no emit because you are no longer doing imports
you are just making things available globally
you can use imports for types still though.. and that should work
jacobus-brogly
@jacobus-brogly
Dec 06 2016 21:07 UTC
i can use declare in the same ts file?
Daniel Tabuenca
@dtabuenc
Dec 06 2016 21:07 UTC
just have to declare any global constructors as ambient
you can but if you are going to use it in multiple places you should put it globally
jacobus-brogly
@jacobus-brogly
Dec 06 2016 21:07 UTC
i can use declare in the same ts file?
Kirill Cherkashin
@kirjs
Dec 06 2016 21:10 UTC
Hi all, I'm using TS browser compiler, and I set declarations: true in the compilerOptions
jacobus-brogly
@jacobus-brogly
Dec 06 2016 21:10 UTC
@dtabuenc ok so far so good
Kirill Cherkashin
@kirjs
Dec 06 2016 21:11 UTC
  return ts.transpileModule(code, {
              compilerOptions: {
              // ...
                declaration: true,
And now I can't find the declarations anywhere
jacobus-brogly
@jacobus-brogly
Dec 06 2016 21:11 UTC
but new __esri.Map(..) takes arguments
declare const ESRIMap: {new(): __esri.Map};
new ESRIMap() works
but new ESRIMap({some args}) gives an error, says doesnt match signature
declare const ESRIMap: {new(a:any): __esri.Map};
this seems to work
Daniel Tabuenca
@dtabuenc
Dec 06 2016 21:14 UTC
you should do
{ new (properties?: MapProperties):  __esri.Map}
or actually
jacobus-brogly
@jacobus-brogly
Dec 06 2016 21:14 UTC
now I have to include MapProperties, lol
Daniel Tabuenca
@dtabuenc
Dec 06 2016 21:15 UTC
declare const Map: __esri.MapConstructor;
declare type Map = __esri.Map
jacobus-brogly
@jacobus-brogly
Dec 06 2016 21:15 UTC
this sucks basicly I am re-defining the d.ts locally in my ts file
mm
thats nicer
Daniel Tabuenca
@dtabuenc
Dec 06 2016 21:15 UTC
no you are just hhoisting a few types outside of the modules
and making them available globally since that's what the commonjs "adapter" seems to be doing
jacobus-brogly
@jacobus-brogly
Dec 06 2016 21:16 UTC
declare const ESRIMap:  __esri.MapConstructor;
declare type ESRIMap = __esri.Map;
declare const MapView: __esri.MapViewConstructor;
declare type MapView = __esri.MapView;
new MapView doesnt work
new ESRIMap does work even with arguments
i guess the MapViewConstructor was a wrong guess
Daniel Tabuenca
@dtabuenc
Dec 06 2016 21:19 UTC
it worked for me
I wouldn't do ESRIMap
you can't rename it
just use Map
you have to use whatever name you would use in the js
jacobus-brogly
@jacobus-brogly
Dec 06 2016 21:19 UTC
Map is only an internal model
MapView displays the map
 let view = new MapView({
       container:'mapNode',
       map:map,
       center:[6,47],
       zoom:12,
      // ui:{
      //     components:[]
      // } 
    });
oh shit
corrected
thisdoesnt work
Map works and also compiles)
your esri/Map i mean
thanks @dtabuenc
Steven
@stevekane
Dec 06 2016 21:22 UTC
he deserves a medal for that assist
jacobus-brogly
@jacobus-brogly
Dec 06 2016 21:22 UTC
big cookie
 interface MapViewConstructor {
    new(properties?: MapViewProperties): MapView;
  }
MapViewConstructor DOES have a new
so weird
Daniel Tabuenca
@dtabuenc
Dec 06 2016 21:23 UTC
good thing I'm not in europe... aren't cookies illegal there?
Steven
@stevekane
Dec 06 2016 21:23 UTC
so is fun
jacobus-brogly
@jacobus-brogly
Dec 06 2016 21:23 UTC
HAHAHAHA
Steven
@stevekane
Dec 06 2016 21:23 UTC
from what I've heard
jacobus-brogly
@jacobus-brogly
Dec 06 2016 21:23 UTC
cookie law
lots of things are illegal here
but we are all leaving the EU
Nexit, Grexit, brexit, frexit
the even have standards for cucumbers
Steven
@stevekane
Dec 06 2016 21:25 UTC
total European pop + total american pop < total chinese pop
this sounds great
jacobus-brogly
@jacobus-brogly
Dec 06 2016 21:25 UTC
has to be a minimum size,seriously these ppl have nithing to do
chinese pop?
Steven
@stevekane
Dec 06 2016 21:25 UTC
population
jacobus-brogly
@jacobus-brogly
Dec 06 2016 21:25 UTC
well, with the one-child policy that wont last long
Steven
@stevekane
Dec 06 2016 21:26 UTC
that's all but dissolved
jacobus-brogly
@jacobus-brogly
Dec 06 2016 21:26 UTC
chinese can breed again
Steven
@stevekane
Dec 06 2016 21:26 UTC
Most Euro economy smaller than California economy
:worried:
jacobus-brogly
@jacobus-brogly
Dec 06 2016 21:26 UTC
why is California bankrupt then?
well there is the PIGS, they dont like to work hard
dont blame them
Steven
@stevekane
Dec 06 2016 21:27 UTC
don't think it's any fault of European eco, just facts
regarding size
if EU dissolves you're individually tiny players
compared to Asia
doesn't sound awesome
jacobus-brogly
@jacobus-brogly
Dec 06 2016 21:28 UTC
no-one cares
EU != trade
its political
EEC= trade
Steven
@stevekane
Dec 06 2016 21:28 UTC
ah
jacobus-brogly
@jacobus-brogly
Dec 06 2016 21:29 UTC
trade is ok, being ruled by unelected burocrats , no
seems like this article indicates the EEC is defunct, absorbed by the EU
but I'm out of my depth here big-time
jacobus-brogly
@jacobus-brogly
Dec 06 2016 21:29 UTC
yes, some time ago
i say re-instate it
and diff countries have diff languages anywya
let China be big who cares
Steven
@stevekane
Dec 06 2016 21:30 UTC
<- this guy
lol
jacobus-brogly
@jacobus-brogly
Dec 06 2016 21:30 UTC
aslong as we can take care of ourselves
Netherlands had aerospace, (Fokker), Philips, ASML , Shell, Azo
etc etc etc
for a tiny country thats good enough
Steven
@stevekane
Dec 06 2016 21:31 UTC
I just think that when 1 player is orders of magnitude your size
jacobus-brogly
@jacobus-brogly
Dec 06 2016 21:31 UTC
these are all Dutch companies, if you see
Steven
@stevekane
Dec 06 2016 21:31 UTC
politically and economically
you're asking for trouble
in general
jacobus-brogly
@jacobus-brogly
Dec 06 2016 21:31 UTC
I dont think so
we dont have to be in superstates to balance each other out
fallacy
Steven
@stevekane
Dec 06 2016 21:31 UTC
shrug
I don't agree but I'm just a pragmatist
jacobus-brogly
@jacobus-brogly
Dec 06 2016 21:32 UTC
shrug shrug
no you are an ideologue
Steven
@stevekane
Dec 06 2016 21:32 UTC
haha that's quite the assertion for knowing someone in the vaguest possible way
jacobus-brogly
@jacobus-brogly
Dec 06 2016 21:32 UTC
just your reasoning, its mystical
Steven
@stevekane
Dec 06 2016 21:32 UTC
I mean, that's pretty staggeringly over-reaching
jacobus-brogly
@jacobus-brogly
Dec 06 2016 21:33 UTC
and devoid of historical reality
Steven
@stevekane
Dec 06 2016 21:33 UTC
lol..
ok
jacobus-brogly
@jacobus-brogly
Dec 06 2016 21:33 UTC
China had 80% of the world trade in the 19th century
didnt invade anyone
Steven
@stevekane
Dec 06 2016 21:33 UTC
o ya?
jacobus-brogly
@jacobus-brogly
Dec 06 2016 21:33 UTC

facts

Steven
@stevekane
Dec 06 2016 21:34 UTC
Opium War?
I mean :/ this conversation has taken a useless turn
jacobus-brogly
@jacobus-brogly
Dec 06 2016 21:34 UTC
that was the Brits invading China
not China invading someone else
Daniel Tabuenca
@dtabuenc
Dec 06 2016 21:34 UTC
Oh man... can we get back to typescript?
Steven
@stevekane
Dec 06 2016 21:34 UTC
haha ya
I gotta get off this boat
didn't know you were so opinionated
jacobus-brogly
@jacobus-brogly
Dec 06 2016 21:35 UTC
@stevekane making shit up is not usefull
@stevekane no its called "i like facts"
Kris Thomsen
@kristho91
Dec 06 2016 21:35 UTC
Damn people, be nice :)
jacobus-brogly
@jacobus-brogly
Dec 06 2016 21:36 UTC
yes, well lets get off the topic "globalism is fun"
and get back to coding))
some people need to be part of a big empire to feel important or something.. "big" "small" bladibla
export const MapView: MapViewConstructor;
interface MapViewConstructor { new(properties?: MapViewProperties): MapView; }
interface MapView extends View {
    center: Point;
    constraints: MapViewConstraints;
    extent: Extent;
    resizeAlign: string;
    rotation: number;
    scale: number;
    viewpoint: Viewpoint;
    zoom: number;

    goTo(target: number[] | Geometry | Geometry[] | Graphic | Graphic[] | Viewpoint | any, options?: MapViewGoToOptions): IPromise<any>;
    hitTest(screenPoint: ScreenPoint): IPromise<any>;
    toMap(screenPoint: ScreenPoint, mapPoint?: Point): Point;
    toScreen(point: Point, screenPoint?: ScreenPoint): ScreenPoint;
  }
ok these 3 codesnippets
so mapview is a constructor aswell?
jacobus-brogly
@jacobus-brogly
Dec 06 2016 21:42 UTC
ok this works and compiles
declare const ESRIMap:  __esri.MapConstructor;
declare type ESRIMap = __esri.Map;
declare const ESRIMapView: __esri.MapViewConstructor;
declare type ESRIMapView = __esri.MapView;
I needed to rename to ESRI prepend for it to work
Kris Thomsen
@kristho91
Dec 06 2016 21:57 UTC
What are your thoughts on having a static "name" on f.ex Angular 1.5 services - to not use "magic strings"? Do or Don't? :D
Daniel Tabuenca
@dtabuenc
Dec 06 2016 21:58 UTC
do you reuse that anywhere?
if not don't.
if you reuse the same string then consider it
Kris Thomsen
@kristho91
Dec 06 2016 21:59 UTC
I have some services that I use in multiple modules and multiple controllers - but inside the same app
Daniel Tabuenca
@dtabuenc
Dec 06 2016 22:36 UTC
are you talking about magic strings for dependency injection?
the ones you put in an array before your function?
Sharon (Sean) Rolel
@srolel
Dec 06 2016 22:50 UTC
do I have a way to have generic typing for arguments?
function<T>(...args: T) {}
where T is not an array
jacobus-brogly
@jacobus-brogly
Dec 06 2016 23:09 UTC
hi
I am using jsx in my main.tsx
it compiles correctly with gulp, no problem
but my vs code is complaining the --jsx flag is not enabled
wtf?
"Cannot use JSX unless --jsx flag is provided"
Daniel Tabuenca
@dtabuenc
Dec 06 2016 23:13 UTC
@Mosho1 you need to do
function<T>(...args: T[] ) {
}
where T is NOT an array
jacobus-brogly
@jacobus-brogly
Dec 06 2016 23:13 UTC
``` let mainWindow = React.createClass({
             render: function(){
                 return <div></div>;
             } 
    });```
hello?
Daniel Tabuenca
@dtabuenc
Dec 06 2016 23:17 UTC
wha't's your tsconfig look like?
jacobus-brogly
@jacobus-brogly
Dec 06 2016 23:17 UTC
{
  "files": [
    "src/client/*.tsx",
    "src/client/*.ts",
    "src/client/*.d.ts"
  ],
  "compilerOptions": {
    "strictNullChecks": true,
    "noImplicitAny": true,
    "target": "es5",
    "jsx": "react",
    "lib": ["es6", "dom"],
    "module": "commonjs",
    "sourceMap": true,
    "moduleResolution": "node",
    "outDir": "dist/server/js"
  }
}
kindof ok i think
Daniel Tabuenca
@dtabuenc
Dec 06 2016 23:22 UTC
yeah looks fine
you have @types/react and @types/react-dom installed?
jacobus-brogly
@jacobus-brogly
Dec 06 2016 23:22 UTC
sure
Daniel Tabuenca
@dtabuenc
Dec 06 2016 23:22 UTC
and try closing the tab and re-opening
jacobus-brogly
@jacobus-brogly
Dec 06 2016 23:23 UTC
ok
jacobus-brogly
@jacobus-brogly
Dec 06 2016 23:29 UTC
I restarted vcode, now there is no intellisense at all
lols
jacobus-brogly
@jacobus-brogly
Dec 06 2016 23:42 UTC
ok
[ts] Cannot use JSX unless the '--jsx' flag is provided.
(property) JSX.IntrinsicElements.div: React.HTMLProps<HTMLDivElement>
this is the error
note it does compile
jacobus-brogly
@jacobus-brogly
Dec 06 2016 23:56 UTC
ok everything works except the jsx parts of the code are in red