Closed Arvraepe closed 7 years ago
Full trace:
component-interaction.service.ts:3Uncaught ReferenceError: decorate is not defined at component-interaction.service.ts:3 at Object.201 (component-interaction.service.ts:12) at webpack_require (bootstrap 750a398…:52) at Object.757 (app.module.ts:57) at webpack_require (bootstrap 750a398…:52) at Object.756 (main.ts:13) at webpack_require (bootstrap 750a398…:52) at Object.594 (src async:7) at webpack_require (bootstrap 750a398…:52) at Object.1230 (main.bundle.js:7) at webpack_require__ (bootstrap 750a398…:52) at webpackJsonpCallback (bootstrap 750a398…:23) at main.bundle.js:1
First I had a extends is not defined... I've included ts-helpers and now I'm getting decorate is not defined.
That's strange, ts-helpers should do the job... Can you post your ts-helpers version you are using? And also where are you including it in your app?
Thanjs
I'm using ts-helpers version 1.1.2 and I'm including it in de main.ts file... couldn't really figure out where else to put it. Just put "import 'ts-helpers'" the extends error was gone, but decorate appeared
Weird... Are you sure it is happening because of this library? Can you maybe create a plunkr so I can have a look?
Thanks
It's gonna be pretty hard to make a plunkr, but to be honest I guess this isn't because of the framework. I'm also fairly new to angular2 and I f*ck up alot of these things at the moment...I've been looking into the issue and the chance that your framework is doing something wrong is very very small in my opinion. Maybe mark this as won't fix, I'll try to figure out what's wrong, if I find a solution I'll post it here for people having the same issue later.
Okay, thanks.
Btw just by looking at the trace you posted above I cannot see that it's failing somewhere in files of this library but at your application file component-interaction.service.ts line 3. So just double check that file maybe there will be some hint =)
Thanks! Hope I can find the issue before I get too annoyed to abandon all hope.
Regarding the original error: is there any way to use tslib
instead if ts-helpers
(since I use it for other stuff)?
Yes you can use tslib for sure (guy here confirmed #126)
yeah, i've seen that, but I have no idea how he did it :P. afaik it doesn't work with webpack (because the library would have to be compiled with importHelpers
flag)
Actually library should be only compiled with flag "noEmitHelpers": true
to exclude that code.
And than when you compiling you should set that flags in your tsconfig.json:
"noEmitHelpers": true,
"importHelpers": true,
And do not forget to install tslib
with package.json
I have it set up like that, and it works for my library that is compiled with importHelpers: true
. But webpack can't see that it should use tslib
for your library (because it just uses the function, and doesn't import it).
e.g:
from transpiled code from my library:
import * as tslib_1 from "tslib";
var Class = (function (_super) {
tslib_1.__extends(Class, _super);
}(BaseClass));
webpack generates something like:
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_tslib__ = __webpack_require__(16);
var Class= (function (_super) {
__WEBPACK_IMPORTED_MODULE_0_tslib__["c" /* __extends */](Class, _super);
}(BaseClass));
I already did somewhere working configuration with tslib
but cannot find it for now. Will check and post here once found =)
Okay after a little bit of researching I found that it is really required for library to be compiled with option importHelpers: true
as well =)
However this option is available only since ts 2.1+ so it is not possible currently to do for this version (v2). But I have beta branch (and npm channel) where I upgraded TS and angular together so there I can add this compilation option (actually I already added it there (: ).
Really wondering now how that guy here (#126) made it work with v2 =)
/cc @rachelxi Can you please tell us you were able to utilize tslib with this lib? Thanks
@gund I installed tslib and just follow the instructions to do the tsconfig.json file: https://github.com/Microsoft/tslib My tsconfig.json file goes as:
{ "compileOnSave": true, "compilerOptions": { "target": "es5", "module": "commonjs", "moduleResolution": "node", "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "lib": [ "es2015", "dom" ], "noImplicitAny": true, "suppressImplicitAnyIndexErrors": true, "importHelpers": true, "noEmitHelpers": true, "paths": { "tslib": [ "node_modules/tslib/tslib.d.ts" ] }, "baseUrl": "./" } }
And I included tslib path in SystemJS to load the module. And it does compile well with typescript 2.1.5.
@gund And I don't know if it is proper to ask under this thread, but is it possible to catch all requests for 401 unauthorized response, then retry the requests on authorization success (e.g. refresh token success and get valid new access token back) ?
@rachelxi Thanks for posting your config hope guys can try and it will help them.
Regarding your second question I believe that should be possible - it's only matter of how you organize your work with Observables. If you want you can create new issue and we can try to find a solution there =)
Well I tried in a new project to use it with tslib and can confirm that it is not going to work with version 2 (because it was compiled with ts 2.0.x where tslib was not supported).
But beta version works fine with tslib so if you need one - use beta (and keep in mind that beta version uses angular 4-beta).
Getting this error when trying to include the module and trying to add interceptors