在Chrome中调试TypeScript,404响应

Emi*_*son 2 javascript debugging google-chrome typescript

我正在将我的.TS编译为JavaScript并生成源映射.但是,我无法调试实际文件.我有一个X数量的.TS文件,它们编译成CombinedTypescript.js,并且源地图是正确的.

但是,当我尝试在Chrome调试器中访问我的.TS文件时,它只给了我404响应.这些文件存在于"源"中,但我无法访问它们或在CombinedTypescript.js中设置断点并逐步执行我的文件.

有谁知道问题可能是什么?

Dav*_*ret 7

您遇到的问题很可能是IIS未配置为提供.ts文件.您需要添加.ts为MIME类型.

选项1 - 编辑web.config

我建议进行此更改,以便您的项目.ts无论环境如何都将提供文件.要执行此操作,请mimeMap向您的web.config下方添加标记,configuration > system.webServer > staticContent如下所示:

<configuration>
    ...
    <system.webServer>
        <staticContent>
            <mimeMap fileExtension=".ts" mimeType="application/x-typescript" />
        </staticContent>
    </system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)

资源

选项2 - 配置IIS

另一种选择是配置IIS来提供.ts文件.以下是一些资源: