-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Provide an API to convert tsconfig.json to CompilerOptions #5276
Comments
here you go: https://github.com/Microsoft/TypeScript/blob/master/lib/typescript.d.ts#L1536-L1555 use |
Awesome. That's what I need. Is the filename option significant? We also have a use case where the configuration is an object already in the tsconfig format, so I would just serialize it and pass it in as text with bogus filename. Will there be any problems with that? |
in parseConfigFileTextToJson the name is used only for the error message. in parseJsonConfigFileContent basePath is expected to be the location of the tscongfig, as all files path in the options are considered relative to the file location. |
I tried using All I want is:
Could that be a thing? |
I don't see why not, we already have this code as nested function of function convertConfigToCompilerOptions(opts) {
var parsed = ts.parseJsonConfigFileContent({
compilerOptions: opts,
// if files are not specified then parseJsonConfigFileContent
// will use ParseConfigHost to collect files in containing folder
files: []
},
// we don't do any file lookups - host and base folders should not be used
undefined,
undefined);
return parsed.options;
} |
That worked! It's a bit awkward, but it works. Thanks Vladimir. On Sat, Oct 17, 2015 at 4:49 PM Vladimir Matveev [email protected]
|
@IgorMinar |
@mhegazy @vladima This is getting pretty frustrating; it just broke again. Here's what we had to do to get it working on Can you recommend a stable API we can use? |
See also tildeio/broccoli-typescript-compiler#7. We're very eager to get on a supported, stable path here, but can't seem to find one. |
@wycats apologies, this breaking change was not intentional. I'll revert |
@vladima is there any way we can get the tests of this functionality to be considered regressions, so people don't just change them at the same time as the functionality? Maybe a note in the tests? |
I'll add tests on our side to make sure that public surface of the API is not changed in an unexpected way |
@vladima Unfortunately the |
You can just supply a simple ts.ParseConfigHost implementation, it's only a
couple methods.
…On Sun, Dec 10, 2017 at 11:50 AM Martin Johns ***@***.***> wrote:
@vladima <https://github.com/vladima> Unfortunately the host can't be set
to undefined anymore, as the type is not ts.ParseConfigHost | undefined.
I don't see a way to use this function anymore.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#5276 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAC5I4ANE6RLNU4xCzPJ1cHs21Rl-ikyks5s_DYagaJpZM4GP5TQ>
.
|
Since IDEs like VS Code use
tsconfig.json
to figure out how to parse a project, it makes sense for all the other build tools (gulp, broccoli, webpack, etc) to pull the tsc config fromtsconfig.json
as well, instead of having their own custom way to configure tsc.In order for this to be seamless, Typescript needs to provide a way to parse tsconfig.json to
CompilerOptions
object.tsc
already does this internally, but all of the apis it uses are private.I've put together my own converter for Angular/broccoli-typescript, but it will get stale with the next version of typescript until I update my option mappings. See
ts-config-converter.ts
added in angular/angular#4779I believe that this task is so common that it should be part of typescripts public api.
cc: @alexeagle
The text was updated successfully, but these errors were encountered: