【问题标题】:upgrade typescript playground on ace to 1.0 RTM将 ace 上的 typescript playground 升级到 1.0 RTM
【发布时间】:2014-04-05 21:07:58
【问题描述】:

我一直在尝试将 Basarat Ali Syed 出色的 typescript 编辑器项目的 a fork 升级到 Typescript 1.0 RTM。

该项目开箱即用,没有问题,但是它使用的是一年前的打字稿版本,并且编译器 api 从那时起发生了很大变化。

为了更新项目,我加入了新的 typescript 位(lib.d.ts 和 typescriptServices.js),并着手修复因 api 更改而损坏的内容。

我正处于编译和编译错误出现在 ace 编辑器上的地步,但我无法弄清楚为什么不再识别文档、警报、窗口、setTimeout 等全局变量:

我一定缺少一些简单的东西,它离工作太近了。有人有什么想法吗?

谢谢!

【问题讨论】:

    标签: typescript tsc


    【解决方案1】:

    看看这里的代码:https://typescript.codeplex.com/SourceControl/latest#src/compiler/tsc.ts

    在编译时将 lib.d.ts 添加到编译器的文件列表中,就像任何其他文件一样:

    解决():

            if (includeDefaultLibrary) {
                var libraryResolvedFile: IResolvedFile = {
                    path: this.getDefaultLibraryFilePath(),
                    referencedFiles: [],
                    importedFiles: []
                };
    
                // Prepend the library to the resolved list
                resolvedFiles = [libraryResolvedFile].concat(resolvedFiles);
            }
    

    编译():

            this.resolvedFiles.forEach(resolvedFile => {
                var sourceFile = this.getSourceFile(resolvedFile.path);
                compiler.addFile(resolvedFile.path, sourceFile.scriptSnapshot, sourceFile.byteOrderMark, /*version:*/ 0, /*isOpen:*/ false, resolvedFile.referencedFiles);
            });
    

    一旦我开始做同样的事情,编译错误就消失了。在旧版本的编译器中一定不需要这一步吗?

    【讨论】:

      【解决方案2】:

      【讨论】:

      猜你喜欢
      • 2012-09-04
      • 2018-10-20
      • 2012-03-12
      • 2016-12-28
      • 2019-12-13
      • 1970-01-01
      • 1970-01-01
      • 2013-04-20
      • 1970-01-01
      相关资源
      最近更新 更多