ng2-ui / datetime-picker

Angular2 DateTime Picker
https://ng2-ui.github.io/#/datetime-picker
MIT License
121 stars 62 forks source link

Problem with TypeScript #24

Closed rafaelcb21 closed 7 years ago

rafaelcb21 commented 7 years ago

This appeared to me the following errors after I run my gulpfile.js

C:/Users/R/Documents/projects/myapp/node_modules/ng2-datetime-picker/dist/datetime-picker.component.d.ts(21,14): error TS1005: '=' expected. C:/Users/R/Documents/projects/myapp/node_modules/ng2-datetime-picker/dist/datetime-picker.component.d.ts(21,18): error TS1005: ';' expected. C:/Users/R/Documents/projects/myapp/node_modules/ng2-datetime-picker/dist/datetime-picker.component.d.ts(22,14): error TS1005: '=' expected. C:/Users/R/Documents/projects/myapp/node_modules/ng2-datetime-picker/dist/datetime-picker.component.d.ts(22,19): error TS1005: ';' expected. C:/Users/R/Documents/projects/myapp/node_modules/ng2-datetime-picker/dist/datetime-picker.component.d.ts(23,14): error TS1005: '=' expected. C:/Users/R/Documents/projects/myapp/node_modules/ng2-datetime-picker/dist/datetime-picker.component.d.ts(23,17): error TS1005: ';' expected. C:/Users/R/Documents/projects/myapp/node_modules/ng2-datetime-picker/dist/datetime-picker.component.d.ts(24,14): error TS1005: '=' expected. C:/Users/R/Documents/projects/myapp/node_modules/ng2-datetime-picker/dist/datetime-picker.component.d.ts(24,19): error TS1005: ';' expected. [10:19:14] TypeScript: 8 syntax errors

allenhwkim commented 7 years ago

Strange, I never got these errors. Anyone has the same issue?

rafaelcb21 commented 7 years ago

I found the problem. My typescript was a version below 2, my gulp-typescript uses a typescript also below the version 2, and after solved the problem, another appeared, saying he was not being found jQuery. For this I installed the jQuery typings.

Follow the steps executed:

$ npm install --save typescript@^2.0.0

gulpfile.js var gulpTypescript = require('gulp-typescript'); var tsconfig = gulpTypescript.createProject('tsconfig.json', { typescript: require('typescript') });

$ typings install dt~jquery --global --save

After the above steps, I could use the ng2-datetime-picker.

Thank you!!!

smartm0use commented 7 years ago

I have typescript v2.0.2 and gulp-typescript v2.13.6 and even typings for jQuery, but i get the same errors.

allenhwkim commented 7 years ago

How about not using typings but node_modules only,. npm install @types/jquery. I haven't tried with jQuery, but others seems fine for me.

allenhwkim commented 7 years ago

I do not use gulp at all personally. Is there a way to reproduce this error without using gulp. e.g $ tsc.

I run $tsc, but I don't see any errors on my project.

rohitbatra20 commented 7 years ago

I see a compilation error with the newer version of the datetime-picker i.e. 0.9.1 The error is in the class : datetime-picker-component.d.ts as mentioned above. I am using gulp: 3.9.1 and typings: 1.4.0.

allenhwkim commented 7 years ago

This package does not use typings nor gulp, but typescript 2.0.0 only for compile.

Any one who use typings and gulp can help this issue?

allenhwkim commented 7 years ago

How about this?

$ npm uninstall typescript # for 2.0
$ npm install typescript 
kat3su commented 7 years ago

I'm having the exact same problem. And change to Typescript ^2.0.0 fixed this,

However, I still want to use Typescript ^1.8

I think the issue was you are missing a few variable declarations in your datetime-picker.component.ts which lead to readonly tag when compiled with Typescript 2.0.0

I will try to add to see if it fixed the issue,

private year;
private month;
private day;
private today;

For now, I just have to delete readonly in datetime-picker.component.d.ts (Don't really need readonly anyway)

allenhwkim commented 7 years ago

@lthh89vt thanks for your feedback. If you find a solution for 1.8, plz make PR

kat3su commented 7 years ago

@allenhwkim Created PR. Not the best thing to do but will do the work, suggestions made in the PR as well.

allenhwkim commented 7 years ago

PR is merged. Closing