|
Size: 272
Comment:
|
Size: 1808
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 2: | Line 2: |
| * https://www.typescriptlang.org * https://www.typescriptlang.org/docs/tutorial.html == install == npm install -g typescript == Compile == tsc helloworld.ts |
|
| Line 6: | Line 14: |
| wget https://github.com/PrettyFlower/KateTypeScriptSyntaxHighlighting/blob/master/typescript.xml cp typescript.xml /usr/share/apps/katepart/syntax/typescript.xml |
wget https://github.com/PrettyFlower/KateTypeScriptSyntaxHighlighting/raw/master/typescript.xml cp typescript.xml /usr/share/apps/katepart/syntax/typescript.xml |
| Line 9: | Line 17: |
== Sample code typescript for browser == {{{ npm install -g typescript npm install -g webpack //greeter.html <!DOCTYPE html> <html> <head><title>TypeScript Greeter</title><meta charset="UTF-8"></head> <body> <script src="dist/bundle.js"></script> </body> </html> //lib.ts export function getText(){ return "text"; } //greeter.ts import {getText} from "./lib"; interface Person { firstName: string; lastName: string; } function greeterPerson(p:Person) { return "Hello GP, " + p.firstName + ' ' + p.lastName + ' ' + getText() ; } function greeter(person:string) { return "Hello, " + person; } var user = "XPTO User"; //document.body.innerHTML = greeter(user); document.body.innerHTML = greeterPerson( {firstName:"First",lastName:"Last"} ); //tsconfig.json { "compilerOptions": { "module": "es6", "noImplicitAny": true, "removeComments": true, "preserveConstEnums": true, "sourceMap": true }, "files": [ "greeter.ts", "lib.ts"] } //webpack.config.js var path = require('path'); module.exports = { entry: ['./greeter.js','./lib.js'], output: { filename: 'bundle.js', path: path.resolve(__dirname, 'dist') } }; // build tsc webpack --config webpack.config.js }}} |
typescript
install
- npm install -g typescript
Compile
- tsc helloworld.ts
kate
https://github.com/PrettyFlower/KateTypeScriptSyntaxHighlighting
wget https://github.com/PrettyFlower/KateTypeScriptSyntaxHighlighting/raw/master/typescript.xml cp typescript.xml /usr/share/apps/katepart/syntax/typescript.xml
Sample code typescript for browser
npm install -g typescript
npm install -g webpack
//greeter.html
<!DOCTYPE html>
<html>
<head><title>TypeScript Greeter</title><meta charset="UTF-8"></head>
<body>
<script src="dist/bundle.js"></script>
</body>
</html>
//lib.ts
export function getText(){
return "text";
}
//greeter.ts
import {getText} from "./lib";
interface Person {
firstName: string;
lastName: string;
}
function greeterPerson(p:Person) {
return "Hello GP, " + p.firstName + ' ' + p.lastName + ' '
+ getText() ;
}
function greeter(person:string) {
return "Hello, " + person;
}
var user = "XPTO User";
//document.body.innerHTML = greeter(user);
document.body.innerHTML = greeterPerson(
{firstName:"First",lastName:"Last"}
);
//tsconfig.json
{
"compilerOptions": {
"module": "es6",
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"sourceMap": true
},
"files": [ "greeter.ts", "lib.ts"]
}
//webpack.config.js
var path = require('path');
module.exports = {
entry: ['./greeter.js','./lib.js'],
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
}
};
// build
tsc
webpack --config webpack.config.js 