相关疑难解决方法(0)

TypeScript捆绑和缩小?

假设我有两个文件

AFile.ts

/// <reference path="ZFile.ts" />
new Z().Foo();
Run Code Online (Sandbox Code Playgroud)

ZFile.ts

class Z
{
    Foo() { }
}
Run Code Online (Sandbox Code Playgroud)

有没有办法js按照它所需的顺序在单个文件中生成所有脚本(需要ZFileAFile获得定义之前Z)?

asp.net-mvc typescript asp.net-mvc-5

18
推荐指数
2
解决办法
1万
查看次数

打字稿外部模块可以有循环依赖吗?

看起来这是不允许的.requireJS在以下内容上抛出一个错误(这个帖子不同,因为它是用内部模块解决的):

element.ts:

import runProperties = require('./run-properties');
export class Element {
   public static factory (element : IElement) : Element {

        switch (element.type) {
            case TYPE.RUN_PROPERTIES :
                return new runProperties.RunProperties().deserialize(<runProperties.IRunProperties>element);
        }
        return null;
    }
}
Run Code Online (Sandbox Code Playgroud)

运行properties.ts:

import element = require('./element');

export class RunProperties extends element.Element implements IRunProperties {
}
Run Code Online (Sandbox Code Playgroud)

module typescript

15
推荐指数
1
解决办法
9543
查看次数

Swagger-Codegen:如何将所有文件合并到一个文件中以进行客户端代码生成

我刚刚开始使用Swagger和NodeJS.我能够将Swagger实现到我的NodeExpress应用程序,并且能够准确地生成带有Swagger-Codegen(Typescript-Angular)的typescript-client-code.

我遇到的一个问题是生成的代码分散了很多不同的文件.我希望它只输出一个文件api.ts,它包含API调用和接口/模型的所有内容.

我一直在寻找解决这个问题的方法,因为随着后端的增长,很难读取和维护生成的客户端代码.

任何建议或指示将不胜感激.

节日快乐!谢谢

编辑:我一直在寻找这个问题的答案,但仍然没有找到答案.我目前正在开发一个使用ASP.NET Core的项目,他们可以NSwag实现我想要实现的目标Node Swagger.

javascript express swagger swagger-codegen angular

10
推荐指数
1
解决办法
1669
查看次数

无法在TypeScript中从文件加载类

我有一个看起来像这样的课:

export module GameModule {
    export class Game {
        private boardContainer: HTMLElement;
        private board: number[][];

        constructor (container: HTMLDivElement) {
            this.boardContainer = container;
            this.board = [[0, 0, 0], [0, 0, 0], [0, 0, 0]];

            this.drawGrid();
        }

        drawGrid() {

        }
    }
}
Run Code Online (Sandbox Code Playgroud)

和主要应用:

import GameModule = module("./GameModule");

window.onload = () => {
    new GameModule.GameModule.Game(<HTMLDivElement> document.getElementById('content'));
};
Run Code Online (Sandbox Code Playgroud)

但是当我尝试编译代码时,我遇到了错误:

>tsc --module amd app.tss
app.tss(1, 27): The name '"./GameModule"' does not exist in the current scope
app.tss(1, 27): A module cannot be aliased to a …
Run Code Online (Sandbox Code Playgroud)

typescript

5
推荐指数
1
解决办法
3205
查看次数