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

Initial work on getting support for "extends". #494

Merged
merged 6 commits into from
Jun 20, 2017

Conversation

lddubeau
Copy link
Contributor

@lddubeau lddubeau commented Mar 4, 2017

This is an initial stab at solving #459.

It passes the test suite but I would not be surprised if I goofed somewhere though. In particular I'm not sure that I got the option checks and normalization performed in main.ts right.

@ivogabe
Copy link
Owner

ivogabe commented Mar 7, 2017

Good work @lddubeau! This looks like a good implementation. Could you add a testcase for this?

I'm also wondering how files, include and exclude should work. Could you try what tsc does with those settings? So basically, if a tsconfig file (referenced in the extends field) provides files, include or exclude, should that be propagated?

Have you checked whether TypeScript exposes some function that can be used here? This PR contains some logic which is already present in TypeScript. If possible I'd like to prevent duplicating that logic. (However, it might be more work to apply to that API then to do it this way..)

@lddubeau
Copy link
Contributor Author

@ivogabe I should have some time to revisit this today or tomorrow.

Yep, a test case is on the todo list.

The semantics for what happens to files, include and exclude when extends is used are defined on this page:

files, include and exclude from the inheriting config file overwrite those from the base config file.

parseJsonConfigFileContent will apply the semantics above. Is this a problem for gulp-typescript?

It does look like I'm doing some things that could be handled by TypeScript's own code.

@ivogabe
Copy link
Owner

ivogabe commented Mar 11, 2017

@lddubeau I've taken a look at the API which TypeScript exposes, and parseJsonConfigFileContent looks like the best approach. I think that you can even remove shallowAssign completely (after commit 6df5043) but I might be mistaken.

Gulp-typescript should have the same semantics related to files, include and exclude as tsc, so using parseJsonConfigFileContent is not a problem.

@lddubeau
Copy link
Contributor Author

lddubeau commented Mar 11, 2017

Regarding shallowAssign I'm still using it in one place to copy the settings passed into the plugin. They are going to be modified and I prefer not to have the modification leak outside. I could use an object spread but these were introduced in 2.1 and would peg the minimum version supported by the plugin to 2.1. Or I guess I could remove shallowAssign if the settings passed to the plugin are deemed to belong to the plugin. Originally there was a shallow copy done but it was done as part of checking the settings.


I ran into a bigger issue than I was expecting. I did not realize this at first but support for extends in tsconfig.json is a TS 2.1 feature. I thought it went back to 2.0.

So there should be a bump in the versions against which gulp-typescript is tested. Maybe, 2.0, 2.1 and dev? Note that the current dev is at 2.1.0, which is buggy when it comes to extends support.

I don't know how to make the change required to bump the version testing. If you could do the version bump, I could rebase and then pick up from there.

@ivogabe
Copy link
Owner

ivogabe commented Mar 11, 2017

You may use object spread, as we can choose the version of TypeScript which is used to compile gulp-typescript. This is independent of the version used by consumers.

You may update the tested version of TypeScript. Though gulp-typescript should still be working with TypeScript 2.0 (though without support for extends of course). You might need to add some feature detection to check whether TypeScript 2.0 are 2.1+ is used.

@lddubeau lddubeau force-pushed the experiment/support-extends branch from 63b918b to c8a4b90 Compare May 3, 2017 12:48
@ivogabe
Copy link
Owner

ivogabe commented May 9, 2017

@lddubeau in #503:

PR #494 essentially provides support for this. I've been using the code in that PR for weeks without issue.

There's some cleanup to be done but the major block is that gulp-typescript needs to have its testing infrastructure updated to test with a proper version of 2.1 (and maybe 2.2 and 2.3??). Once that is done, I can pick up where I left off, and add tests to the PR so that it the whole thing can be merged.

Sorry, I missed that you were waiting on me to update the test infrastructure. I'll try to update that this week, though I won't remove the tests for 2.1 but will test on both 2.1 and 2.3. Then we can test the extends support only with TS 2.3.

@ivogabe
Copy link
Owner

ivogabe commented May 23, 2017

@lddubeau Can you update your PR with tests? We now use TypeScript 2.3.3, so you can now test this properly. You don't have to do anything with prior versions, as we don't test with those versions automatically.

@lddubeau
Copy link
Contributor Author

Thanks. An update should be coming soon.

@lddubeau lddubeau force-pushed the experiment/support-extends branch from c8a4b90 to 97353d0 Compare May 25, 2017 20:27
lddubeau added 6 commits May 25, 2017 16:30
The shallow copy done before calling parseJsonConfigFileContent was
unnecessary as parseJsonConfigFileContent can do it by itself.
@lddubeau lddubeau force-pushed the experiment/support-extends branch from 97353d0 to f43e9f5 Compare May 25, 2017 20:30
@lddubeau
Copy link
Contributor Author

@ivogabe As discussed, I've added the test cases and dropped the manual shallow copy.

@jair-cazarin
Copy link

We are also interested in this functionality. Is there anything else preventing this from being integrated to master?

@lddubeau
Copy link
Contributor Author

@jair-cazarin From my perspective, there's nothing blocking merging this branch. I've been using a build of gulp-typescript from this branch for weeks now because I absolutely depend on extends in my tsconfig.json files.

@ivogabe
Copy link
Owner

ivogabe commented Jun 20, 2017

Sorry for the delay, I've been busy with some other projects lately. I've taken a look at it, everything looks good. Thanks @lddubeau!

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

Successfully merging this pull request may close these issues.

3 participants