Ionic-native: Typescript Error Cannot find name 'unknown'.

Created on 22 Sep 2019  Â·  6Comments  Â·  Source: ionic-team/ionic-native

I'm submitting a ... (check one with "x")
[x] bug report

image

$ ionic serve
> ionic-app-scripts serve --address localhost --port 8100 --livereload-port 35729 --dev-logger-port 53703 --nobrowser
[app-scripts] [16:17:45]  ionic-app-scripts 3.2.4 
[app-scripts] [16:17:45]  watch started ... 
[app-scripts] [16:17:46]  build dev started ... 
[app-scripts] [16:17:46]  clean started ... 
[app-scripts] [16:17:46]  clean finished in 101 ms 
[app-scripts] [16:17:46]  copy started ... 
[app-scripts] [16:17:47]  copy finished in 889 ms 
[app-scripts] [16:17:47]  deeplinks started ... 
[app-scripts] [16:17:50]  deeplinks finished in 2.83 s 
[app-scripts] [16:17:50]  transpile started ... 
[app-scripts] [16:18:06]  typescript: node_modules/@ionic-native/core/decorators/common.d.ts, line: 10 
[app-scripts]             Cannot find name 'unknown'. 
[app-scripts]        L9:  export declare function wrapPromise(pluginObj: any, methodName: string, args: any[], opts?: CordovaOptions): Promise<unknown>;
[app-scripts]       L11:   * Checks if plugin/cordova is available


Ionic Framework: ^3.9.2
Ionic App Scripts: 3.2.4
Angular Core: ^5.2.11
Angular Compiler CLI: ^5.2.11
Node: 11.5.0
OS Platform: macOS High Sierra

Most helpful comment

Good point!
But in my case upgrading typescript from 2.9.2 to 3.6.4 leads to the following error during ionic serve :-/

[ng] ERROR in The Angular Compiler requires TypeScript >=2.7.2 and <2.10.0 but 3.6.4 was found instead.
[ng] ℹ 「wdm」: Failed to compile.

All 6 comments

I could fix this issue in first place by replacing Promise<unknown> with Promise<any> in "core/decorators/common.d.ts" file.
I'm pretty sure it is not a proper solution but the error vanished. Still not sure if there will be any side effects...

Which TypeScript version do you use?
In my project I used version 2.6.2 and had the same issue. After upgrading to the latest version (3.6.3) it is working fine.

Good point!
But in my case upgrading typescript from 2.9.2 to 3.6.4 leads to the following error during ionic serve :-/

[ng] ERROR in The Angular Compiler requires TypeScript >=2.7.2 and <2.10.0 but 3.6.4 was found instead.
[ng] ℹ 「wdm」: Failed to compile.

I could fix this issue in first place by replacing Promise<unknown> with Promise<any> in "core/decorators/common.d.ts" file.
I'm pretty sure it is not a proper solution but the error vanished. Still not sure if there will be any side effects...

the only solution I found that worked. Thanks!

I could fix this issue in first place by replacing Promise<unknown> with Promise<any> in "core/decorators/common.d.ts" file.
I'm pretty sure it is not a proper solution but the error vanished. Still not sure if there will be any side effects...

Happens to me as well, using typescript 2.6.2 due to angular-cli limitations. The temporary fix by dominikse worked for me

Try to add this to a Typescript declaration file of your project:

declare type unknown = any;

Was this page helpful?
0 / 5 - 0 ratings

Related issues

goleary picture goleary  Â·  3Comments

danbucholtz picture danbucholtz  Â·  3Comments

FdezRomero picture FdezRomero  Â·  4Comments

ajcrites picture ajcrites  Â·  3Comments

icchio picture icchio  Â·  3Comments