kamilkp / ng2-vs-for

Virtual Scroll repeater for Angular2
MIT License
42 stars 25 forks source link

error on compiling #1

Closed iBasit closed 8 years ago

iBasit commented 8 years ago

I'm using version 1.0.11 to go with angular2 beta.

I want to use this plugin for ionic2 app. When I add the following line in my app.ts file. I get the following errors:

import {VsFor} from 'ng2-vs-for';

TypeScript error: app/app.ts(4,21): Error TS2307: Cannot find module 'ng2-vs-for'.
TypeScript error: app/app.ts(23,3): Error TS2345: Argument of type '{ templateUrl: string; providers: (typeof gq | typeof Api)[]; directive: any[]; config: {}; }' is not assignable to parameter of type 'AppMetadata'.
  Object literal may only specify known properties, and 'directive' does not exist in type 'AppMetadata'.

/Users/basit/projects/site.com/github/mobile-app/node_modules/ng2-vs-for/src/ng2-vs-for.ts:1
import {
^
ParseError: 'import' and 'export' may appear only with 'sourceType: module'
kamilkp commented 8 years ago

Its an issue with your tsconfig.json. Can you try with my tsconfig? Its probably moduleResolution or compiler target stuff. Also you can try requiring the transpiled js file

Kamil Pękala

Dnia 05.05.2016 o godz. 19:39 Basit notifications@github.com napisał(a):

I'm using version 1.0.11 to go with angular2 beta.

I want to use this plugin for ionic2 app. When I add the following line in my app.ts file. I get the following errors:

import {VsFor} from 'ng2-vs-for';

TypeScript error: app/app.ts(4,21): Error TS2307: Cannot find module 'ng2-vs-for'. TypeScript error: app/app.ts(23,3): Error TS2345: Argument of type '{ templateUrl: string; providers: (typeof gq | typeof Api)[]; directive: any[]; config: {}; }' is not assignable to parameter of type 'AppMetadata'. Object literal may only specify known properties, and 'directive' does not exist in type 'AppMetadata'.

/Users/basit/projects/GlobalQuran.com/github/mobile-app/node_modules/ng2-vs-for/src/ng2-vs-for.ts:1 import { ^ ParseError: 'import' and 'export' may appear only with 'sourceType: module'

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub

iBasit commented 8 years ago

Following is ionic2 tsconfig, I'm not sure how to add your plugin. usally it picks it up automatically

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true
  },
  "filesGlob": [
    "**/*.ts",
    "!node_modules/**/*"
  ],
  "exclude": [
    "node_modules",
    "typings/main",
    "typings/main.d.ts"
  ],
  "compileOnSave": false,
  "atom": {
    "rewriteTsconfig": false
  }
}
iBasit commented 8 years ago

After just pointing it to directly to the file, rather then module name. I get following error..

/Users/basit/projects/site.com/github/mobile-app/node_modules/ng2-vs-for/src/ng2-vs-for.ts:1
import {
^
ParseError: 'import' and 'export' may appear only with 'sourceType: module'
iBasit commented 8 years ago

Following fix have solved the issue.

https://forum.ionicframework.com/t/import-and-export-may-appear-only-with-sourcetype-module/47539/7