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

TypeError: tsDiagnostic.file.getText is not a function #2889

Closed
staskuban opened this issue Nov 20, 2017 · 22 comments
Closed

TypeError: tsDiagnostic.file.getText is not a function #2889

staskuban opened this issue Nov 20, 2017 · 22 comments
Labels

Comments

@staskuban
Copy link

Hi there, im updatet my ionic env and now having theese errors when trying build ios --prod

TypeError: tsDiagnostic.file.getText is not a function
    at loadDiagnostic (/Users/user/WebstormProjects/MDMProfileMobile/node_modules/@ionic/app-scripts/dist/logger/logger-typescript.js:32:44)
    at /Users/user/WebstormProjects/MDMProfileMobile/node_modules/@ionic/app-scripts/dist/logger/logger-typescript.js:13:16
    at Array.map (<anonymous>)
    at Object.runTypeScriptDiagnostics (/Users/user/WebstormProjects/MDMProfileMobile/node_modules/@ionic/app-scripts/dist/logger/logger-typescript.js:12:26)
    at /Users/user/WebstormProjects/MDMProfileMobile/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:231:59
    at step (/Users/user/WebstormProjects/MDMProfileMobile/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:32:23)
    at Object.next (/Users/user/WebstormProjects/MDMProfileMobile/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:13:53)
    at fulfilled (/Users/user/WebstormProjects/MDMProfileMobile/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:4:58)
    at <anonymous>

ionic info

cli packages: (/Users/user/WebstormProjects/MDMProfileMobile/node_modules)

@ionic/cli-utils  : 1.18.0
ionic (Ionic CLI) : 3.18.0

global packages:

cordova (Cordova CLI) : 7.0.1 

local packages:

@ionic/app-scripts : 3.1.2
Cordova Platforms  : android 6.2.3 ios 4.4.0
Ionic Framework    : ionic-angular 3.9.2

System:

Android SDK Tools : 26.0.2
ios-deploy        : 1.9.2 
Node              : v8.9.1
npm               : 5.5.1 
OS                : macOS Sierra
Xcode             : Xcode 9.1 Build version 9B55 

Environment Variables:

ANDROID_HOME : /Users/user/Library/Android/sdk

Misc:

backend : pro
@imhoffd
Copy link
Contributor

imhoffd commented Nov 20, 2017

@staskuban May we have the full output of ionic build --prod? It's nice to know at which step these errors occur, just for sanity.

@staskuban
Copy link
Author

@dwieeb , sure

Mini-Polzovatel:MDMProfileMobile user$ ionic cordova build ios --prod
Running app-scripts build: --prod --platform ios --target cordova
[09:25:54]  build prod started ... 
[09:25:54]  clean started ... 
[09:25:54]  clean finished in 4 ms 
[09:25:54]  copy started ... 
[09:25:56]  deeplinks started ... 
[09:25:58]  deeplinks finished in 2.00 s 
[09:25:58]  ngc started ... 
TypeError: tsDiagnostic.file.getText is not a function
    at loadDiagnostic (/Users/user/WebstormProjects/MDMProfileMobile/node_modules/@ionic/app-scripts/dist/logger/logger-typescript.js:32:44)
    at /Users/user/WebstormProjects/MDMProfileMobile/node_modules/@ionic/app-scripts/dist/logger/logger-typescript.js:13:16
    at Array.map (<anonymous>)
    at Object.runTypeScriptDiagnostics (/Users/user/WebstormProjects/MDMProfileMobile/node_modules/@ionic/app-scripts/dist/logger/logger-typescript.js:12:26)
    at /Users/user/WebstormProjects/MDMProfileMobile/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:231:59
    at step (/Users/user/WebstormProjects/MDMProfileMobile/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:32:23)
    at Object.next (/Users/user/WebstormProjects/MDMProfileMobile/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:13:53)
    at fulfilled (/Users/user/WebstormProjects/MDMProfileMobile/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:4:58)
    at <anonymous>
[09:26:23]  copy finished in 29.45 s 

@staskuban
Copy link
Author

I reslove this issue. Problem with https://github.com/kadoshms/ionic2-autocomplete which crashes while compile with no errors. I updated check in logger-typescript fo
if (tsDiagnostic.file && tsDiagnostic.file.getText) ...

@soniyj
Copy link

soniyj commented Dec 21, 2017

Hi @staskuban can you tell me how to apply the change on an existing project? Because I didn't find that file into node_modules/@Ionic. Thanks

@RanmalN
Copy link

RanmalN commented Jan 9, 2018

This fix should be merged

@soniyj
Copy link

soniyj commented Jan 9, 2018

@RanmalN i am still getting the error and not sure that has been merged in the latest ionic cli i am using 3.19.x.

@lzkill
Copy link

lzkill commented Jan 9, 2018

I've been compiling with --prod with no issues for several weeks. Now it produces this error out of nothing! Why is the PR closed?

@5HARK
Copy link

5HARK commented Jan 9, 2018

@soniyj
in node_modules/@ionic/app-scripts/dist/logger/logger-typescript.js:29
change
if (tsDiagnostic.file) {
to
if (tsDiagnostic.file && tsDiagnostic.file.getText) {

@soniyj
Copy link

soniyj commented Jan 10, 2018

hi @5HARK cool thank you I will try 👍

@hervedevos
Copy link

Same issue here, why is the PR closed ?

Run into this issue with ionic-cli 3.19.1 and ionic 4.5.2 packages

ionic info

cli packages: (/usr/lib/node_modules)

    @ionic/cli-utils  : 1.19.1
    ionic (Ionic CLI) : 3.19.1

package.json

"dependencies": {
  "@angular/common": "5.2.0",
  "@angular/compiler": "5.2.0",
  "@angular/compiler-cli": "5.2.0",
  "@angular/core": "5.2.0",
  "@angular/forms": "5.2.0",
  "@angular/http": "5.2.0",
  "@angular/platform-browser": "5.2.0",
  "@angular/platform-browser-dynamic": "5.2.0",
  "@ionic-native/core": "4.5.2",
  "@ionic-native/splash-screen": "4.5.2",
  "@ionic-native/status-bar": "4.5.2",
  ...
},
"devDependencies": {
  @ionic/app-scripts: "3.1.8"
  ..
}

@andremorata
Copy link

andremorata commented Jan 30, 2018

Same problem here...

cli packages: (C:\Users\andre\AppData\Roaming\npm\node_modules) 
                                                                
    @ionic/cli-utils  : 1.19.1                                  
    ionic (Ionic CLI) : 3.19.1                                  
                                                                
local packages:                                                 
                                                                
    @ionic/app-scripts : 3.1.8                                  
    Ionic Framework    : ionic-angular 3.9.2                    
                                                                
System:                                                         
                                                                
    Node : v7.10.1                                              
    npm  : 4.2.0                                                
    OS   : Windows 10                                           

package.json

    "@angular/common": "5.2.2",
    "@angular/compiler": "5.2.2",
    "@angular/compiler-cli": "5.2.2",
    "@angular/core": "5.2.2",
    "@angular/forms": "5.2.2",
    "@angular/http": "5.2.2",
    "@angular/platform-browser": "5.2.2",
    "@angular/platform-browser-dynamic": "5.2.2",
    "@ionic-native/core": "4.4.0",
    "@ionic-native/splash-screen": "4.4.0",
    "@ionic-native/status-bar": "4.4.0",
    "@ionic/storage": "2.1.3",
    "ionic-angular": "3.9.2",
    "ionicons": "3.0.0",
    "rxjs": "5.5.2",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.18",
    "angular2-signaturepad": "^2.6.1",
    "animate.css": "^3.5.2",
    "font-awesome": "^4.7.0",
    "localforage": "^1.5.5",
    "moment": "^2.20.1",
    "ng2-ckeditor": "^1.1.9",
    "ngx-zxing": "^0.3.4",
    "text-encoding": "^0.6.4",
    "text-mask": "0.0.2",
    "text-mask-addons": "^3.7.1"
  },
  "devDependencies": {
    "@angular/cli": "1.6.6",
    "@ionic/app-scripts": "3.1.8",
    "typescript": "2.6.2"
  }

@carys-cc
Copy link

carys-cc commented Feb 1, 2018

Hi, also got this problem. Compiling without --prod works, with --prod get the following:

$ ionic cordova build ios --prod
Running app-scripts build: --prod --platform ios --target cordova
[15:56:01] build prod started ...
[15:56:01] clean started ...
[15:56:01] clean finished in 1 ms
[15:56:01] copy started ...
[15:56:01] ngc started ...
TypeError: this.compiler.compileAll is not a function
at CodeGenerator.codegen (/Users/patrickchoi/Dropbox/Ionic/carys_dev/node_modules/@angular/compiler-cli/src/codegen.js:30:14)
at Function.NgTools_InternalApi_NG_2.codeGen (/Users/patrickchoi/Dropbox/Ionic/carys_dev/node_modules/@angular/compiler-cli/src/ngtools_api.js:61:30)
at Object.doCodegen (/Users/patrickchoi/Dropbox/Ionic/carys_dev/node_modules/@ionic/app-scripts/dist/aot/codegen.js:6:51)
at /Users/patrickchoi/Dropbox/Ionic/carys_dev/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:42:30
at

@soniyj
Copy link

soniyj commented Feb 1, 2018

I got this problem long time ago and didn't find any solution about it

@gmarab
Copy link

gmarab commented Feb 22, 2018

@staskuban can you please reopen this PR?
Maybe so someone will take a look.
For my experience the problem occurs when you compile with --aot (therefore also with --prod) a project managed in lazy loading.
I made today a project in lazy loading and the problem, which until this morning was not there, suddenly appeared.

@huan
Copy link

huan commented Mar 28, 2018

So do I. +1

For my experience the problem occurs when you compile with --aot (therefore also with --prod) a project managed in lazy loading.
I made today a project in lazy loading and the problem, which until this morning was not there, suddenly appeared.

@romain10009
Copy link

+1 I have this error on a lazy loaded project!

@tolgaek
Copy link

tolgaek commented Apr 2, 2018

@zixia @romain10009 This turned out to be a mistake I made in an html file where I did *ngIf="phones & phones.length" (I forgot to put &&)

I'm not sure how this causes the issue but to debug your own issue, you can go to the
node_modules/@ionic/app-scripts/dist/logger/logger-typescript.js And add this following if condition and change the other if condition just above line 29

  if (tsDiagnostic && tsDiagnostic.file && !tsDiagnostic.file.getText) {
    console.log(tsDiagnostic.file.fileName);
  }

and change the if condition on line 29 to include the getText check

if (tsDiagnostic.file && tsDiagnostic.file.getText) {

Then run the build, and see which file has the typescript error

@imhoffd imhoffd changed the title Failing when build ios --prod TypeError: tsDiagnostic.file.getText is not a function Apr 2, 2018
@imhoffd imhoffd reopened this Apr 2, 2018
@imhoffd
Copy link
Contributor

imhoffd commented Apr 2, 2018

See this PR: ionic-team/ionic-app-scripts#1365

This will be fixed in app-scripts 3.1.9

@coolara
Copy link

coolara commented Apr 14, 2018

if found which cause the error tsDiagnostic.file.getText is not a function
i create a custom component in my project in my component html
when i use ngIf or ngFor like this
example.html

<div *ngIf="text">
  {{text}}
</div>

it works ok like this

<div>
  {{text}}
</div>

why

@coolara
Copy link

coolara commented Apr 17, 2018

烦躁,没人关注这个问题啊,难道我还得把angular的版本降到4.1.3 ionic 版本降到2.1.4才能解决问题吗

@imhoffd
Copy link
Contributor

imhoffd commented Apr 18, 2018

@ionic/app-scripts 3.1.9 is out with this a fix for this! Sorry for the delay!

@imhoffd imhoffd closed this as completed Apr 18, 2018
@imhoffd imhoffd added the bug label Apr 18, 2018
@coolara
Copy link

coolara commented Apr 20, 2018

u can run ./node_modules/.bin/ngc check what cause the error

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

No branches or pull requests