Skip to content

[typescript/angular2] compilation error in generated artifcats #4375

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

Closed
jeusdi opened this issue Dec 12, 2016 · 5 comments
Closed

[typescript/angular2] compilation error in generated artifcats #4375

jeusdi opened this issue Dec 12, 2016 · 5 comments

Comments

@jeusdi
Copy link

jeusdi commented Dec 12, 2016

Description

Code generated:

	/**
     * 
     * Extends object by coping non-existing properties.
     * @param objA object to be extended
     * @param objB source object
     */
    private extendObj<T1,T2>(objA: T1, objB: T2) {
        for(let key in objB){
            if(objB.hasOwnProperty(key)){
                objA[key] = objB[key];    <<<<<<<<<<<<<<<<<
            }
        }
        return <T1&T2>objA;
    }

Error message:

file: 'file:///d%3A/projects/living/user-platform/cest/ts/api/users.service.ts'
severity: 'Error'
message: 'Type 'keyof T2' cannot be used to index type 'T1'.'
at: '65,17'
source: 'ts'

My package.json is:

{
  "name": "cest",
  "version": "0.1.0-unstable0009",
  "description": "Living Community Endpoint REST Client",
  "main": "./js/index.js",
  "typings": "./js/index.d.ts",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "prepublish": "tsc"
  },
  "keywords": [
    "living",
    "cest",
    "commty"
  ],
  "author": "Living Digital Way",
  "license": "ISC",
  "devDependencies": {
    "@types/core-js": "^0.9.34",
    "typescript": "^2.1.4"
  },
  "publishConfig": {
    "registry": "http://nuget.living-digital-way.com:81/npm/npm_unstable"
  },
  "dependencies": {
    "@angular/common": "^2.2.4",
    "@angular/core": "^2.2.4",
    "@angular/http": "^2.2.4",
    "@angular/platform-browser": "^2.2.4",
    "rxjs": "^5.0.0-beta.12",
    "zone.js": "^0.6.21"
  }
}

And tsconfig.json:

{
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "moduleResolution": "node",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "declaration": true,
        "baseUrl": "./ts",
        "outDir": "js"
    },
    "exclude": [
        "node_modules",
        "js"
    ]
}
Swagger-codegen version

2.2.3-SNAPSHOT

@todrules
Copy link

I'm getting the exact same error.

Typescript: 2.1.4
Swagger CodeGen: 2.3.0 (built it a week ago)
@angular: 2.3.0

I'm also using awesome-typescrpit-loader 3.0.0-beta.13. I've had a few problems with that loader lately so thought I'd mention it.

@wing328 wing328 added this to the v2.2.2 milestone Dec 13, 2016
@wing328
Copy link
Contributor

wing328 commented Dec 13, 2016

@todrules is it correct to say that it was working fine before? or it never work for you?

@todrules
Copy link

It was working on another project I was working on. And while troubleshooting just now, I rolled back Typescript from 2.1.4 to 2.1.1, and it's working. So, something is getting introduced in the newest version of TS that is causing this issue, but at least there's a workaround for now.

@wing328
Copy link
Contributor

wing328 commented Dec 13, 2016

@todrules thanks for helping us to pinpoint the issue to Typescript version update. We'll need a fix to be compatible with the latest version as well as old version (e.g. 2.1.1) of TS.

cc @Vrolijkx

@wing328
Copy link
Contributor

wing328 commented Feb 15, 2017

@todrules #4562 has been merged into master. Please pull the latest to give it a try. I believe it should address the issue that you reported if I'm not mistaken.

@wing328 wing328 closed this as completed Feb 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants