-
Notifications
You must be signed in to change notification settings - Fork 25.7k
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
feat: export collection of built-in directives #1524
feat: export collection of built-in directives #1524
Conversation
Hmm, it looks like Dart is not happy about Any ideas on rewriting it so Dart is not complaining? Or is it a bug in the Dart transpiler that should be fixed? |
e668ce1
to
d69324b
Compare
export * from './src/directives/class'; | ||
export * from './src/directives/for'; | ||
export * from './src/directives/if'; | ||
export * from './src/directives/non_bindable'; | ||
export * from './src/directives/switch'; | ||
|
||
export var BUILT_IN_DIRECTIVES = [For, If, NonBindable, Switch, SwitchWhen, SwitchDefault]; |
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.
It should not be all caps. How about coreDirectives
?
@View({
directives: [coreDirecitives, MyDirective]
})
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.
Also it needs a doc (with an example on how to use it) so that it will show up in the documentation.
d69324b
to
a395702
Compare
@mhevery changed the name to |
* }) | ||
* @View({ | ||
* templateUrl: 'myComponent.html', | ||
* directives: [coreDirecitives, OtherDirective] |
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.
typo coreDirectives
@alexeagle or @mprobst can you help @pkozlowski-opensource with the |
handing to @mprobst |
@pkozlowski-opensource so as discussed in offline, we don't have a way to mark an expression as const (in the Dart sense) from TypeScript source code. I could special case So two options:
|
How about we use static fields on classes that have a @const annotation? On Wed, Apr 29, 2015 at 3:18 PM Martin Probst notifications@github.com
|
We could do that, but it might still be odd and hacky as the const part is
not the field, but rather the expression going into it.
The separate files approach, one for dart, one for ts, should make this
easy enough to solve, with not too much duplication (four lines of code or
so). It's IMHO also easier to understand/maintain.
|
Yes, but having the outer class is actually a nice place to keep constants. E.g. On Wed, Apr 29, 2015 at 6:24 PM Martin Probst notifications@github.com
|
I don't think
|
I really don't like the comment hack, experience shows that's in general a terrible idea. What about just putting that stuff into a |
@mprobst yeh, the comment trick doesn't sound super-clean. I will split things into separate Ts / Dart files for this PR. But I think that we will need some kind of solution for this use-case as I keep bumping into it and there is another issue (#1283) where I will need to play it again. I saw also number of other places in the source code where we don't use consts due to this very problem.... In short: it is recurring. |
Have we considered making a feature request for TypeScript to add the matching semantics with some available keyword or other syntax? |
@alexeagle I don't think that you could ever implement dart- I am not a fan of comment, but duplicate code sounds even worse. Any other suggestions? |
We could add a magic function
|
Ups, didn't finish my last mail: We could have a function E.g. export const BASICS = CONST([For, If]); In Dart, this would transpile into:
On Wed, May 6, 2015 at 8:54 AM Tobias Bosch tbosch@google.com wrote:
|
We need to land dart-archive/ts2dart#151 and update deps on |
a395702
to
a5988b3
Compare
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This PR makes it slightly easier to list built-in directives in
@View
and addresses part of #1293 based on this commentIMO this change is backward-compatible, non-controversial and makes it easier to implement other boilerplate-busters discussed in #1293.