question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

tsdx ignores tsconfig.json "extends" keyword

See original GitHub issue

Current Behavior

There’s an extends feature in tsconfig which allows configuration inheritance across multiple tsconfig files. This however isn’t recognized in tsdx, which parses tsconfig here:

https://github.com/jaredpalmer/tsdx/blob/4f6de1083393057903a1837fb6658f8058ee832f/src/createRollupConfig.ts#L46-L49

The JSON object is used as-is, instead of drilling up to resolve parent config.

Expected behavior

tsdx should process extends just like tsc does.

Suggested solution(s)

In a quick look through TypeScript’s source code I couldn’t find the place where extends is handled, but it’s possible that TypeScript’s exported tsconfig parsing functions might handle extends for us automatically. See https://github.com/microsoft/TypeScript/blob/760393f893358a462b00eef7e8fb92342b0f71ad/lib/typescript.d.ts#L3639-L3647 what what TS offers in its API. The implementation is here: https://github.com/Microsoft/TypeScript/blob/6487d1ffe0d903b1e55a187ddeb973fe0d445a2f/src/compiler/parser.ts#L717

Additional context

This problem is similar to #483 in that both this issue and that one are caused by parsing tsconfig differently than tsc does.

Your environment

Software Version(s)
TSDX tsdx@0.12.3
TypeScript typescript@3.7.5
Browser n/a (this is a build issue)
npm/Yarn yarn@1.21.1
Node v12.13.1
Operating System MacOS Catalina 10.15.2

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:20 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
agilgur5commented, Feb 4, 2020

ok. @agilgur5 we’re piling up quite a few PR’s for jared to review, lets slow down so that we dont swamp him with too much stuff.

@sw-yx think that might be the first time I’ve been asked to contribute less 🤔 🤔 🤔

1reaction
agilgur5commented, Feb 4, 2020

anyone want to tackle this?

Oh, I already did hah. @justingrant said he didn’t have time for this in https://github.com/jaredpalmer/tsdx/issues/483#issuecomment-581238335 so I made the solution myself (see above reference). Still need to add a test for the extends case, hence the draft, but will do that in a day or few as I have to focus on some other things

Read more comments on GitHub >

github_iconTop Results From Across the Web

TSConfig Reference - Docs on every TSConfig option
The value of extends is a string which contains a path to another configuration file to inherit from. The path may use Node.js...
Read more >
How to compile tsconfig.json into a config object using ...
A function to read compiler options from a tsconfig file while correctly handling tsconfig extends keyword inheritance
Read more >
VS 15.6 ignores tsconfig.json and TypeScriptCompileBlocked
After updating to 15.6 it appears our tsconfig.json seems to be ignored (we are targeting Typescript 2.6). This results in that modules cannot...
Read more >
ts-loader - npm
The tsconfig.json file controls TypeScript-related options so that your IDE, the tsc command, and this loader all share the same options.
Read more >
Rollpkg NPM | npm.io
tsconfig.json { "extends": "rollpkg/configs/tsconfig.json" } ... Note that you can write your entire code in index.ts or index.tsx if you only need one...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found