3
votes
import { environment } from '../../environments/environment';
import { Headers } from '@angular/http';

@Injectable()
export class ProjectsService {

  private _wpBase = environment.wpBase;

ng build --prod gives me an error :

ERROR in src/app/projects/projects.service.ts(11,33): error TS2339: Property 'wpBase' does not exist on type '{ production: boolean; }'.

How can I fix this? The app works fine, I'm trying to implement Angular Universal using this guide: https://github.com/angular/angular-cli/wiki/stories-universal-rendering

2

2 Answers

2
votes

You probably forgot to set the wpBase property in environment.prod.ts...

Check both your environment.ts and environment.prod.ts and see if you have set the wpBase correctly.

1
votes

Quick fix is to type the environment as any:

@Injectable()
export class ProjectsService {
  private _wpBase = (environment as any).wpBase;
}

Proper fix would be to add type definition for your environment object.

interface AppEnv {
   production: boolean;
   wpBase: // whatever is the correct type
}
export const environment: AppEnv = {
  production: false,
  wpBase: // whatever is the value
};