无法导入compiler / typescript.ts

时间:2013-05-31 02:52:49

标签: typescript

一线程序helloworld

///<reference path='/Users/tadams/git/typescript/src/compiler/typescript.ts'/>

打破typescript-0.9.0

错误是 bash-3.2 $ tsc helloworld.ts

/Users/tadams/git/typescript/bin/tsc.js:42270
                comparisonInfo.flags |= 128 /* InconsistantPropertyAccesib
                              ^
TypeError: Cannot read property 'flags' of undefined
at PullTypeResolver.sourcePropertyIsRelatableToTargetProperty (/Users/tadams/git/typescript/bin/tsc.js:42270:35)
at PullTypeResolver.sourceMembersAreRelatableToTargetMembers (/Users/tadams/git/typescript/bin/tsc.js:42243:27)
at PullTypeResolver.sourceIsRelatableToTarget (/Users/tadams/git/typescript/bin/tsc.js:42183:46)
at PullTypeResolver.sourceIsAssignableToTarget (/Users/tadams/git/typescript/bin/tsc.js:42003:25)
at PullTypeResolver.computeCallExpressionSymbol (/Users/tadams/git/typescript/bin/tsc.js:41007:51)
at PullTypeResolver.resolveCallExpression (/Users/tadams/git/typescript/bin/tsc.js:40891:29)
at PullTypeChecker.typeCheckCallExpression (/Users/tadams/git/typescript/bin/tsc.js:44820:58)
at PullTypeChecker.typeCheckAST (/Users/tadams/git/typescript/bin/tsc.js:43506:33)
at PullTypeChecker.typeCheckReturnStatement (/Users/tadams/git/typescript/bin/tsc.js:45394:35)
at PullTypeChecker.typeCheckAST (/Users/tadams/git/typescript/bin/tsc.js:43639:33)

是否有人知道发生了什么或此错误消息的含义是什么?在Mac OS X 10.8上运行typescript-0.9.0。谢谢!

更新:   打字稿.9中有一个错误。一个方法没有调用足够的参数导致这个奇怪的错误。这是bug补丁差异。

diff --git a/src/compiler/typecheck/pullTypeResolution.ts b/src/compiler/typecheck/pullTypeResolution.ts
index ec3d236..801ed2f 100644
--- a/src/compiler/typecheck/pullTypeResolution.ts
+++ b/src/compiler/typecheck/pullTypeResolution.ts
@@ -4001,7 +4001,7 @@ module TypeScript {
                     getTypeAtIndex: (index: number) => { return rightType; } // we only want the "second" type - the "first" is skipped
                 }

-                var bestCommonType = this.findBestCommonType(leftType, null, collection, context);
+                var bestCommonType = this.findBestCommonType(leftType, null, collection, context, new TypeComparisonInfo());

                 if (bestCommonType) {
                     symbol = bestCommonType;
@@ -6442,7 +6442,7 @@ module TypeScript {
                         setTypeAtIndex: (index: number, type: PullTypeSymbol) => { } , // no contextual typing here, so no need to do anything
                          getTypeAtIndex: (index: number) => { return index ?     Q.signature.getReturnType() : best.signature.getReturnType(); } // we only want the "second" type  - the "first" is skippe
                     }
    -                    var bct = this.findBestCommonType(best.signature.getReturnType(), null, collection, context);
    +                    var bct = this.findBestCommonType(best.signature.getReturnType(), null,    collection, context, new TypeComparisonInfo());
                     ambiguous = !bct;
                 }
                 else {
    @@ -6844,4 +6844,4 @@ module TypeScript {
             return sig;
         }
     }
    -}
    \ No newline at end of file
    +}`

1 个答案:

答案 0 :(得分:0)

您需要确保所有依赖项都可用,特别是在我想象的示例中flags.ts

以下是typescript.ts

的所有依赖关系
///<reference path='diagnostics.ts' />
///<reference path='flags.ts' />
///<reference path='nodeTypes.ts' />
///<reference path='hashTable.ts' />
///<reference path='ast.ts' />
///<reference path='astWalker.ts' />
///<reference path='astWalkerCallback.ts' />
///<reference path='astPath.ts' />
///<reference path='astLogger.ts' />
///<reference path='binder.ts' />
///<reference path='base64.ts' />
///<reference path='sourceMapping.ts' />
///<reference path='emitter.ts' />
///<reference path='errorReporter.ts' />
///<reference path='parser.ts' />
///<reference path='printContext.ts' />
///<reference path='scanner.ts' />
///<reference path='scopeAssignment.ts' />
///<reference path='scopeWalk.ts' />
///<reference path='signatures.ts' />
///<reference path='symbols.ts' />
///<reference path='symbolScope.ts' />
///<reference path='tokens.ts' />
///<reference path='typeChecker.ts' />
///<reference path='typeCollection.ts' />
///<reference path='typeFlow.ts' />
///<reference path='types.ts' />
///<reference path='pathUtils.ts' />
///<reference path='referenceResolution.ts' />
///<reference path='precompile.ts' />
///<reference path='incrementalParser.ts' />
///<reference path='declarationEmitter.ts' />

我在过去也看到过没有格式正确的评论引起的问题。我建议总是在结束斜线前加一个空格(即使我认为这不是你的问题),即

///<reference path='/Users/tadams/git/typescript/src/compiler/typescript.ts' />

///<reference path='/Users/tadams/git/typescript/src/compiler/typescript.ts'/>