agelfert

Compiling Typescript to JS.... "default" inserts are tripping me up.

Discussion created by agelfert on Apr 10, 2019
Latest reply on Apr 11, 2019 by agelfert
Branched from an earlier discussion

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...

 let params = urlUtils.urlToObject(document.location.href);

...it compiles to this in Javascript...

let params = urlUtils_1.default.urlToObject(document.location.href);

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'>

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"
    ]
  }

Outcomes