Skip to content

tsconfig target option is ignored -- use browserslist for Babel instead #951

@thany

Description

@thany

Current Behavior

Modern code is not getting transpiled to the target specified in tsconfig.json.

Expected behavior

It should respect the target option and transpile to that.

Suggested solution(s)

I dunno, if target is undiserable or whatever, maybe respect browserslist in package.json? Because that it also doesn't do. Otherwise it should just pick up target in tsconfig.json. Or I guess it should pick up something, anything, in order to make transpilation happen to a target of my choosing.

Additional context

Currently it does only very moderate transpilation, for instance a ?? b is transpiled, but { ...a, ...b } is not. Even setting target to a ridiculous es3 doesn't transpile any more (or less) than setting it to esnext. There should be some difference between the two, wouldn't you say?

So it is transpiling to some kind of target, but which one?... I don't know, but not my target, that's for sure.

Your environment

  System:
    OS: Windows 10 10.0.19042
    CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
    Memory: 10.66 GB / 31.76 GB
  Binaries:
    Node: 12.20.0 - C:\Program Files\nodejs\node.EXE
    npm: 6.14.9 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 87.0.4280.88
    Edge: Spartan (44.19041.423.0), Chromium (87.0.664.66)
    Internet Explorer: 11.0.19041.1
  npmPackages:
    tsdx: 0.14.1 => 0.14.1
    typescript: 3.8.3 => 3.8.3

Why are these scripts never seeing my Firefox browser? 🤨
Anyway, maybe it also helps to see my tsconfig.json:

{
  "include": ["src", "types"],
  "compilerOptions": {
    "target": "es5",
    "module": "esnext",
    "lib": ["dom", "esnext", "es2017"],
    "importHelpers": true,
    "declaration": true,
    "downlevelIteration": true,
    "sourceMap": true,
    "rootDir": "./",
    "strict": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "strictFunctionTypes": true,
    "strictPropertyInitialization": true,
    "noImplicitThis": true,
    "alwaysStrict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "moduleResolution": "node",
    "baseUrl": "./",
    "paths": {
      "*": ["src/*", "node_modules/*"]
    },
    "jsx": "react",
    "esModuleInterop": true
  }
}

To the question "why do you need this?" I can answer simply: because I need to test stuff in this library on old browsers. Maybe libraries should not be transpiled. Maybe they should be. But that is an opinion not quite relevant to this issue. Just wanted to get that off the tables.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind: questionThis is a usage or similar questionkind: supportAsking for support with something or a specific use caseproblem: no reproNo reproduction was provided (and have not tried to repro without one)problem: staleIssue has not been responded to in some timesolution: intended behaviorThis is not a bug and is expected behavior

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions