0

With angular2 RC.1 we created a custom Pipe and import some classes we need to create the pipe. Only now we migrate to final angular release and we are not able to import any of the classes we need.

import { isBlank, isString, isArray, StringWrapper, CONST } from 'angular2/src/facade/lang';
import { BaseException } from 'angular2/src/facade/exceptions';
import { ListWrapper } from 'angular2/src/facade/collection';
import { InvalidPipeArgumentException } from 'angular2/src/common/pipes/invalid_pipe_argument_exception';

Can someone tell us where we can found this classes, we are not able to find them, also not in the code. So what is happening with all them?

Michael Burger
  • 643
  • 1
  • 9
  • 17

1 Answers1

0

These were all refactored out of the public API purposefully around the RC6 timeframe, if I remember right. If you go through the source code on github you'll see that in most cases these exist but are no longer exported anywhere. There is a github issue going back to April of 2015 which highlights the thinking behind removing these internal utilities from public exposure:

Facades are here to abstract JS / Dart differences. We don't want to be in business of providing general helper functions as there are already plenty of libraries that do just that in a generic manner. Facades are minimal and for internal use - we don't want to grow those to sth generic as not to add too many bytes to the framework.

https://github.com/angular/angular/issues/3886

You'll either need to find libraries that implement what you need or build your own out.

isString, for example is a straightforward typeof: Check if a variable is a string

isBlank can be accomplished by checking if it's a string and then seeing if the thing is blank with a regex.

Exceptions would be derived from error: How do I extend a host object (e.g. Error) in TypeScript where you throw the new error.

You asked what happened to them, and I answered.

Community
  • 1
  • 1
silentsod
  • 8,165
  • 42
  • 40
  • Okay, but how can they not implement a BaseException or a InvalidPipeArgumentException if you will create our own Pipes, which is somehting what is supported at all. – Michael Burger Nov 14 '16 at 12:36
  • Instead of 'ListWrapper.forEachWithIndex' i can use simple 'Array.forEach((record, index) => {});' and that's okay But there should be a library which gives me a `isString` function? Do you know someone? And how can I throw an Exception on a Pipe? Before there was `BaseException` and `InvalidPipeArgumentException`, there should be something like that or not? – Michael Burger Nov 14 '16 at 14:03