Git Product home page Git Product logo

typescript-runtime's Introduction

TypeScript Helpers

This package currently includes TypeScript helpers, which are variables generated by TypeScript and used throughout the compiled code. For example, __extends helper allows to change implementation (if overriden) of the class inheritance.

Helpers are imported from official tslib NPM, and then exposed globally.

typescript-runtime's People

Contributors

barbatus avatar

Stargazers

Mehmet Ali "Mali" Akmanalp avatar  avatar

Watchers

James Cloos avatar Uri Goldshtein avatar  avatar  avatar

Forkers

mctep

typescript-runtime's Issues

Issues after upgrading from Meteor 1.4.4.2 to Meteor 1.5

I'm having the following stacktrace in my client code after upgrading from Meteor 1.4.4.2 to Meteor 1.5. The dependency on typescript runtime was upgraded from 1.0.0 to 1.0.1; I tried a downgrade with no success:

barbatus_typescript-runtime.js?hash=b9c22e4…:134 Uncaught TypeError: Object.setPrototypeOf called on null or undefined
    at setPrototypeOf (<anonymous>)
    at __extends (barbatus_typescript-runtime.js?hash=b9c22e4…:134)
    at project-selector.component.ts:91
    at project-selector.component.js (project-selector.component.ts:101)
    at fileEvaluate (modules-runtime.js?hash=8587d18…:343)
    at require (modules-runtime.js?hash=8587d18…:238)
    at component-selector.component.js (component-selector.component.ts:14)
    at fileEvaluate (modules-runtime.js?hash=8587d18…:343)
    at require (modules-runtime.js?hash=8587d18…:238)
    at shared.module.js (shared.module.ts:15)
    at fileEvaluate (modules-runtime.js?hash=8587d18…:343)
    at require (modules-runtime.js?hash=8587d18…:238)
    at work-item-modal.component.js (work-item-modal.component.ts:23)
    at fileEvaluate (modules-runtime.js?hash=8587d18…:343)
    at require (modules-runtime.js?hash=8587d18…:238)

The code in the project-selector.component.ts:

import { Mongo } from 'meteor/mongo';
import { Component, EventEmitter, AfterContentInit, AfterViewChecked, ElementRef, forwardRef, OnInit } from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
import { KitsuneComponent } from 'imports/ui/kitsune.component';
import { Project, Projects } from 'imports/api/project/project';
import * as _ from 'lodash';

export abstract class SelectorComponent<T> extends KitsuneComponent implements ControlValueAccessor, AfterContentInit, AfterViewChecked {
  selected: T | T[];
  settings: any;
  select: EventEmitter<T | T[]> = new EventEmitter<T | T[]>();

  protected dropdown: JQuery;
  protected onTouched: () => void;

  constructor(private element: ElementRef) {
    super();
  }

  ngAfterContentInit() {
    this.dropdown = jQuery(this.element.nativeElement).dropdown(_.assign(this.settings || {}, {
      onChange: (val: string | string[]) => {
        // TODO setting this.selected value will fail on safari for this and writeValue()
        this.selected = _.isArray(val) ? val.map(_ => this.getItem(_)) : this.getItem(val);
        this.select.emit(this.selected);
      }
    }));
  }

  removeSelected(item: any) {
    let deletingItem = typeof item === "string" ? item : item.toString();
    this.dropdown.dropdown("remove selected", deletingItem);
  }

  ngAfterViewChecked() {
    this.setValue();
  }

  writeValue(item: T | T[]): void {
    this.selected = item;
  }

  registerOnChange(fn: (_: T | T[]) => void): void {
    this.select.subscribe(fn);
  }

  registerOnTouched(fn: () => void): void {
    this.onTouched = fn;
  }

  getValue(item: T): string {
    return item.toString();
  }

  getItem(val: string): T {
    return <any>val;
  }

  protected setValue(value: T | T[] = this.selected) {
    if (value !== null && value !== undefined) {
      let val = _.isArray<T>(value) ? value.map(_ => this.getValue(_)) : this.getValue(value);
      if (!_.isEqual(val, this.dropdown.dropdown('get value')) || (_.isEmpty(val) ? !!this.dropdown.dropdown('get text') : !this.dropdown.dropdown('get text'))) {
        this.dropdown.dropdown('set selected', val);
        this.dropdown.find('select').val(val);
      }
    }
  }
}

// tslint:disable:component-selector no-forward-ref use-input-property-decorator use-output-property-decorator
@Component({
  selector: 'select[selector=project]',
  providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => ProjectSelectorComponent), multi: true }],
  inputs: ['options', 'selected', 'settings'],
  outputs: ['select'],
  template: `
    <option *ngFor="let option of options" value="{{ option._id }}">{{ option.name }}</option>
  `
})
// tslint:enable
export class ProjectSelectorComponent extends SelectorComponent<string> implements OnInit {
  options: Mongo.Cursor<Project>;

  constructor(element: ElementRef) {
    super(element);
  }

  ngOnInit() {
    this.options = this.options || Projects.find();
  }
}

Downgrading back to meteor 1.4.X seems to "fix" the problem. I also upgraded typescript to 2.3.2, and attempted to install the node tslib package.

A screenshot of the javascript is attached.

Any thoughts on how to debug this cryptic error?

screen shot 2017-07-07 at 5 10 36 pm

Is this package needed any more?

Since this has been resolved this package shouldn't be needed any more, right?

We should just be able to depend on tslib instead of this package and use --importHelpers.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.