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

5

6

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.

Chrotoem answered 15/1, 2018 at 9:35 Comment(4)
It was removed. : core: OpaqueToken has been removed as it was deprecated since v4. Use InjectionToken instead. (#18971) (3c4eef8)Figurant
Some details on it's use here: #43419550Casease
If you are updating from 4.x.x to 5.x.x, you should at least read the list of breaking changes in the changelog github.com/angular/angular/blob/master/…Curd
Please see my answer. Note: I'm a technical reviewer of the typescript language families of the codegenMerilyn
C
3

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

Clipfed answered 16/1, 2018 at 9:16 Comment(0)
D
3

includes folling in the package.json file

"@angular/flex-layout": "^2.0.0-beta.12"

Try deleting the node_modules folder, delete the package.json file then running the following command i hope this problem was resolved

npm install

please refer following link for this issue https://github.com/angular/flex-layout/issues/494#issuecomment-343355178

Dentifrice answered 28/3, 2018 at 13:22 Comment(1)
Please use formatting tools to properly edit and format your answer. Also check How to write an answer.Touchmenot
M
1

Please see https://github.com/swagger-api/swagger-codegen/issues/7324#issuecomment-368548716

If you are wanting to use Angular 5, you need to use the version of swagger-codegen that supports version switching.

That this time the lowest stable version of that is 2.3.0

In that you can define (for custom config) ngVersion to whatever version you want. As long as that semVer is above 4.0 it will generate injection token instead of OpaqueToken.

Merilyn answered 26/2, 2018 at 15:56 Comment(0)
T
1

I had this error when I updating angular 4 to 5

I fixed this issue by change package.json file

"@agm/core": "1.0.0-beta.1" to "@agm/core": "1.0.0-beta.5"

after run npm update

Teaspoon answered 25/3, 2019 at 8:0 Comment(0)
A
0

This happened when I upgraded to angular 5.2.0. I ended up having to do the following:

Edited package.json: Had to change my version for @angular/compiler-cli. In my case I had to bring it back to 5.2.0, as it somehow got to 5.2.10.

Deleted the node_modules directory.

Ran: npm install

Installed: npm install @angular/flex-layout.

Aborning answered 10/5, 2018 at 11:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.