I'm having a trouble with compilling my TypeScript file:
app/app.component.ts
import {Component} from 'angular2/core';
@Component({
selector: 'my-app',
template: '<h1>Messenger</h1>'
})
export class AppComponent { }
TypeScript Compiller returns
Error:(1, 1) TS1148: Cannot compile modules unless the '--module' flag is provided.
Error:(1, 25) TS2307: Cannot find module 'angular2/core'.
Error:(7, 14) TS1219: Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning.
Providing flags in tsconfig.json does nothing.
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"exclude": [
"node_modules",
"typings/main",
"typings/main.d.ts"
]
}
My project tree:
.
├── app
├── node_modules
├── typings
├── application.js
├── messages.js
├── package.json
├── tsconfig.json
└── typings.json
I'm using RubyMine 8 as IDE
What am I doing wrong? Is there another way to provide my flags?
If you are using the bundled TypeScript compiler, go to File > Settings > Languages & Frameworks > TypeScript
You can click on the set options manually
radio button, and enter the arguments in the Command line options
text box. See the list of available arguments
This is how you provide command line arguments.
Use tsconfig.json
works for me without providing any command line arguments.
I might be missing something, but I think there're two errors in your first line of your app.component.ts
import {Component} from 'angular2/core';
should be
import { Component } from '@angular2/core';
The space between the imports and the curly brackets and the '@' symbol before angular2 have caused me lots and lots of pain.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.