<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Compiling Typescript to JS.... &amp;quot;default&amp;quot; inserts are tripping me up. in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/compiling-typescript-to-js-quot-default-quot/m-p/631452#M58926</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Okay. Here is what worked for me. It doesn't make complete sense to me but it solved my problem.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Typescript compiler options are explained &lt;A href="http://www. https//www.typescriptlang.org/docs/handbook/compiler-options.html"&gt;here&lt;/A&gt;. For -- esModuleInterOp&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-1 jive-image" height="116" src="https://community.esri.com/legacyfs/online/441880_esModuleInterOp.png" width="683" /&gt;&lt;/P&gt;&lt;P&gt;So the defaults is&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;false.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;In my tsconfig this was true. So I changed it to false and tried with both&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;"target" : "es5", and then&lt;/P&gt;&lt;P&gt;"target" : "es6"&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Both result in: &lt;STRONG&gt;Uncaught TypeError: Map_1.default is not a constructor&lt;/STRONG&gt;&lt;BR /&gt; .&lt;/P&gt;&lt;P&gt;Next, I compared --esModuleInterop: false using either "es5" or "es6". Here, I get no errors but my code is ignored as before.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Finally, I&amp;nbsp;came across &lt;A href="https://github.com/Esri/jsapi-resources/issues/37#issuecomment-261120031"&gt;this thread&lt;/A&gt; saying there are no default exports included for arcgis-js-api typings.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Aha, so I switched my lovely imports from:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;import Map from "esri/Map";&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;back to:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;import Map = require( "esri/Map");&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Problem solved. (Although I'm back to requires.)&lt;/P&gt;&lt;P&gt;This &lt;A href="https://github.com/Esri/jsapi-resources/issues/37#issuecomment-264257699"&gt;suggestion &lt;/A&gt;("workaround") sounded promising but didn't work for me. I think it must reference an earlier version of the API. Or maybe I misunderstood? Maybe a typo?&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;import arcgisUtils from 'esri/arcgis/utils';&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I'm still somewhat confused by the whole export process and targeting different JS flavors. But I guess that's just the state of things right now.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 11 Apr 2019 19:17:41 GMT</pubDate>
    <dc:creator>Arne_Gelfert</dc:creator>
    <dc:date>2019-04-11T19:17:41Z</dc:date>
    <item>
      <title>Compiling Typescript to JS.... "default" inserts are tripping me up.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/compiling-typescript-to-js-quot-default-quot/m-p/631451#M58925</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Forking this from &lt;A _jive_internal="true" href="https://community.esri.com/thread/231894-how-to-create-an-external-link-to-jsapi-web-map-that-zooms-into-a-specific-feature" target="_blank"&gt;another thread&lt;/A&gt; because I ran into Typescript issues...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What's been tripping me up has been using Typescript for my latest web development explorations.&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I write the following line in Typescript...&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt; &lt;SPAN class="keyword token"&gt;let&lt;/SPAN&gt; params &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; urlUtils&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;urlToObject&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;document&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;location&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;href&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;...it compiles to this in Javascript...&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;let&lt;/SPAN&gt; params &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; urlUtils_1&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;default&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;urlToObject&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;document&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;location&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;href&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and inserts a "default". Apparently, the browser doesn't care about the "_1" (underscore1). I've read a little about it and it &lt;A href="https://github.com/Microsoft/TypeScript/issues/6264" rel="nofollow noopener noreferrer" target="_blank"&gt;seems to be innocuous&lt;/A&gt;.&amp;nbsp; But&amp;nbsp;it never assigns the URL info to params. If I tweak my compiled Javascript and remove the extra "default", it runs fine.&lt;/P&gt;&lt;P&gt;In the Dev Tools&amp;nbsp;console, I see (background for what I was doing are in the above reference thread.)&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&amp;gt;query.where
&amp;lt;{__accessor__: b}
&amp;gt;query.where
&amp;lt;"LOCNO = '12345'&amp;gt;‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So how can I get my Typescript to not mess up&amp;nbsp;the Javascript? Something I need to tweak in my tsconfig.json?&lt;/P&gt;&lt;P&gt;This is what mine looks like:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;{
    "compilerOptions": {
      "module": "amd",
      "target": "es6",
      "esModuleInterop": true,

      "noImplicitAny": true,
      "sourceMap": false, 
      "jsx": "react",
      "jsxFactory": "tsx",

      //"allowSyntheticDefaultImports": true, 
      //"maintainModuleNames" : true, 

      "experimentalDecorators": true,
      "preserveConstEnums": true,
      "suppressImplicitAnyIndexErrors": true
    },
    "include": [
      "./app/*"
    ],
    "exclude": [
      "node_modules"
    ]
  }&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:51:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/compiling-typescript-to-js-quot-default-quot/m-p/631451#M58925</guid>
      <dc:creator>Arne_Gelfert</dc:creator>
      <dc:date>2021-12-12T02:51:59Z</dc:date>
    </item>
    <item>
      <title>Re: Compiling Typescript to JS.... "default" inserts are tripping me up.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/compiling-typescript-to-js-quot-default-quot/m-p/631452#M58926</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Okay. Here is what worked for me. It doesn't make complete sense to me but it solved my problem.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Typescript compiler options are explained &lt;A href="http://www. https//www.typescriptlang.org/docs/handbook/compiler-options.html"&gt;here&lt;/A&gt;. For -- esModuleInterOp&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-1 jive-image" height="116" src="https://community.esri.com/legacyfs/online/441880_esModuleInterOp.png" width="683" /&gt;&lt;/P&gt;&lt;P&gt;So the defaults is&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;false.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;In my tsconfig this was true. So I changed it to false and tried with both&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;"target" : "es5", and then&lt;/P&gt;&lt;P&gt;"target" : "es6"&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Both result in: &lt;STRONG&gt;Uncaught TypeError: Map_1.default is not a constructor&lt;/STRONG&gt;&lt;BR /&gt; .&lt;/P&gt;&lt;P&gt;Next, I compared --esModuleInterop: false using either "es5" or "es6". Here, I get no errors but my code is ignored as before.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Finally, I&amp;nbsp;came across &lt;A href="https://github.com/Esri/jsapi-resources/issues/37#issuecomment-261120031"&gt;this thread&lt;/A&gt; saying there are no default exports included for arcgis-js-api typings.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Aha, so I switched my lovely imports from:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;import Map from "esri/Map";&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;back to:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;import Map = require( "esri/Map");&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Problem solved. (Although I'm back to requires.)&lt;/P&gt;&lt;P&gt;This &lt;A href="https://github.com/Esri/jsapi-resources/issues/37#issuecomment-264257699"&gt;suggestion &lt;/A&gt;("workaround") sounded promising but didn't work for me. I think it must reference an earlier version of the API. Or maybe I misunderstood? Maybe a typo?&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;import arcgisUtils from 'esri/arcgis/utils';&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I'm still somewhat confused by the whole export process and targeting different JS flavors. But I guess that's just the state of things right now.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Apr 2019 19:17:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/compiling-typescript-to-js-quot-default-quot/m-p/631452#M58926</guid>
      <dc:creator>Arne_Gelfert</dc:creator>
      <dc:date>2019-04-11T19:17:41Z</dc:date>
    </item>
  </channel>
</rss>

