-
Notifications
You must be signed in to change notification settings - Fork 1.4k
chore(config): introduce computed properties #968
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
Conversation
Hi! looking good so far! How does this affect an override in I guess this code needs an update too, doesn't it? |
Yeah, that is why the build fails. I'll fix it later today. |
b38238d
to
432b661
Compare
Lets discuss the latest proposed changes since they introduce different syntax for overwriting config properties. Also, if you have ideas for clean and less verbose definition of the property setters which is going to keep the compiler quite let me know. |
Hi! Thanks for the updates :) I don't know if this is possible in TypeScript but wouldn't it be easer to not provide a // project.config.ts
get NPM_DEPENDENCIES: InjectableDependency[] {
const seedDependencies = super.NPM_DEPENDENCIES;
return seedDependencies.concat(additional_deps);
} I do not know if it is possible to override a Update: Related TypeScript Issue: microsoft/TypeScript#338 and merged PR microsoft/TypeScript#5860 (Seems to be only possible when emitting to |
Since we are using ts-node for gulpfile.ts and tsconfig which is independent from the project build config we can eventually have this. Unfortunately we need to drop all versions of node that don't support es6... |
@@ -3,13 +3,16 @@ import { join } from 'path'; | |||
import { SeedConfig } from './seed.config'; | |||
import { InjectableDependency } from './seed.config.interfaces'; | |||
|
|||
import {Overwrite} from '../utils/seed/overwrite_config'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add whitespace?
import { Overwrite } from '../utils/seed/overwrite_config';
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Hey @mgechev, do you know which node versions would be affected (in terms of needing to be dropped because they do not support es6)? Anything < 5.x? To sum it up: For me the PR looks fine to merge, even though i wished for something a bit sleeker :) Thank you @mgechev for tackling the issue! 🎉 |
Lets think of a better solution. I'm not huge fen of the one above tool. |
One alternate solution i could think of would be to rewrite the properties to actual methods, like this: before: get PORT() {
return argv['port'] || 5555;
} after: getPort() {
return argv['port'] || 5555;
} Pros:
Cons:
Thoughts on that? |
I was also thinking that we could wrap the computed config members into a class SeedConfig {
STATIC_MEMBER = 'blah';
//...
init() {
this.COMPUTED_MEMBER = `${this.STATIC_MEMBER}/blah`;
}
} Pros
Cons
|
The methods approach seems quite verbose too but we don't have to complicate the configuration by having additional conventions. The The current approach has disadvantage that we have useless setters and we add extra I don't love any of these three options. |
I'll think about a better solution over the weekend. |
@mgechev: Have you had a chance to think about better solution? (some weekends has passed ;) ) |
Fix #823