0

I have certain code that looks like this

interface KnockoutObservableArrayStatic {
    fn: KnockoutObservableArrayFunctions<any>;
    <T>(value?: T[]): KnockoutObservableArray<T>;
}
declare var ko: KnockoutObservableArrayStatic;

I want to create a empty observable array with type TElement, which should be something like this

var elementArray: TElement[] = null;
var observableArray = ko(elementArray);

But compiler gives me error

Cannot convert 'KnockoutObservableArray' to 'KnockoutObservableArray': Call signatures of types 'KnockoutObservableArray' and 'KnockoutObservableArray' are incompatible

How come?

2 Answers 2

3

Hard to say without seeing all of the code, but this sounds like a compiler bug (you shouldn't see "Cannot convert T to T" errors ever, basically). If you could post an issue with a self-contained example I can verify if the code compiles with the latest TypeScript compiler. There have been several bugs around generic compatibility with the Knockout type structure like this.

Sign up to request clarification or add additional context in comments.

Comments

0

I had the same problem when compiled solution in VS2013.

I deleted this two lines from MyProject.csproj file

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets')" />

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props')" />

and errors went out.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.