将ace上的typescript操场升级到1.0 RTM

时间:2014-04-05 21:07:58

标签: typescript tsc

我一直在努力将Basarat Ali Syed优秀打字稿编辑项目的 a fork 升级到Typescript 1.0 RTM。

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

为了更新项目,我删除了新的typescript位(lib.d.ts和typescriptServices.js)并设置了修复因api更改而被破坏的内容。

我正处于事物编译和编译错误在ace编辑器上浮现的地步但我无法弄清楚为什么不再识别诸如document,alert,window,setTimeout等全局变量:

typescript compilation issue

我必须有一些简单的东西,它是如此接近工作。有人有什么想法吗?

谢谢!

2 个答案:

答案 0 :(得分:3)

在这里看了一下代码:https://typescript.codeplex.com/SourceControl/latest#src/compiler/tsc.ts

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

resolve():

        if (includeDefaultLibrary) {
            var libraryResolvedFile: IResolvedFile = {
                path: this.getDefaultLibraryFilePath(),
                referencedFiles: [],
                importedFiles: []
            };

            // Prepend the library to the resolved list
            resolvedFiles = [libraryResolvedFile].concat(resolvedFiles);
        }

compile():

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

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

答案 1 :(得分:0)

相关问题