Forking this from another thread because I ran into Typescript issues...
What's been tripping me up has been using Typescript for my latest web development explorations.
When I write the following line in Typescript...
<SPAN class="keyword token">let</SPAN> params <SPAN class="operator token">=</SPAN> urlUtils<SPAN class="punctuation token">.</SPAN><SPAN class="token function">urlToObject</SPAN><SPAN class="punctuation token">(</SPAN>document<SPAN class="punctuation token">.</SPAN>location<SPAN class="punctuation token">.</SPAN>href<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
...it compiles to this in Javascript...
<SPAN class="keyword token">let</SPAN> params <SPAN class="operator token">=</SPAN> urlUtils_1<SPAN class="punctuation token">.</SPAN><SPAN class="keyword token">default</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">urlToObject</SPAN><SPAN class="punctuation token">(</SPAN>document<SPAN class="punctuation token">.</SPAN>location<SPAN class="punctuation token">.</SPAN>href<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
and inserts a "default". Apparently, the browser doesn't care about the "_1" (underscore1). I've read a little about it and it seems to be innocuous. But it never assigns the URL info to params. If I tweak my compiled Javascript and remove the extra "default", it runs fine.
In the Dev Tools console, I see (background for what I was doing are in the above reference thread.)
>query.where
<{__accessor__: b}
>query.where
<"LOCNO = '12345'><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>So how can I get my Typescript to not mess up the Javascript? Something I need to tweak in my tsconfig.json?
This is what mine looks like:
{
"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"
]
}<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>