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

Add support for tsconfig.json. #26

Closed
MicahZoltu opened this issue Jul 8, 2015 · 10 comments
Closed

Add support for tsconfig.json. #26

MicahZoltu opened this issue Jul 8, 2015 · 10 comments

Comments

@MicahZoltu
Copy link

https://github.com/Microsoft/TypeScript/wiki/tsconfig.json

tsconfig.json is the official project type for TypeScript projects. In particular, it is where compiler options are stored. In many situations, there may be several tools that are running the TypeScript compiler and they should all use the same options for a given project. In order for this to not become a maintenance nightmare, each of the tools should leverage a shared configuration file, which is tsconfig.json.

I would like to see SystemJS's TypeScript transpiler support tsconfig.json so I don't have to store my compiler options in two places.

@frankwallis
Copy link
Owner

This sounds reasonable, so I can add a setting to typescriptOptions tsconfig which will contain the path of a tsconfig.json file or just be set to true to load /tsconfig.json?

typeScriptOptions: {
  tsconfig: true,
  tsconfig: "/.settings/tsconfig.json",
  resolveAmbientRefs: true
}

@MicahZoltu
Copy link
Author

I'm guessing that a person would either use a tsconfig.json or provide the options through typeScriptOptions. I can't think of a situation where you would want to mix the two. I suppose if a user did want to override some settings it would probably be specific to runtime plugin, so maybe the merge strategy would be to pull in all of the information from tsconfig.json and then overwrite any explicit options provided via typeScriptOptions?

tsconfigPath: 'relative/path/to/tsconfig.json',
typeScriptOptions: {
    resolveAmbientRefs: true
}

I will admit, I haven't really thought this through very hard, I just started using the typescript plugin with SystemJS and the first thing I looked into was using my existing tsconfig.json settings since I already have those setup so my IDE can correctly do type checking.

@sarith
Copy link

sarith commented Jul 23, 2015

+1 for @Zoltu's recommendation above. Seems to make the most sense intuitively.

@ghost
Copy link

ghost commented Jul 27, 2015

+1 so I don't have to use relative paths everywhere.

When you are levels deep. having ../../../ sucks.

@ghost
Copy link

ghost commented Jul 29, 2015

@frankwallis if tsconfig support is supported, would this be possible using in browser compilation?

src/app.ts

then src/module/component/comp1/comp1.ts import {default as d} from 'app'; work?

Right now you must do `import {default as d} from '../../../app'; with this plugin. compiling with the ts compiler and the tsconfig doesn't do it.

@frankwallis
Copy link
Owner

@robertbaker - I am not sure if this works even when building with the TypeScript compiler, it seems to me that the code would fail at runtime unless the compiler rewrites the import in the generated JavaScript to point to the correct file. Support for resolution mappings is being handled under microsoft/TypeScript#2338.

Currently my plan for tsconfig support is just to load the compiler options (which will actually just be the subset of the options which do not conflict with those used by plugin-typescript) and to use it to automatically load any reference files contained in the 'files' array.

@cherrydev
Copy link

Just my $0.02 about having both tsconfig and specifying compiler options: The command-line tsc supports this specifically, with command line options overriding options in the tsconfig file.

@basarat
Copy link

basarat commented Oct 12, 2015

I prefer tsconfig: /path/to/tsconfig. There is discussion about this here : TypeStrong/discussions#1 🌹

@frankwallis
Copy link
Owner

Ok I have finally added tsconfig.json support (in 2.1.0), you can use

tsconfig: true

to load from "tsconfig.json", or set it to a path which will be resolved to locate the file:

tsconfig: "config/mytsconfig.json"

The plugin loads compiler options and declaration files from the files array when type-checking is enabled. I have updated some of the examples to show it working. Let me know if you have any problems, thanks.

@basarat
Copy link

basarat commented Oct 14, 2015

awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants