0

一行程序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 中有一个错误。没有使用足够的参数调用方法,这导致了这个奇怪的错误。这是错误补丁差异。

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
    +}`
4

1 回答 1

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'/>
于 2013-05-31T13:54:21.993 回答