HOW TO have auto import of classes upon a directive creation
Deviad opened this issue · comments
Hello,
in this boilerplate it is included a tsconfig.json file with a files: property.
If you do no include all the .ts files you are working with, you won't be able to use the auto-import feature in Intellij IDEA and therefore, very likely, also in PHP Storm and Webstorm.
With reference to chapter 03 for example, when you create a file named property-binding.component.ts, you must include this file in the "files:" property.
"files": [
"./dev/property-binding.component.ts",
"./dev/app.component.ts",
"./dev/boot.ts"
]
It took me some time to understand this, I hope someone will find this information useful and save some time for actually learning.
import {Component} from "angular2/core";
import {PropertyBindingComponent} from "dev/property-binding.component";
@Component({
selector: 'app',
template: `
<section class="parent">
<h2>This is the parent component</h2>
<h4>Please, enter your name:</h4>
<input type="text" [(ngModel)]="name">
<br><br>
<section class="child">
<my-property-binding [myName]="name" [myAge]="26">
</my-property-binding>
</section>
</section>
`,
directives: [PropertyBindingComponent]
})
export class AppComponent {
name = '';
}
Therefore when you finish typing directives: [PropertyBindingComponent]
, once you press ALT+Enter, Intellij IDEA will automatically write import {PropertyBindingComponent} from "dev/property-binding.component";
.
Hi,
I cannot confirm this. You don't have to explicitly specify all to-be-compiled files in the 'files' configuration. That would be a very inconvenient way of using TypeScript since you would have to add each class there. By default all .ts files will be included and therefore my .tsconfig file only has the 'exclude' configuration which tells the compile which files NOT to compile.
Regards,
Maximilian
Hello,
I realized by practice what you said before reading this comment.
This is how I solved the issue:
"files": [
"./dev/**/*.ts"
]