我有angular 1.x应用程序。应用是使用gulp构建的。我将枚举定义在自动生成的单独文件中,该文件称为enums.ts
内容如下:
filenames <- list.files(path=".",
pattern="csv",
full.names=TRUE)
names <- as.vector(filenames)
# Creating a directory to save contour plots
dir.create("Contour plots")
#Creates a contour plot in ggplot of the variable in xz space
makeplot <- function(filename) {
data <- as.data.frame(read.csv(file = filename), header = FALSE)
ggplot(data=data, mapping = aes(x = data[,2],
y=data[,1],
z = data[,3])) +
geom_raster(data=data, aes(fill=data[,3]), show.legend=TRUE, interpolate
= FALSE) +
scale_fill_gradient(limits=range(data[,3]), high = 'red', low =
'white')+
geom_contour(bins = 30, colour = "black") +
xlab(label = "Distance from ridge axis") +
ylab(label = "Depth") +
theme_classic()+
coord_cartesian(
ylim = c(0,1), xlim = c(0,2))+
scale_x_continuous(expand = c(0, 0)) +
scale_y_continuous(expand = c(0, 0)) +
guides(fill=guide_legend(title="Yb concentration")) +
theme(legend.position="bottom")
}
for (f in filenames) {
png(filename="Rplot%03d.png", height = 600, width = 1200)
makeplot(f)
dev.off()
}
使用此枚举的类在不同的文件类中。ts
declare module MyApp.App {
export enum Status {
Done = 0,
Unsuccessful = 1,
Pending = 2,
}
文件由ts编译器处理,但输出js文件始终为空。
如果我将枚举移动到包含使用它的类的文件,则一切正常。
namespace MyApp.App {
export class ResourcesCtrl implements IResourcesCtrl {
public loading: boolean;
public resources: IResource[];
public isSucessfull(resource: IResource): boolean {
return resource.status.toString() !== Status.Done.toString();
}
}
angular.module("app").
controller("resourcesCtrl",ResourcesCtrl);
}
答案 0 :(得分:0)
这不是实现代码,而是环境声明。
它以declare
开始...这意味着它仅提供有关类型的信息。
如果您打算从此文件中获取输出,则它至少需要一点实现代码。
例如,以下代码...
declare module DoesNotExist {
export enum AmbientEnum {
a, b, c
}
}
export enum RealEnum {
d, e, f
}
只会产生带有RealEnum
的输出文件:
define(["require", "exports"], function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var RealEnum;
(function (RealEnum) {
RealEnum[RealEnum["d"] = 0] = "d";
RealEnum[RealEnum["e"] = 1] = "e";
RealEnum[RealEnum["f"] = 2] = "f";
})(RealEnum = exports.RealEnum || (exports.RealEnum = {}));
});