Describe the bug
Following docs here: https://aws-amplify.github.io/docs/js/angular#option-1-configuring-the-amplify-provider-with-every-amplify-js-module
Including Amplify to main.ts results in a build error:
ERROR in node_modules/@aws-amplify/analytics/lib-esm/Analytics.d.ts(50,46): error TS2304: Cannot find name 'unknown'
To Reproduce
ng serve
on angular cli build
Expected behavior
The app to compile
Screenshots
Environment
System:
OS: macOS High Sierra 10.13.6
CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
Memory: 540.07 MB / 8.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 9.10.1 - /usr/local/bin/node
npm: 5.6.0 - /usr/local/bin/npm
Browsers:
Chrome: 78.0.3904.87
Firefox: 69.0.3
Safari: 13.0.3
npmPackages:
@angular-devkit/build-angular: ~0.6.1 => 0.6.8
@angular/animations: ^6.0.0 => 6.1.10
@angular/cli: ~6.0.1 => 6.0.8
@angular/common: ^6.0.0 => 6.1.10
@angular/compiler: ^6.0.0 => 6.1.10
@angular/compiler-cli: ^6.0.0 => 6.1.10
@angular/core: ^6.0.0 => 6.1.10
@angular/forms: ^6.0.0 => 6.1.10
@angular/http: ^6.0.0 => 6.1.10
@angular/language-service: ^6.0.0 => 6.1.10
@angular/platform-browser: ^6.0.0 => 6.1.10
@angular/platform-browser-dynamic: ^6.0.0 => 6.1.10
@angular/router: ^6.0.0 => 6.1.10
@types/jasmine: ~2.8.6 => 2.8.16
@types/jasminewd2: ~2.0.3 => 2.0.8
@types/node: ~8.9.4 => 8.9.5
aws-amplify: ^1.2.4 => 1.2.4
aws-amplify-angular: ^3.1.4 => 3.1.4
codelyzer: ~4.2.1 => 4.2.1
core-js: ^2.5.4 => 2.6.10
jasmine-core: ~2.99.1 => 2.99.1
jasmine-spec-reporter: ~4.2.1 => 4.2.1
karma: ~1.7.1 => 1.7.1
karma-chrome-launcher: ~2.2.0 => 2.2.0
karma-coverage-istanbul-reporter: ~1.4.2 => 1.4.3
karma-jasmine: ~1.1.1 => 1.1.2
karma-jasmine-html-reporter: ^0.2.2 => 0.2.2
protractor: ~5.3.0 => 5.3.2
rxjs: ~6.3.3 => 6.3.3
ts-node: ~5.0.1 => 5.0.1
tslint: ~5.9.1 => 5.9.1
typescript: ~2.7.2 => 2.7.2
zone.js: ^0.8.26 => 0.8.29
npmGlobalPackages:
@angular/cli: 6.0.1
@aws-amplify/cli: 3.17.0
@magnolia/cli: 2.1.0
@vue/cli: 3.8.2
@vue/devtools: 5.1.0
babel-cli: 6.24.1
bower: 1.7.7
browser-sync: 2.26.3
eslint: 3.18.0
grunt-cli: 0.1.13
gulp: 3.9.0
json-server: 0.14.2
mocha: 3.2.0
n: 2.1.0
node-sass: 4.5.2
nodemon: 1.10.2
npm: 5.6.0
protractor: 5.4.2
rxjs-tslint: 0.1.3
spoof: 1.1.0
svgo: 1.0.5
typescript: 3.5.1
Hello @chrisj-skinner any workarounds for this? Can I downgrade or something?
I haven't found any solutions to removing the above error - however if I save a (any) .ts file after I get the above failing message, the app rebuilds and then produces a Complied successfully
message.
NOTE: in the below screenshot the 'save' of the .ts file was done after I received the Failed to compile
message.
The app loads up - but I do get some console error messages regarding state
when using certain amplify components. But not sure that is related to this compile error of not. 🤔
For me, this was because Angular 5 uses typescript 2, but amplify uses Typescript 3.
Change to tsconfig.json
"compilerOptions": {
"skipLibCheck": true // add this
Interesting. I had to downgrade the Auth app I was interested in using. How
will this affect other errors though
On Fri, 8 Nov 2019, 22:45 axvolfson, notifications@github.com wrote:
For me this was because Angular 5 uses typescript 2, but amplify uses
Typescript 3.
Change to tsconfig.json
"compilerOptions": { "skipLibCheck": true,// add this—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/aws-amplify/amplify-js/issues/4345?email_source=notifications&email_token=AHDNOOZ67CSF5DJTCLA7WL3QSXMWPA5CNFSM4JJEVTQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDTN4CI#issuecomment-552001033,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AHDNOOZQJSQR46CPE3AS6ZDQSXMWPANCNFSM4JJEVTQQ
.
@chrisj-skinner Does @axvolfson resolve your issue? Also, I do see that there you are using Angular 6, did you add the two code snippets under the Angular 6+ support? Please let us know
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically closed because of inactivity. Please open a new issue if are still encountering problems.
Don't mean to necrobump this issue. But @axvolfson 's solution didn't work for me and I'm sure I'm not the only one maintaining weird legacy npm projects.
For me the issue was that mime.lookup()
was causing an error. However when I changed it to the new mime syntax that caused Cannot find name 'unknown'
.
Definitely related to other NPM deps using different versions of mime.
I simply added //@ts-ignore
to the lines preceding any mime.lookup()
.
In short, I hate typescript and //@ts-ignore
is a useful tool for solving problems like these.
Most helpful comment
For me, this was because Angular 5 uses typescript 2, but amplify uses Typescript 3.
Change to tsconfig.json