Why error in Angular 5 as : has no exported member 'OpaqueToken'.?

Partha Sarathi Ghosh picture Partha Sarathi Ghosh · Jan 15, 2018 · Viewed 14.8k times · Source

I have an Angular 4 application, which I am upgrading to Angular 5.

I am getting the following error.

ERROR in src/app/application/services/generated/variables.ts(1,10): error TS2305: Module '"..../node_modules/@angular/core/core"' has no exported member 'OpaqueToken'.

Code snippet is :

import { OpaqueToken } from '@angular/core';

export const BASE_PATH = new OpaqueToken('basePath');
export const COLLECTION_FORMATS = {
    'csv': ',',
    'tsv': '   ',
    'ssv': ' ',
    'pipes': '|'
}

This code is been generated by swagger editor.

Answer

user9112752 picture user9112752 · Jan 16, 2018

The OpaqueToken got removed. You have to use the InjectionToken instead. I am facing the same problem. At the Moment the "best" solution is to replace the tokens after each code-gen build. But thats not a permanent solution.

Please contribute to this issue: https://github.com/swagger-api/swagger-codegen/issues/7324