"variable namespace is undeclared" error in Polymer - polymer-1.0

I am trying to create a new helper file in a Polymer project.
helper.html looks like this:
<script src="helper.ts"></script>
Helper looks like this:
namespace my_namespace {
export function foo(){}
}
I get several errors including "variable namespace is undeclared", "Parse error. Semi-colon expected", "variable missing_expression is undeclared", "Parse error. primary expression expected".

Check for these things:
Your namespace must match the name field in your tf_web_library declaration in your BUILD file
Add both your helper.html and helper.js files to your BUILD file.
In helper.html, the src field should be helper**.js** not helper**.ts**

Related

Do not use a triple slash reference for

I'm trying to use a type declaration file. When using triple slash reference like so:
/// <reference path="../declarations.d.ts" />
The app builds fine, but I get the above eslint error: "Do not use a triple slash reference for ../declarations.d.ts, use import style instead(https://typescript-eslint.io/rules/triple-slash-reference/)
If I do use an import:
import "../declarations.d.ts"
The build fails and the declarations file is being ignored.
I also tried to use tsconfig.json to add the file, but that also failed (I'm using NX environment, probably there's some bug with NX)
So only the reference syntax is working, but then I get that es-lint error. Does anyone know how to fix this?
My custom declaration file:
import '#types/my-react-package';
declare module '#types/my-react-package' {
export interface PackageProps {
showPreview?: boolean;
}
}

how to use cp-react-tree-table in my project?

New to typescript, try to follow the demo https://www.npmjs.com/package/cp-react-tree-table to use this control in my project, but get below information.
Try to search and seems it's related to module definition which confuse.
Hope someone can show me light.
import * as jQuery from 'jquery';
import TreeDataTable from 'cp-react-tree-table';
'TreeDataTable' is declared but its value is never read.ts(6133)
Could not find a declaration file for module 'cp-react-tree-table'. 'path/node_modules/cp-react-tree-table/dist/index.js' implicitly has an 'any' type.
Try npm install #types/cp-react-tree-table if it exists or add a new declaration (.d.ts) file containing declare module 'cp-react-tree-table';ts(7016)
Could not find a declaration file for module 'cp-react-tree-table'. path/node_modules/cp-react-tree-table/dist/index.js' implicitly has an 'any' type.
Try npm install #types/cp-react-tree-table if it exists or add a new declaration (.d.ts) file containing declare module 'cp-react-tree-table';ts(7016)
Could not find a declaration file for module 'cp-react-tree-table'
Create a new file like cp-react-tree-table.d.ts then add the following content to resolve the error quickly, but it's unsafe.
declare module "cp-react-tree-table" {
let TreeDataTable: any;
export default TreeDataTable;
}
Also, make sure typescript honoring our declaration file.
Your module doesn't have a type definition.
You should have install : #types/cp-react-tree-table but apparently it doesn't exist.
So you have to manualy create a file : "cp-react-tree-table.d.ts" containing the types.
You have examples of types definition here.

Angular basic tutorial do not work with Windows?

I want to learn Angular so I started with there tutorial here, its really basic but that does not stop me from get ALOT of exception.
I installed latest and stable of every compinent Git, Node and python but when running
npm install
I got some exceptions, I then reinstalled components to a older specific version(no backward compability here). This got my a couple of steps but yet again other exceptions was thrown like this :
C:\Program Files
(x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.Cpp.Platform.t
argets(44,5): error MSB8020: The builds tools for v120 (Platform
Toolset = 'v12 0') cannot be found. To build using the v120 build
tools, either click the Proj ect menu or right-click the solution, and
then select "Update VC++ Projects..."
Why would it need MSBuild? Anyway, I changed the config like this
npm config set msvs_version 2012
And now I get even more exceptions!?, like these :
C:\Users\bob\angular-phonecat\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\ws>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
bufferutil.cc
C:\Users\bob\.node-gyp\4.2.3\include\node\v8.h(336): error C2988: unrecognizable template declaration/definition [C:\Users\bob\angular-phonecat\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\ws\build\bufferutil.vcxproj]
C:\Users\bob\.node-gyp\4.2.3\include\node\v8.h(336): error C2059: syntax error : 'using' [C:\Users\bob\angular-phonecat\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\ws\build\bufferutil.vcxproj]
C:\Users\bob\.node-gyp\4.2.3\include\node\v8.h(469): error C2988: unrecognizable template declaration/definition [C:\Users\bob\angular-phonecat\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\ws\build\bufferutil.vcxproj]
C:\Users\bob\.node-gyp\4.2.3\include\node\v8.h(469): error C2059: syntax error : 'using' [C:\Users\bob\angular-phonecat\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\ws\build\bufferutil.vcxproj]
C:\Users\bob\.node-gyp\4.2.3\include\node\v8.h(576): error C2061: syntax error : identifier 'WeakCallbackType' [C:\Users\bob\angular-phonecat\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\ws\build\bufferutil.vcxproj]
C:\Users\bob\.node-gyp\4.2.3\include\node\v8.h(642) : see reference to class template instantiation 'v8::PersistentBase<T>' being compiled
C:\Users\bob\.node-gyp\4.2.3\include\node\v8.h(637): error C2253: 'PersistentBase<T>' : pure specifier or abstract override specifier only allowed on virtual function [C:\Users\bob\angular-phonecat\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\ws\build\bufferutil.vcxproj]
C:\Users\bob\.node-gyp\4.2.3\include\node\v8.h(844): error C2253: 'Global<T>' : pure specifier or abstract override specifier only allowed on virtual function [C:\Users\bob\angular-phonecat\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\ws\build\bufferutil.vcxproj]
C:\Users\bob\.node-gyp\4.2.3\include\node\v8.h(847) : see reference to class template instantiation 'v8::Global<T>' being compiled
C:\Users\bob\.node-gyp\4.2.3\include\node\v8.h(852): error C2988: unrecognizable template declaration/definition [C:\Users\bob\angular-phonecat\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\ws\build\bufferutil.vcxproj]
C:\Users\bob\.node-gyp\4.2.3\include\node\v8.h(852): error C2059: syntax error : 'using' [C:\Users\bob\angular-phonecat\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\ws\build\bufferutil.vcxproj]
C:\Users\bob\.node-gyp\4.2.3\include\node\v8.h(915): error C2989: 'v8::HandleScope' : class template has already been declared as a non-class template [C:\Users\bob\angular-phonecat\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\ws\build\bufferutil.vcxproj]
C:\Users\bob\.node-gyp\4.2.3\include\node\v8.h(319) : see declaration of 'v8::HandleScope'
C:\Users\bob\.node-gyp\4.2.3\include\node\v8.h(949): error C2989: 'v8::EscapableHandleScope' : class template has already been declared as a non-class template [C:\Users\bob\angular-phonecat\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\ws\build\bufferutil.vcxproj]
C:\Users\bob\.node-gyp\4.2.3\include\node\v8.h(135) : see declaration of 'v8::EscapableHandleScope'
C:\Users\bob\.node-gyp\4.2.3\include\node\v8.h(979): error C2989: 'v8::Data' : class template has already been declared as a non-class template [C:\Users\bob\angular-phonecat\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\ws\build\bufferutil.vcxproj]
C:\Users\bob\.node-gyp\4.2.3\include\node\v8.h(74) : see declaration of 'v8::Data'
C:\Users\bob\.node-gyp\4.2.3\include\node\v8.h(1118): error C2989: 'v8::Script' : class template has already been declared as a non-class template [C:\Users\bob\angular-phonecat\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\ws\build\bufferutil.vcxproj]
C:\Users\bob\.node-gyp\4.2.3\include\node\v8.h(96) : see declaration of 'v8::Script'
C:\Users\bob\.node-gyp\4.2.3\include\node\v8.h(1559): error C2989: 'v8::StackTrace' : class template has already been declared as a non-class template [C:\Users\bob\angular-phonecat\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\ws\build\bufferutil.vcxproj]
C:\Users\bob\.node-gyp\4.2.3\include\node\v8.h(101) : see declaration of 'v8::StackTrace'
C:\Users\bob\.node-gyp\4.2.3\include\node\v8.h(1622): error C2989: 'v8::StackFrame' : class template has already been declared as a non-class template [C:\Users\bob\angular-phonecat\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\ws\build\bufferutil.vcxproj]
C:\Users\bob\.node-gyp\4.2.3\include\node\v8.h(100) : see declaration of 'v8::StackFrame'
C:\Users\bob\.node-gyp\4.2.3\include\node\v8.h(2031): error C2989: 'v8::Value' : class template has already been declared as a non-class template [C:\Users\bob\angular-phonecat\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\ws\build\bufferutil.vcxproj]
C:\Users\bob\.node-gyp\4.2.3\include\node\v8.h(108) : see declaration of 'v8::Value'
Is it really supose to be this hard to install Angular on a Windows 8.1 computer? Or are my environment faulted in any way?
How do I solve this problem? Have search alot but no help.
I've installed Node/NPM/Angular on 4 differents machines of mine. This is what I've done to make it all work:
Visual C++ 2005
Visual C++ 2008
Visual c++ 2010
Python 2.7
I don't know why, I've just followed the console erros and all worked.
Yes, it is hard. The reason for this is that (dependend on the node modules you install) node-gyp rebuilds things to make them run on the platform, in your case Windows 8.
There are lots and lots of questions how to solve these kind of errors. Prepare yourself to install Python and Visual Studio like explained here.
Good luck! Working with node.js on Linux or OSX is much easier....

Unable to pick up custom camel converter

I've created a new converter with the following structure:
package com.mycompany;
#Converter
public final class MyCustomConverter {
#Converter
public static TypeB convert(TypeA typeA) {
// do the conversion
}
}
I've also created in my src/main/java/resources folder the following package, META-INF.services.org.apache.camel and within that a TypeConverter file which just says:
com.mycompany
Within my route from TypeA I have got:
<convertBodyTo type="com.mycompany.TypeB" />
Yet my tests constantly fail to pick up the file and thus cannot find the converter, with the exception being:
Caused by: org.apache.camel.NoTypeConversionAvailableException: No
type converter available to convert from type: com.mycompany.TypeA to
the required type: com.mycompany.TypeB with value TypeA[value1="blah"]
Am I meant to do something else to get my test to pick up the TypeConverter file? Surely putting it in that resources folder with the exact structure adds it to the classpath and so it would be accessible.
Its recommended in the TypeConverter file to list the FQN of all the type conveters, eg
com.mycompany
Should be
com.mycompany.MyCustomConverter
This is also what we say on this page: http://camel.apache.org/type-converter.html
And could you check inside the generated JAR file of yours, that the META-INF/services/org/apache/camel directory is there, and that the TypeConverter file is present (and it is not in some directory like META-INF/org.apache.camel).
Also what is the runtime environment you use? Do you run Camel standalone, Tomcat, OSGi or something else?

XQuery 3.0 and maps in Saxon

I would like to experiment with map features in Saxon (http://www.saxonica.com/documentation/expressions/xpath30maps.xml), but I am unable to get past query compilation. Maybe I am missing some parameter or I use a wrong namespace, but I just can't find the right answer. This is my query code:
xquery version "3.0";
(: i have also tried http://www.w3.org/2005/xpath-functions/map, no difference :)
import module namespace map = "http://ns.saxonica.com/map";
map:get(map { 1 := 'aaa'}, 1)
invoked from command line:
"c:\Program Files\Saxonica\SaxonEE9.4N\bin\Query.exe" -s:play.xml -q:play2.xq" -qversion:3.0
The commands ends with error Cannot locate module for namespace "http://ns.saxonica.com/map"
When I leave out the module namespace map declaration, the error is Prefix map has not been declared, so I assume it must be.
Michael Kay has just posted a new blog entry with details on the Saxon Map implementation:
http://dev.saxonica.com/blog/mike/2012/01/#000188
You should use declare namespace instead of import module namespace for access to builtin functions. As far as I understand it, module import is for user-supplied modules only.
File map.xq:
declare namespace map="http://www.w3.org/2005/xpath-functions/map";
map:get(map { 1 := 'aaa'}, 1)
Works just fine:
> "C:\Program Files\Saxonica\SaxonEE9.4N\bin\Query.exe" -qversion:3.0 map.xq
<?xml version="1.0" encoding="UTF-8"?>aaa
I tried it with Saxon-EE 9.4.0.2J (the Java version) too, with the same effect.
Dunno if this helps, but the BaseX XQuery Processor also offers an implementation of Michael Kay's map proposal (still to be finalized by the W3): http://docs.basex.org/wiki/Map_Module

Resources