skatejs: 4.1 doesn't work with Typescript
The new implementation of API on prototype doesn’t work with Typescript which is very unfortunate.
Problem is probably in Typescript implementation of extends
.
It works only with old skate js API’s ( define and definition via object )
Short description of possible issue:
-
problem starts here ( within
connectedCallback
): https://github.com/skatejs/skatejs/blob/master/src/api/component.js#L186 -
which calls
syncPropsToAttrs(this)
, wherethis
is the custom element constructor. Problem is that there is noprops
static property on it so this call (https://github.com/skatejs/skatejs/blob/master/src/api/component.js#L34) will returnundefined
and when you callundefined
.forEach well it throws…
Here is the repo which reproduces the error: https://github.com/Hotell/skate-and-raw-WC
and here is skate component https://github.com/Hotell/skate-and-raw-WC/blob/master/src/app/skate-wc/yo-smile/YoSmile.tsx
just hit yarn
|| npm i
to install dependencies, then yarn start
|| npm start
and open devTools, to debug it.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 1
- Comments: 20 (18 by maintainers)
FYI: https://github.com/Microsoft/TypeScript/pull/12488 this issue will be solved in TypeScript 2.2
@Hotell I think you should give it a try. It follows the original pattern of TypeScript __extends.
But yes, now I understand the reason why static class member should be enumerable=false and I agree that this is something that TypeScript will needs to address. I like your solution better.
We’ll be discussing this in the near future. This might be something to keep an eye out for in the 2.2 timeframe.
yup (breaking)change on TS side is needed
@Hotell I Yes, I like it.
When you tried my version did you check the one that skips over ‘length’, ‘name’, ‘prototype’ ?
Object.getOwnPropertyNames(b).forEach(function(p) { if (-1 === ['length', 'name', 'prototype'].indexOf(p)) { d[p] = b[p]; } });
nice @vvakame! ,
you don’t need to import tslib manually, just hit
"importHelpers": true,
in tsconfig.json and just override the global._extends as you do alreadyI made work around. check this change.
also just one more note, older versions of skate did work with Typescript