Cannot find name XYX, after updating project from {N} 2.4 to 3.0


#1

Hi there!

I have a project which was on nativescript 2.4 and i followed the instructions below to update it to 3.0:
http://docs.nativescript.org/angular/releases/upgrade-instructions

My project (commited on version 2.4) is on github:

Every step of the update process finished successfully.

But when I try to npm run android, I get the following errors.
I would kindly apreciate some help.

Thanks,
Thiago!

D:\Documents\Desenvolvimento\NativeScript\workspace\BudgetSMS>tns run android
Executing before-prepare hook from D:\Documents\Desenvolvimento\NativeScript\workspace\BudgetSMS\hooks\before-
prepare\nativescript-dev-typescript.js
Found peer TypeScript 2.1.6
app/modules/shared/borderless-btn.directive.ts(3,24): error TS2307: Cannot find module 'ui/button'.

app/modules/shared/borderless-btn.directive.ts(4,27): error TS2307: Cannot find module 'platform'.

app/modules/shared/borderless-btn.directive.ts(5,30): error TS2307: Cannot find module 'application'.

app/modules/shared/side-drawer-page/side-drawer-page.component.ts(7,22): error TS2307: Cannot find module 'ui/
page'.
app/modules/shared/side-drawer-page/side-drawer-page.component.ts(8,34): error TS2307: Cannot find module 'pla
tform'.
app/modules/shared/side-drawer-page/side-drawer-page.component.ts(9,28): error TS2307: Cannot find module 'ui/
action-bar'.
app/modules/shared/sqlite/db.ts(46,31): error TS2304: Cannot find name 'Promise'.

app/modules/shared/sqlite/db.ts(51,59): error TS2304: Cannot find name 'Promise'.
app/modules/shared/sqlite/db.ts(56,30): error TS2304: Cannot find name 'Promise'.
app/modules/sms/broadcast.receiver.android.ts(1,30): error TS2307: Cannot find module 'application'.
node_modules/@angular/common/src/directives/ng_class.d.ts(48,34): error TS2304: Cannot find name 'Set'.

node_modules/@angular/common/src/pipes/async_pipe.d.ts(44,38): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/application_init.d.ts(16,18): error TS2304: Cannot find name 'Promise'.

node_modules/@angular/core/src/application_ref.d.ts(116,67): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/application_ref.d.ts(132,101): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/application_ref.d.ts(158,67): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/application_ref.d.ts(160,101): error TS2304: Cannot find name 'Promise'.

node_modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.d.ts(24,15): error TS2304: Can
not find name 'Map'.
node_modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.d.ts(28,16): error TS2304: Can
not find name 'Map'.
node_modules/@angular/core/src/di/reflective_provider.d.ts(88,123): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/di/reflective_provider.d.ts(88,165): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/facade/lang.d.ts(12,17): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/facade/lang.d.ts(13,17): error TS2304: Cannot find name 'Set'.

node_modules/@angular/core/src/linker/compiler.d.ts(53,49): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/linker/compiler.d.ts(61,65): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/linker/ng_module_factory_loader.d.ts(14,34): error TS2304: Cannot find name 'Pr
omise'.
node_modules/@angular/core/src/linker/system_js_ng_module_factory_loader.d.ts(28,25): error TS2304: Cannot fin
d name 'Promise'.
node_modules/@angular/core/src/util/lang.d.ts(8,53): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router/src/config.d.ts(307,62): error TS2304: Cannot find name 'Promise'.

node_modules/@angular/router/src/interfaces.d.ts(78,99): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router/src/interfaces.d.ts(157,109): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router/src/interfaces.d.ts(227,115): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router/src/interfaces.d.ts(297,89): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router/src/interfaces.d.ts(367,50): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router/src/router.d.ts(392,70): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router/src/router.d.ts(414,59): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router/src/utils/collection.d.ts(35,58): error TS2304: Cannot find name 'Promise'.
node_modules/nativescript-angular/node_modules/@angular/common/src/directives/ng_class.d.ts(46,34): error TS23
04: Cannot find name 'Set'.
node_modules/nativescript-angular/node_modules/@angular/common/src/pipes/async_pipe.d.ts(44,38): error TS2304:
 Cannot find name 'Promise'.
node_modules/nativescript-angular/node_modules/@angular/compiler/src/aot/compiler.d.ts(32,38): error TS2304: C
annot find name 'Promise'.

node_modules/nativescript-angular/node_modules/@angular/compiler/src/aot/compiler.d.ts(43,32): error TS2304: C
annot find name 'Map'.
node_modules/nativescript-angular/node_modules/@angular/compiler/src/aot/compiler_host.d.ts(19,33): error TS23
04: Cannot find name 'Promise'.
node_modules/nativescript-angular/node_modules/@angular/compiler/src/compile_metadata.d.ts(344,20): error TS23
04: Cannot find name 'Set'.
node_modules/nativescript-angular/node_modules/@angular/compiler/src/compile_metadata.d.ts(346,28): error TS23
04: Cannot find name 'Set'.
node_modules/nativescript-angular/node_modules/@angular/compiler/src/compile_metadata.d.ts(348,15): error TS23
04: Cannot find name 'Set'.
node_modules/nativescript-angular/node_modules/@angular/compiler/src/compile_metadata.d.ts(350,23): error TS23
04: Cannot find name 'Set'.
node_modules/nativescript-angular/node_modules/@angular/compiler/src/compile_metadata.d.ts(352,17): error TS23
04: Cannot find name 'Set'.
node_modules/nativescript-angular/node_modules/@angular/compiler/src/compile_metadata.d.ts(354,25): error TS23
04: Cannot find name 'Set'.
node_modules/nativescript-angular/node_modules/@angular/compiler/src/directive_normalizer.d.ts(38,72): error T
S2304: Cannot find name 'Promise'.
node_modules/nativescript-angular/node_modules/@angular/compiler/src/directive_normalizer.d.ts(40,74): error T
S2304: Cannot find name 'Promise'.
node_modules/nativescript-angular/node_modules/@angular/compiler/src/i18n/extractor.d.ts(17,33): error TS2304:
 Cannot find name 'Promise'.
node_modules/nativescript-angular/node_modules/@angular/compiler/src/i18n/extractor.d.ts(26,35): error TS2304:
 Cannot find name 'Promise'.
node_modules/nativescript-angular/node_modules/@angular/compiler/src/jit/compiler.d.ts(44,49): error TS2304: C
annot find name 'Promise'.
node_modules/nativescript-angular/node_modules/@angular/compiler/src/jit/compiler.d.ts(46,65): error TS2304: C
annot find name 'Promise'.
node_modules/nativescript-angular/node_modules/@angular/compiler/src/metadata_resolver.d.ts(58,104): error TS2
304: Cannot find name 'Promise'.
node_modules/nativescript-angular/node_modules/@angular/compiler/src/output/output_ast.d.ts(433,63): error TS2
304: Cannot find name 'Set'.
node_modules/nativescript-angular/node_modules/@angular/compiler/src/resource_loader.d.ts(13,23): error TS2304
: Cannot find name 'Promise'.
node_modules/nativescript-angular/node_modules/@angular/compiler/src/util.d.ts(25,18): error TS2304: Cannot fi
nd name 'Promise'.
node_modules/nativescript-angular/node_modules/@angular/compiler/src/util.d.ts(26,46): error TS2304: Cannot fi
nd name 'Promise'.

node_modules/nativescript-angular/node_modules/@angular/core/src/application_init.d.ts(16,18): error TS2304: C
annot find name 'Promise'.
node_modules/nativescript-angular/node_modules/@angular/core/src/application_ref.d.ts(116,67): error TS2304: C
annot find name 'Promise'.
node_modules/nativescript-angular/node_modules/@angular/core/src/application_ref.d.ts(132,101): error TS2304:
Cannot find name 'Promise'.
node_modules/nativescript-angular/node_modules/@angular/core/src/application_ref.d.ts(158,67): error TS2304: C
annot find name 'Promise'.
node_modules/nativescript-angular/node_modules/@angular/core/src/application_ref.d.ts(160,101): error TS2304:
Cannot find name 'Promise'.
node_modules/nativescript-angular/node_modules/@angular/core/src/change_detection/differs/default_keyvalue_dif
fer.d.ts(24,15): error TS2304: Cannot find name 'Map'.
node_modules/nativescript-angular/node_modules/@angular/core/src/change_detection/differs/default_keyvalue_dif
fer.d.ts(28,16): error TS2304: Cannot find name 'Map'.
node_modules/nativescript-angular/node_modules/@angular/core/src/di/reflective_provider.d.ts(88,123): error TS
2304: Cannot find name 'Map'.
node_modules/nativescript-angular/node_modules/@angular/core/src/di/reflective_provider.d.ts(88,165): error TS
2304: Cannot find name 'Map'.
node_modules/nativescript-angular/node_modules/@angular/core/src/facade/lang.d.ts(12,17): error TS2304: Cannot
 find name 'Map'.
node_modules/nativescript-angular/node_modules/@angular/core/src/facade/lang.d.ts(13,17): error TS2304: Cannot
 find name 'Set'.
node_modules/nativescript-angular/node_modules/@angular/core/src/linker/compiler.d.ts(53,49): error TS2304: Ca
nnot find name 'Promise'.
node_modules/nativescript-angular/node_modules/@angular/core/src/linker/compiler.d.ts(61,65): error TS2304: Ca
nnot find name 'Promise'.
node_modules/nativescript-angular/node_modules/@angular/core/src/linker/ng_module_factory_loader.d.ts(14,34):
error TS2304: Cannot find name 'Promise'.
node_modules/nativescript-angular/node_modules/@angular/core/src/linker/system_js_ng_module_factory_loader.d.t
s(28,25): error TS2304: Cannot find name 'Promise'.
node_modules/nativescript-angular/node_modules/@angular/core/src/util/lang.d.ts(8,53): error TS2304: Cannot fi
nd name 'Promise'.
node_modules/nativescript-angular/node_modules/@angular/platform-browser/src/browser/browser_adapter.d.ts(79,3
3): error TS2304: Cannot find name 'Map'.
node_modules/nativescript-angular/node_modules/@angular/platform-browser/src/dom/dom_adapter.d.ts(97,42): erro
r TS2304: Cannot find name 'Map'.
node_modules/nativescript-angular/node_modules/@angular/platform-browser/src/dom/dom_renderer.d.ts(22,37): err
or TS2304: Cannot find name 'Map'.
node_modules/nativescript-angular/node_modules/@angular/router/src/config.d.ts(307,62): error TS2304: Cannot f
ind name 'Promise'.
node_modules/nativescript-angular/node_modules/@angular/router/src/interfaces.d.ts(78,99): error TS2304: Canno
t find name 'Promise'.
node_modules/nativescript-angular/node_modules/@angular/router/src/interfaces.d.ts(157,109): error TS2304: Can
not find name 'Promise'.
node_modules/nativescript-angular/node_modules/@angular/router/src/interfaces.d.ts(227,115): error TS2304: Can
not find name 'Promise'.
node_modules/nativescript-angular/node_modules/@angular/router/src/interfaces.d.ts(297,89): error TS2304: Cann
ot find name 'Promise'.
node_modules/nativescript-angular/node_modules/@angular/router/src/interfaces.d.ts(367,50): error TS2304: Cann
ot find name 'Promise'.
node_modules/nativescript-angular/node_modules/@angular/router/src/router.d.ts(392,70): error TS2304: Cannot f
ind name 'Promise'.
node_modules/nativescript-angular/node_modules/@angular/router/src/router.d.ts(414,59): error TS2304: Cannot f
ind name 'Promise'.
node_modules/nativescript-angular/node_modules/@angular/router/src/utils/collection.d.ts(35,58): error TS2304:
 Cannot find name 'Promise'.
node_modules/nativescript-angular/node_modules/rxjs/Observable.d.ts(68,60): error TS2304: Cannot find name 'Pr
omise'.
node_modules/nativescript-angular/node_modules/rxjs/Observable.d.ts(68,70): error TS2304: Cannot find name 'Pr
omise'.
node_modules/nativescript-angular/parse5_adapter.d.ts(84,33): error TS2304: Cannot find name 'Map'.
node_modules/nativescript-angular/platform-common.d.ts(32,67): error TS2304: Cannot find name 'Promise'.
node_modules/nativescript-angular/platform-common.d.ts(33,101): error TS2304: Cannot find name 'Promise'.
node_modules/nativescript-angular/platform-providers.d.ts(1,23): error TS2307: Cannot find module 'ui/frame'.
node_modules/nativescript-angular/platform-providers.d.ts(2,22): error TS2307: Cannot find module 'ui/page'.
node_modules/nativescript-angular/platform-providers.d.ts(4,27): error TS2307: Cannot find module 'platform'.
node_modules/nativescript-angular/resource-loader.d.ts(4,23): error TS2304: Cannot find name 'Promise'.
node_modules/nativescript-angular/router/ns-location-strategy.d.ts(2,45): error TS2307: Cannot find module 'ui
/frame'.
node_modules/nativescript-angular/router/ns-module-factory-loader.d.ts(6,25): error TS2304: Cannot find name '
Promise'.
node_modules/nativescript-angular/router/page-router-outlet.d.ts(5,24): error TS2307: Cannot find module 'plat
form'.
node_modules/nativescript-angular/router/page-router-outlet.d.ts(6,23): error TS2307: Cannot find module 'ui/f
rame'.
node_modules/nativescript-angular/router/router-extensions.d.ts(3,23): error TS2307: Cannot find module 'ui/fr
ame'.
node_modules/nativescript-angular/router/router-extensions.d.ts(10,67): error TS2304: Cannot find name 'Promis
e'.
node_modules/nativescript-angular/router/router-extensions.d.ts(11,72): error TS2304: Cannot find name 'Promis
e'.
node_modules/nativescript-sms-inbox/index.d.ts(6,47): error TS2304: Cannot find name 'Promise'.
node_modules/nativescript-sms-inbox/index.d.ts(14,75): error TS2304: Cannot find name 'Promise'.
node_modules/nativescript-sms-inbox/index.d.ts(23,105): error TS2304: Cannot find name 'Promise'.
node_modules/nativescript-sms-inbox/index.d.ts(31,77): error TS2304: Cannot find name 'Promise'.
node_modules/nativescript-sms-inbox/index.d.ts(38,43): error TS2304: Cannot find name 'Promise'.
node_modules/nativescript-telerik-ui/sidedrawer/angular/side-drawer-directives.d.ts(6,20): error TS2307: Canno
t find module 'ui/core/view'.
node_modules/nativescript-telerik-ui/sidedrawer/index.d.ts(1,23): error TS2307: Cannot find module 'ui/core/vi
ew'.
node_modules/nativescript-telerik-ui/sidedrawer/index.d.ts(2,23): error TS2307: Cannot find module 'ui/page'.
node_modules/nativescript-telerik-ui/sidedrawer/index.d.ts(3,39): error TS2307: Cannot find module 'ui/core/de
pendency-observable'.
node_modules/nativescript-telerik-ui/sidedrawer/index.d.ts(4,27): error TS2307: Cannot find module 'ui/core/bi
ndable'.
node_modules/rxjs/Observable.d.ts(68,60): error TS2304: Cannot find name 'Promise'.
node_modules/rxjs/Observable.d.ts(68,70): error TS2304: Cannot find name 'Promise'.
node_modules/tns-core-modules/tns-core-modules.d.ts(14,18): error TS2304: Cannot find name 'Promise'.
node_modules/tns-core-modules/tns-core-modules.d.ts(17,27): error TS2304: Cannot find name 'Headers'.
node_modules/tns-core-modules/tns-core-modules.d.ts(19,44): error TS2304: Cannot find name 'RequestInit'.
node_modules/tns-core-modules/tns-core-modules.d.ts(19,58): error TS2304: Cannot find name 'Promise'.

TypeScript compiler failed with exit code 1

D:\Documents\Desenvolvimento\NativeScript\workspace\BudgetSMS>

#2

You need to use TypeScript 2.2 with 3.0 projects.

Also typescript imports of modules need to prepend tns-core-modules unless you make changes to the tsconfig (described in the article below), e.g.

import { Page } from 'ui/page';
import { isAndroid, isIOS } from 'platform';

becomes

import { Page } from 'tns-core-modules/ui/page';
import { isAndroid, isIOS } from 'tns-core-modules/platform';

You can find all breaking changes at


#3

Thanks, man! I was following the update instructions on the official docs site, and there’s a link to the breaking changes, but it is outdated:
http://docs.nativescript.org/angular/releases/breaking-changes

Had I seen how many those are, I wouldn’t have tried to update yet. I’m still beginning both mobile development and nativescript. Good thing I have the github repo to go back to.

Somebody should fix the official docs. Is there a way to contact them? (or maybe you are one of them)

Thanks for the reply, though!


#4

That article is long since outdated, yes. We are in the process of migrating the docs infrastructure to make it more robust and stable. Changes to some of the most outdated articles will soon appear live.

Sorry for the caused inconvenience.


#5

I would like to mention that my code, apparently, had nothing to be changed from version 2.5 to version 3.0 of NativeScript, because I recreated the project and basically copy-and-pasted the /app folder, and it worked.

However, when I tried to update the 2.5 project using the instructions on the link below, I got a lot of errors such as “cannot find name X”:
http://docs.nativescript.org/angular/releases/upgrade-instructions

I don’t know, but it seems to me that the update script is not perfect.

Thanks!


#6

@thiagoufg the update command only changes the versions of your tns-core-modules, widgets, and the runtimes. It will not adjust versions of any other dependencies, like typescript, for example. Read up on some of the latest blog posts where developers walk you through the 2.5 - 3.0 upgrade process.