more experiments for mixing javascript and typescript

This commit is contained in:
Torkel Ödegaard
2015-09-09 19:34:24 +02:00
parent 005e1e002b
commit a8197df1c1
16 changed files with 80 additions and 75 deletions

1
.gitignore vendored
View File

@@ -4,6 +4,7 @@ coverage/
awsconfig
/dist
/emails/dist
/public/app_gen
/tmp
docs/AWS_S3_BUCKET

View File

@@ -1,7 +0,0 @@
/// <reference path="../headers/require.d.ts" />
declare class Base {
constructor();
testFunc(): number
getName(): string
}
export = Base;

View File

@@ -1,9 +1,13 @@
define([
],
function () {
"use strict";
class PanelMeta {
description: any
fullscreen: any
editIcon: any
panelName: any
menu: any
editorTabs: any
extendedMenu: any
function PanelMeta(options) {
constructor(options : any) {
this.description = options.description;
this.fullscreen = options.fullscreen;
this.editIcon = options.editIcon;
@@ -29,22 +33,17 @@ function () {
this.addExtendedMenuItem('Panel JSON', '', 'editPanelJson(); dismiss();');
}
PanelMeta.prototype.addMenuItem = function(text, icon, click, role) {
addMenuItem (text, icon, click, role?) {
this.menu.push({text: text, icon: icon, click: click, role: role});
};
}
PanelMeta.prototype.getName = function() {
return "javascript";
};
PanelMeta.prototype.addExtendedMenuItem = function(text, icon, click, role) {
addExtendedMenuItem (text, icon, click, role?) {
this.extendedMenu.push({text: text, icon: icon, click: click, role: role});
};
}
PanelMeta.prototype.addEditorTab = function(title, src) {
addEditorTab (title, src) {
this.editorTabs.push({title: title, src: src});
};
}
}
return PanelMeta;
});
export = PanelMeta;

View File

@@ -1,6 +1,6 @@
require.config({
urlArgs: 'bust=' + (new Date().getTime()),
baseUrl: 'public/app',
baseUrl: 'public/app_gen',
paths: {
config: 'components/config',

View File

@@ -1,6 +0,0 @@
/// <reference path="../headers/require.d.ts" />
declare class FileSearcher {
constructor();
getFiles(): string[];
}
export = FileSearcher;

View File

@@ -1,13 +0,0 @@
///<reference path="../headers/require.d.ts" />
define(["require", "exports"], function (require, exports) {
var FileSearcher = (function () {
function FileSearcher() {
}
FileSearcher.prototype.getFiles = function () {
return ["asd"];
};
return FileSearcher;
})();
return FileSearcher;
});
//# sourceMappingURL=fileSearcher.js.map

View File

@@ -1 +0,0 @@
{"version":3,"file":"fileSearcher.js","sourceRoot":"","sources":["fileSearcher.ts"],"names":["FileSearcher","FileSearcher.constructor","FileSearcher.getFiles"],"mappings":"AAAA,+CAA+C;;IAE/C;QAEIA;QACAC,CAACA;QAEMD,+BAAQA,GAAfA;YACEE,MAAMA,CAACA,CAACA,KAAKA,CAACA,CAACA;QACjBA,CAACA;QACLF,mBAACA;IAADA,CAACA,AARD,IAQC;IAEqB,AAAtB,OAAS,YAAY,CAAC"}

View File

@@ -1,6 +0,0 @@
/// <reference path="../headers/require.d.ts" />
declare class Base {
constructor();
getName(): string;
}
export = Base;

View File

@@ -1,15 +0,0 @@
///<reference path="../headers/require.d.ts" />
define(["require", "exports", './fileSearcher', "../components/panelmeta"], function (require, exports, FileSearcher) {
var Base = (function () {
function Base() {
var test = new FileSearcher();
test.getFiles();
}
Base.prototype.getName = function () {
return "asd";
};
return Base;
})();
return Base;
});
//# sourceMappingURL=testCtrl.js.map

View File

@@ -1 +0,0 @@
{"version":3,"file":"testCtrl.js","sourceRoot":"","sources":["testCtrl.ts"],"names":["Base","Base.constructor","Base.getName"],"mappings":"AAAA,+CAA+C;;IAO/C;QAEIA;YACEC,IAAIA,IAAIA,GAAGA,IAAIA,YAAYA,EAAEA,CAACA;YAC9BA,IAAIA,CAACA,QAAQA,EAAEA,CAACA;QAClBA,CAACA;QAEMD,sBAAOA,GAAdA;YACEE,MAAMA,CAACA,KAAKA,CAACA;QACfA,CAACA;QACLF,WAACA;IAADA,CAACA,AAVD,IAUC;IAEa,AAAd,OAAS,IAAI,CAAC"}

View File

@@ -2,7 +2,6 @@
///<amd-dependency path="../components/panelmeta" />
import PanelMeta = require('../components/panelmeta');
import FileSearcher = require('./fileSearcher');
class Base {

View File

@@ -19,7 +19,7 @@
<!-- build:js [[.AppSubUrl]]/app/app.js -->
<script src="[[.AppSubUrl]]/public/vendor/requirejs/require.js"></script>
<script src="[[.AppSubUrl]]/public/app/components/require.config.js"></script>
<script src="[[.AppSubUrl]]/public/app_gen/components/require.config.js"></script>
<!-- endbuild -->
</head>

View File

@@ -4,8 +4,16 @@ module.exports = function(config) {
everything_but_less_to_temp: {
cwd: '<%= srcDir %>',
expand: true,
src: ['**/*', '!**/*.less', '!config.js'],
src: ['**/*', '!**/*.less'],
dest: '<%= tempDir %>'
},
app_gen_build: {
cwd: '<%= srcDir %>/app',
expand: true,
src: ['**/*.js', '**/*.html'],
dest: '<%= srcDir %>/app_gen'
}
};
};

View File

@@ -2,16 +2,29 @@ module.exports = function() {
'use strict';
return {
base: {
build: {
src: ['public/app/**/*.ts'],
dest: '',
dest: 'public/app_gen',
options: {
module: 'amd', //or commonjs
target: 'es5', //or es3
keepDirectoryHierarchy: true,
rootDir: 'public/app',
declaration: true,
watch: true,
sourceMap: true,
generateTsConfig: true,
}
},
watch: {
src: ['public/app/**/*.ts'],
dest: 'public/app_gen',
options: {
module: 'amd', //or commonjs
target: 'es5', //or es3
rootDir: 'public/app',
declaration: true,
sourceMap: true,
watch: true,
generateTsConfig: true,
}
}
};

View File

@@ -6,6 +6,23 @@ module.exports = function(config) {
options: {
spawn: false
}
},
app_gen: {
files: ['<%= srcDir %>/app/**/*.js', '<%= srcDir %>/app/**/*.html'],
tasks: ['copy:app_gen_build'],
options: {
spawn: false
}
},
typescript: {
files: ['<%= srcDir %>/app/**/*.ts'],
tasks: ['typescript:build'],
options: {
spawn: false
}
}
};
};

17
tsconfig.json Normal file
View File

@@ -0,0 +1,17 @@
{
"compilerOptions": {
"sourceMap": true,
"declaration": true,
"outDir": "public/app_gen",
"target": "ES5",
"rootDir": "public/app",
"module": "amd",
"noEmitOnError": true
},
"files": [
"public/app/components/panelmeta.ts",
"public/app/controllers/fileSearcher.ts",
"public/app/controllers/testCtrl.ts",
"public/app/headers/require.d.ts"
]
}