Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using "resolveJsonModule: true" causes drastic compilation error #25216

Closed
ORESoftware opened this issue Jun 26, 2018 · 2 comments
Closed

Using "resolveJsonModule: true" causes drastic compilation error #25216

ORESoftware opened this issue Jun 26, 2018 · 2 comments
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@ORESoftware
Copy link

ORESoftware commented Jun 26, 2018

I am on: Version 2.9.1

So I have this project, with lib and dist and "outDir":"dist" and "include": ["lib"] ...
that means the only thing that ends up in dist, should be what's in lib, right?

https://github.com/ORESoftware/npm-link-up

This project has a single straightforward tsconfig.json file.

How to replicate the problem :

  1. git clone https://github.com/ORESoftware/npm-link-up.git
  2. rm -rf dist
  3. tsc
  4. dist should have some 20+ files in it. These files are the correct files.
  5. rm -rf dist
  6. change "resolveJsonModule": false, to "resolveJsonModule": true
  7. tsc
  8. now dist should have about 3 files in it. These files are the incorrect files.

I would assume that "resolveJsonModule": true would not do that much except allow you to do:

import json = require('../../my.file.json');
const jsonType = typeof json;

I don't see why it should have such a drastic affect on what goes from lib into dist.

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Jun 26, 2018
@mhegazy
Copy link
Contributor

mhegazy commented Jun 26, 2018

when you use "resolveJsonModule": true you are telling the compiler to include the .json files imported from your .ts files as part of your project. the files will be emitted to the output, just like all your .ts/.tsx files.

The addition of new files not under lib results in the output folder structure changing.. see more details about this in https://github.com/Microsoft/TypeScript/wiki/FAQ#why-does---outdir-moves-output-after-adding-a-new-file

@mhegazy mhegazy added Working as Intended The behavior described is the intended behavior; this is not a bug and removed Needs Investigation This issue needs a team member to investigate its status. labels Jun 26, 2018
@typescript-bot
Copy link
Collaborator

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

4 participants