Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Having trouble using this in AoT compiled apps #68

Open
pdavin-zz opened this issue Feb 2, 2017 · 1 comment
Open

Having trouble using this in AoT compiled apps #68

pdavin-zz opened this issue Feb 2, 2017 · 1 comment

Comments

@pdavin-zz
Copy link

I'm having trouble using this in our AoT (Ahead of Time compilation) build. AoT is necessary for any Angular 2 app that wants decent production performance.

I think the difficulty is mainly due to absence of *.d.ts files for your library. This causes ngc, when compiling my app, to try to also compile your library's *.ts files. This doesn't work since they're not under rootDir - since it's good practice to keep third party libraries in a separate directory tree from your own app code.

I tried compiling the library with 'npm run ngc', but it seems that is broken in a couple ways.

The "files" target in tsconfig-aot.json references integration-test/ files - that directory doesn't exist in the git clone. I changed files to [ "src/main.ts", "src/datepicker.module.ts"] and got past this issue.

Also noImplicitAny: true is turned on, but the code doesn't pass noImplicitAny rules. Turning that off got me past this issue.

Also the compiler option "declaration": true should be present in order to create .d.ts files. When I turn this on however I get these errors:
Error: Error at /.../Angular-2-Datepicker/src/datepicker.component.ts:331:33: Public property 'dateFormat' of exported class has or is using private name 'DateFormatFunction'.
Error at /.../Angular-2-Datepicker/src/datepicker.component.ts:702:43: Return type of public method from exported class has or is using private name 'ValidationResult'.
Error at /.../Angular-2-Datepicker/src/datepicker.component.ts:722:40: Return type of public method from exported class has or is using private name 'ValidationResult'.

This is because the interfaces are used in the types of public @inputs. Adding "export" before the interface declarations fixed this.

After all this I was able to generate .d.ts files for the library. However I'm still having ngc compilation issues importing the DatepickerModule - but that is probably outside the scope of this issue.

@zskhan
Copy link

zskhan commented Feb 7, 2017

This issue is also resolved in this PR #52
Its in review. If you want it on urgent basis you can use ng-material-datepicker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants