TypeScript 1.3 protected error - visual-studio-2013

Recently installed new TS version into VS2013 and tried to use protected modifier.
However TS validator shows me an error (and underlines protected word with a red line.
I get an error like
Use of future reserver word.
; expected
looks like it's looking into old TS definitions.
Checked the project file and there is 1.1 version of TypeScript.
also running tsc -v produces 1.3.0.
Does somebody of you guys experience that?
What i'm missing and what to do to fix that.
Thank you a lot for any help.
export class SomeClass {
protected metadata: Metadata;
protected subItems: SomeClass[];
constructor() {
}
}

thank you all guys. for your answers!
the reason was (oh, what's the shame =) ) the ReSharper.
It's validation was showing that error, suspending it i'm getting no errors now.
Looks like JetBrains guys should update their definitions like Web Essentials did.
As they aren't compatible with new TS version, 1.3. And no updates pending as for now.
Hope, it'll be useful for somebody else.

The answer to your question then is ReSharper 9.0 EAP.
It supports TypeScript 1.3 features: 'protected' modifier and tuples.
You're welcome to try it. Though, yes, it's a pre-release version, so overall stability is not strictly guaranteed.

Are you building from within Visual Studio, or from the command-line? What with different versions of the SDK being installed, as well as potentially the NPM package globally (if you've ever installed that), it can get quite messy as to which version gets picked up. For example, if I run 'where tsc' from the command prompt, I get the below hits (and this is without the 1.1 SDK on the path, though I am in the bin folder for testing the latest bits)
S:\src\TypeScript\bin>where tsc
S:\src\TypeScript\bin\tsc
S:\src\TypeScript\bin\tsc.js
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\tsc.exe
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\tsc.js
C:\Users\billti\AppData\Roaming\npm\tsc
C:\Users\billti\AppData\Roaming\npm\tsc.cmd
Can you verify via "where tsc" the locations and order you PATH is resolving the 'tsc' command?
That said, if you're building from within a VS project, it should locate the latest SDK via the build target. Does this also occur with a new TypeScript project (where the latest version and targets file should be referenced)?
Failing that, and I hate to say it... ready... did you try rebooting? :-) Sometimes updates to the PATH etc.. after an install don't get picked up until processes restart, and things like MSBuild can actually linger waiting for the next build as a perf optimization, rather than exit once the build is done (and thus may not pick up environment changes immediately).

It didn't work for me too. What I did to fix it was installing VS2013 Update 4 and after that, I executed the TypeScript 1.3 setup again and did a repair.
Also, you should make sure you don't have <TypeScriptToolsVersion>1.0</TypeScriptToolsVersion> in your csproject defined. Set it to 1.1 (not 1.3) or remove it entirely (then it will use the latest one). Hope that helps!

You can determine whether the issue is related to Visual Studio pointing at the wrong TypeScript version by following these steps.
Place this example code in C:\Temp\app.ts
interface Metadata {
something: string;
}
export class SomeClass {
protected metadata: Metadata;
protected subItems: SomeClass[];
constructor() {
}
}
export class OtherClass extends SomeClass {
constructor() {
super();
this.metadata = null;
}
}
var x = new SomeClass();
// Not allowed
// x.metadata = null;
Run the command:
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.1>tsc --module amd c:\Temp\app.ts
Taking care to ensure you are pointing at the 1.1 folder in the TypeScript SDK folder.
The output should be:
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.1>
i.e. nothing, except you now have an app.js file.
You can also re-run the test after uncommenting the x.metadata = null; line - at which point you should get the error:
c:/Temp/app.ts(22,1): error TS2445: Property 'metadata' is protected and only accessible within class 'SomeClass' and its subclasses.
Next Steps...
If the above fails, please supply details of the problem.
The only real answer we could give though it remove it and check the 1.1 folder is gone before re-installing it by fetching the installer fresh from the Microsoft website (perhaps you have a bad installer or there was some problem during installation?) You may also want to check that you are on Visual Studio Update 4, as I am testing it on Update 4.
If the above worked as expected, your Visual Studio is not pointing at the correct version.
This could be because of the project file as Dick van den Brink has correctly mentioned. Check that you have <TypeScriptToolsVersion>1.1</TypeScriptToolsVersion> and that it is the only element with this name.
It can also be down to any Visual Studio extensions that may be messing with your TypeScript (for example, if you had a really old version of Web Essentials - in which case, update it - if it is some other extension, try disabling it).

Related

Build problems with SQLite3 on VS2010

I try to build SQLite v3 from source using VS2010 and run into problems which I do not know how to tackle.
This is what I have:
VS2010 pro.
using sqlite-amalgamation-3160100.zip
Microsoft article: SQLite databases
This is what I did:
Created a C++ 'Win32 Console application'.
Disabled procompiled headers.
Added preprocessor definitions: (dont do this, this is the problem!)
_HAVE_SQLITE_CONFIG_H;SQLITE_OS_WINRT;SQLITE_API=__declspec(dllexport);
(as specified by 'SQLite databases' section 3.)
Created config.h (which is empty for the moment.)
Included the source files from sqlite-amalgamation-3160100.zip in the project.
build.
I get a number of compiler errors
1> sqlite3.c
1>e:\andre\ontwikkeling\sqlite\sqlite-amalgamation-3160100\sqlite3.c(38515): error C2065: 'MapViewOfFileFromApp' : undeclared identifier
1>e:\andre\ontwikkeling\sqlite\sqlite-amalgamation-3160100\sqlite3.c(38515): error C2099: initializer is not a constant
1>e:\andre\ontwikkeling\sqlite\sqlite-amalgamation-3160100\sqlite3.c(38524): error C2065: 'CreateFile2' : undeclared identifier
....
... which I try to solve.
The first one leads me to the following code snipped:
#if SQLITE_OS_WINRT && (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0)
{ "MapViewOfFileFromApp", (SYSCALL)MapViewOfFileFromApp, 0 },
#else
{ "MapViewOfFileFromApp", (SYSCALL)0, 0 },
#endif
Now 'MapViewOfFileFromApp' leads to MapViewOfFileFromApp function, 'Maps a view of a file mapping into the address space of a calling Windows Store app.', a valid microsoft call for which my project setup is missing the correct configuration.
I could get a workaround for this one, but other errors are depending only on SQLITE_OS_WINRT and as such not possible to work around it.
It looks like that I'm missing some configuration options but I do not know which ones. I read all of the documented compile time options but can't find out what it is that I do wrong.
I tried to find a working exaple of a VS2010 solution but came up with nothing. And of cause I checked here for similar questions! (If there is one covering this then I missed it, sorry.)
Does anybody have a suggestion on what I'm missing? I'm running out of idea's.
* edit 6 jan 2017 *
On advice of MaxFurry I followed the steps of the blog by David Cravey which does exact the same steps as I did but without declaring SQLITE_OS_WINRT;SQLITE_API=__declspec(dllexport);. Leaving these two defines out solved the problem.
Aparently I misinterpreted the advice in the Microsoft article.
Compile time problems solved.
Kind regards.
Do you have your sqlite3.dll file already built? If so just create a folder in your visual studio folder. When u want to use sqlite3 just copy the dll file to the folder of the project in visual studio u want to use it also copy the following files there sqlit3.c, sqlite3.h. When this is done open the project in your visual studio IDE. Right click on the project name, add, add existing then click on the sqlite3.h and sqlite3.c. Let me know how it goes.

VS 2013 Error-"No exports were found that match the constraint:"

I am using Visual Studio 2013 on Windows 10, Today I am getting error "No exports were found that match the constraint:"
I did following but still having same issue:
Solution giving in link
Error message "No exports were found that match the constraint contract name"
by removing/renaming "ComponentModelCache" folder, but still problem.
Run VS Repair, but still having same problem.
Finally, I Uninstalled Visual Studio 2013 and reinstalled, but still having
same problem.
Please suggest what do do now?
Finally, I did find answer myself, instead of deleting/renaming 'ComponentModelCache' folder in path
C:\Users\'username'\AppData\local\Microsoft\VisualStudio\12.0
I renamed folder 'Microsoft' in path
C:\Users\'username'\AppData\local\
This works for me.
You can see here more solutions which require deleting the cache in %APPDATA%.
In my case, the problem was that I was initializing and using class with the MEF framework but didn't declare the class as a MEF class.
How to import a MEF class:
[Import(typeof(ICalculator))]
public ICalculator calculator;
How to define and export a MEF class:
public interface ICalculator
{
String Calculate(String input);
}
[Export(typeof(ICalculator))]
class MySimpleCalculator : ICalculator
{
}
The code example is taken from here
Apologies for contributing to an old "answered" thread. however for me, using Win 10, VS 2013. I had to remove the 'ComponentModelCache' folder from each version of VS that I had installed before this issue was resolved.

ShimNotImplementedException after upgrading Visual Studio 2013 and Microsoft Fakes v12

We are utilizing Microsoft Fakes with Visual Studio 2013. After updating to Visual Studio 2013 Update-4 or Update-5, we are getting ShimNotImplementedException's in our tests.
We have followed instructions found in other SOF questions and turned off the SpecificVersion of our Microsoft.QualityTools.Testing.Fakes references. This allows a compile but the tests still fail when run.
The hint we needed to solve this was found in MSDN forums.
The underlying issue is that the legacy tests did not define specific methods
on the ShimXXX object that the code based is using. Under version 11
all is well; version 12 is a different matter.
The stack trace for the ShimNotImplementedException gave the needed information on the missing property/method:
Microsoft.QualityTools.Testing.Fakes.Shims.ShimNotImplementedException
at $Func`2NotImplementedf5b9281e-32b0-4bf3-9079-6a54470670de.Invoke(SiteContext arg1)
at Sitecore.Sites.SiteContext.get_Database() //THIS IS THE PROBLEM PROPERTY
at Sitecore.Ecommerce.ShopContext..ctor(SiteContext innerSite)
at ActiveCommerce.UnitTest.ProductStockManagerTests.get_MockShopContext()
at ActiveCommerce.UnitTest.ProductStockManagerTests.GetAvailability_AlwaysInStock()
Adding the missing property to our shim construction solved the issue:
return new Sitecore.Ecommerce.ShopContext(new ShimSiteContext
{
PropertiesGet = () => new NameValueCollection(),
DatabaseGet = () => null //ADDING THIS SOLVED THE ISSUE
});
I ran in to a similar problem after upgrading several of our projects from .NET 4 to .NET 4.5.2 using Visual Studio 2015. All the sudden several previously passing tests started failing. The common denominator was that all of the tests were using Shims to mock registry access.
What appears to have happened is that something changed in the handling of the Dispose method. Originally I had not implemented a Dispose method on the RegistryKey shims. That didn't seem to cause any trouble running under .NET 4. However after the switch to 4.5.2, it is implicitly being called all the time.
The solution was simple: I just added a stub for Dispose.
Microsoft.Win32.Fakes.ShimRegistryKey.AllInstances.Dispose = (key) => { };
The tests now pass again.
Note that setting it to NULL did not solve it for it. There has to be a method.

Compiler can't resolve modules

I am using Visual Studio 2013 Update 2 with Web Essentials latest version.
At the moment typescript is giving me a hard time as AMD compiling does not seem to be reliable. Most of the time intellisense is happy with the module path (not always) but the compiler never accepts it.
This is what my file structure looks like:
-scripts
-app
-controls
FeedbackControl.ts
-models
FeedbackModel.ts
FeedbackControl.ts
import model = require("../models/feedbackmodel");
export class FeedbackControl{
constructor(){}
}
FeedbackModel.ts
export class FeedbackModel{
constructor(){}
}
This looks valid to me and even the IDE is ok with it. But when I try to compile this is what the compiler thinks:
Build: Unable to resolve external module '"../models/feedbackmodel"'.
On a side node:
Now and then the IDE is showing me such errors, too. A restart of visual studio helps. What always leads to an error is when I do not use lower case characters in module path only. Like so:
import model = require("../models/FeedbackModel");
I have no idea what I need to do to get this fixed. My team mates are having this issue, too, so I guess there is something wrong with the solution. As a workaround we disabled typescript compiling on each .ts file.
The string casing of the import statement i.e. /models/FeedbackModel needs to match the case used in the file system.

How can I install WTL 8.0 Project Wizards in VS 2010?

I've downloaded the WTL 8.0 package and come to find the scripts to install App Wizards don't support VS 2010.
Does anyone know of updates scripts to support installation in VS 2010?
Thank you!
The AppWizard for VS2010 above has two small glitches (however they might deter people from using WTL with VS2010). These are very easy to fix:
1) [Output Directory] and [Intermediate Directory] in new project properties are not followed by a backslash ('\').
To fix:
file: .\AppWiz\Files\Scripts\1033\default.js
I have replaced:
if(bDebug)
{
config.IntermediateDirectory = 'Debug';
config.OutputDirectory = 'Debug';
config.ATLMinimizesCRunTimeLibraryUsage = false;
}
else
{
config.IntermediateDirectory = 'Release\\';
config.OutputDirectory = 'Release\\';
config.ATLMinimizesCRunTimeLibraryUsage = true;
}
with
// Add generic configuration details
config.IntermediateDirectory = '$(SolutionDir)$(Configuration)\\';
config.OutputDirectory = '$(Configuration)\\';
config.ATLMinimizesCRunTimeLibraryUsage = !bDebug;
2) Some WTL headers are missing in newly created projects.
The symbol WTL_USE_CPP_FILES seems to be missing when the template stdafx.h file is parsed, as a result a bunch of header files are not included in new projects.
Again in .\AppWiz\Files\Scripts\1033\default.js, I have added:
// Add WTL_USE_CPP_FILES to all projects
wizard.AddSymbol("WTL_USE_CPP_FILES", true)
just below line 41 (so that the lines are always included). This seems to do the trick.
I've never looked at VS appWizards before (or js for that matter), so I can't guarantee the workarounds are concrete. It seems pretty straighforward though & I've been using WTL with VS2010 with no problems since I've made those changes...
WTL is awesome btw - many thanks to the folks who still maintain it!
Cheers,
Yiannis
WTL 8.0 was released in june 2007 so couldn't possibly support VS 2010.
You may download the current work in progress WTL 8.1 AppWizard from http://wtl.svn.sourceforge.net/viewvc/wtl/trunk/wtl/Wizards/AppWiz.tar.gz?view=tar and the matching library files from /include.tar.gz?view=tar.

Resources