When i try to use ng-select2/ng2-select/ng2-select2 with angular 5 project #types/select2 package gives a error - jquery-select2

ERROR in node_modules/#types/select2/index.d.ts(163,18): error TS2430: Interface 'AjaxOptions' incorrectly extends interface 'Pick string)' is not assignable to type 'string'.
Type '(params: QueryOptions) => string' is not assignable to type 'string'.

After reasearching a lot and trying to find a solution on my own (due to lack of solutions on internet), I found a fix at least for my issue.
I will share it with you just in case.
On my case the root cause of this was an entry on '.angular-cli.json' that was missing and because of this the 'select2' js file was not being uploaded.
So I just added this line to the .angular-cli.json:
"scripts": [
"../node_modules/jquery/dist/jquery.js",
"../node_modules/jqueryui/jquery-ui.js",
"../node_modules/select2/dist/js/select2.full.js",
This solved my issue and now I'm able to use the select2 control.
Note that you might need to add the .css for select2 as well ;).
Good luck!.

Related

What Is the Replacement for the #Decorator Directive?

I'm upgrading my dart code from angular 1 to angular 4.
This line now gives an error in my IDE:
#Decorator(selector: '[citable]')
Annotation must either be a const variable or const construction invocation.
I was able to fix this error on #Input by including the formDirective. What directive should I use for #Decoration? I can't find any recent mention of #Decorator in a web search for AngularDart.
I tried adding const after selector:. Then I get a syntax error.
The replacement is #Directive.

Dart Polymer : Type X is not a subtype of type Y

I develop my application with Dart and Polymer on PyCharm. I currently have an error :
Exception: type 'ObservableList<DrugFilterItem>' is not a subtype of type 'ObservableList<DrugCompareItem>' of '__$orderFilterList#51385934'
ObservableList is from package:observe/src/observable_list.dart
DrugFilterItem is from package:synmed/drug_elements/views/drug_filter_menu.dart
ObservableList is from package:observe/src/observable_list.dart
DrugCompareItem is from package:synmed/drug_elements/views/drug_search_toolbar.dart
DrugFilterItem and DrugCompareItem are both custom classes, DrugCompareItem extends DrugFilterItem, and the line designed by the error is :
ObservableList<DrugCompareItem> orderFilterList = new ObservableList<DrugFilterItem>();
The problem suddenly happened today : I installed Pycharm 2016.3 and tried to code, but I had an error with the package shadow, which I solved. Since, I have this error which I supposed came from a problem with the packages as the code didn't change from before to after.
What I have found for now is nothing in fact, I read a lot of post on this kind of error, one of the recurrent subject was the imports but I didn't find any problem with this. I am using Dart 1.20.1 and
polymer: "<=0.16.4+1"
core_elements: "<=0.7.1+3"
paper_elements: "<=0.7.1"
Do anyone has any clue for me? Thanks!
Sounds like https://github.com/dart-lang/sdk/issues/14972#issuecomment-108402835
I believe this is working as intended. A List is not assignable to a List, even if it only contains Apples.
There are several ways to work around this:
iterable.map((x) => x) (removing the generic type),
new List<MethodMirror>.from(iterable)
new MyIterableWrapper<MethodMirror>(iterable) (where the iterable-wrapper that would need to be written).

Which way to go with these bugs

Compiling Dart app to js these two errors arise:
Nº1:
InvalidStateError: Failed to call 'register' on 'Document' for type 'polymer-element': a type with that name is already registered.
Nº2:
Breaking on exception: TypeError: Object #<qE> has no method 'vL'
The object qE is created by dart2js.
How to find the solution?
There are appropriate tools to find the solution?
Thanks for advance !
I heard N1 occurs when Angular and Polymer is used in the same app. This is a known bug.
related open issues:
- duplicate polymer-element registration should not break the app
- Get error "Uncaught InvalidStateError: Failed to call 'register' on 'Document' for type 'polymer-element'
For the N2 use pub build --mode=debug so you get unmangled names and then use one of the available strategies to fix the problem (use of MirrorsUsed, #observable, #reflectable)

Debugging MirrorsUsed

I'm trying to figure out which libraries I need to pass to #MirrorsUsed to get my app compiled and working. Sometimes, it's easy to figure out which library may be missing since a descriptive error is thrown such as Uncaught Unsupported operation: Cannot find class for: NgAttr .
Other times, I get a more obscure message, such as NullError: Cannot call "$gt" on null with no clue as to which library I may be omitting. Is there a better approach to this, besides trial and error?
In case you're wondering, this is an angular app and this is how I currently have it configured:
#MirrorsUsed(targets: const[
'angular',
'angular.core',
'angular.core.dom',
'angular.filter',
'angular.perf',
'angular.directive',
'angular.routing',
'angular.core.parser.dynamic_parser',
'angular.core.parser.lexer',
'todo',
'perf_api',
'List',
'NodeTreeSanitizer',
'PlaybackHttpBackendConfig'
],
override: '*')
import 'dart:mirrors';
Use
pub build --mode=debug
this does tree shaking but retains (mostly) the original Dart names.
Then debugging the generated JavaScript usually lets deduce the source of the exception.
EDIT
IMHO these are not necessary anymore, because they were added to #MirrorsUsed in the Angular libs.
'angular',
'angular.core',
'angular.core.dom',
'angular.filter',
'angular.perf',
'angular.directive',
'angular.routing',
'angular.core.parser.dynamic_parser',
'angular.core.parser.lexer',

DomainTypes in XmlProvider FS0039 not defined

I am trying to use the FSharp.Data XmlProvider.
According to the samples you can access nested types and create a function that will receive a parameter of one of those types.
https://github.com/fsharp/FSharp.Data/blob/master/samples/library/XmlProvider.fsx (line 177)
However when I try to do the following:
type businessesT = XmlProvider<"Businesses.xml">
type businessT = businessesT.DomainTypes.Business
let testfunc (b:businessesT.DomainTypes.Business) =
b
It seems to work until I actually compiles and then I get
error FS0039: The type 'Business' is not defined
UPDATE:
The problem can be reproduced with the sample from FSharp.Data (XmlProvider.fsx)
adding a type alias after line 205
type Rss = XmlProvider<"http://tomasp.net/blog/rss.aspx">
type test = Rss.DomainTypes.Channel
What is strange is that the sample with the printDiv function is working...
This is most likely caused by some problem with loading the type provider - if the compiler fails to load the type provider, then it cannot run it and so none of the provided types like Business would be defined.
Are you using #r in a script file, or are you referencing the type provider through "Add References" in a project? If you're using #r, check if there is any error message on that line. In case of project, check other error messages output by the compiler.
I already listed some common reasons why type provider fails to load in another answer.
This was probably the same problem as "type provider" not recognized when building project, which has been fixed in FSharp.Data 1.1.10

Resources