Skip to content

Instantly share code, notes, and snippets.

@ndarwincorn
Last active November 19, 2020 19:10
Show Gist options
  • Save ndarwincorn/9dd82281a1893e71fb74a05975743c1c to your computer and use it in GitHub Desktop.
Save ndarwincorn/9dd82281a1893e71fb74a05975743c1c to your computer and use it in GitHub Desktop.
cdktf debug
{
"language": "typescript",
"app": "npm run --silent compile && node main.js",
"terraformProviders": ["gitlabhq/gitlab@~> 3.1.0"]
}

minimal reproducable example

from a directory with the included files, run the following:

$ npm install
$ npm run get
$ npm run synth

the last command will result in

.gen/providers/gitlab/user.ts:145:10 - error TS2300: Duplicate identifier 'resetPassword'.
145   public resetPassword() {
             ~~~~~~~~~~~~~
.gen/providers/gitlab/user.ts:171:14 - error TS2300: Duplicate identifier 'resetPassword'.
171   public get resetPassword() {
                 ~~~~~~~~~~~~~
.gen/providers/gitlab/user.ts:174:14 - error TS2300: Duplicate identifier 'resetPassword'.
174   public set resetPassword(value: boolean ) {

if you then change the required version of cdktf and cdktf-cli to 0.0.17 in the package.json, the above does not error

comparison of the broken lines in the generated resource

good generated provider by 0.0.17 (user.ts L112-119,131-137):

// password - computed: false, optional: true, required: false
  private _password?: string;
  public get password() {
    return this._password;
  }
  public set password(value: string | undefined) {
    this._password = value;
  }

...

  // reset_password - computed: false, optional: true, required: false
  private _resetPassword?: boolean;
  public get resetPassword() {
    return this._resetPassword;
  }
  public set resetPassword(value: boolean | undefined) {
    this._resetPassword = value;
  }

bad generated provider by 0.0.18 (user.ts L137-151,170-183):

// password - computed: false, optional: true, required: false
  private _password?: string;
  public get password() {
    return this.getStringAttribute('password');
  }
  public set password(value: string ) {
    this._password = value;
  }
  public resetPassword() {
    this._password = undefined;
  }
  // Temporarily expose input value. Use with caution.
  public get passwordInput() {
    return this._password
  }

...

  // reset_password - computed: false, optional: true, required: false
  private _resetPassword?: boolean;
  public get resetPassword() {
    return this.getBooleanAttribute('reset_password');
  }
  public set resetPassword(value: boolean ) {
    this._resetPassword = value;
  }
  public resetResetPassword() {
    this._resetPassword = undefined;
  }
  // Temporarily expose input value. Use with caution.
  public get resetPasswordInput() {
    return this._resetPassword
  }
import { Construct } from "constructs";
import { App, TerraformStack } from "cdktf";
import { GitlabProvider } from "./.gen/providers/gitlab";
class MyStack extends TerraformStack {
constructor(scope: Construct, name: string) {
super(scope, name);
new GitlabProvider(this, "provider", {
token: "DUMMYTOKEN",
}
}
}
const app = new App();
new MyStack(app, "cdk");
app.synth();
{
"name": "cdk",
"version": "1.0.0",
"main": "main.js",
"types": "main.ts",
"license": "MPL-2.0",
"private": true,
"scripts": {
"get": "cdktf get",
"synth": "cdktf synth",
"compile": "tsc --pretty"
},
"engines": {
"node": ">=10.12"
},
"dependencies": {
"cdktf": "0.0.18",
"constructs": "^3.2.36"
},
"devDependencies": {
"@types/node": "^14.14.8",
"cdktf-cli": "0.0.18",
"typescript": "^4.0.5"
}
}
{
"compilerOptions": {
"alwaysStrict": true,
"charset": "utf8",
"declaration": true,
"experimentalDecorators": true,
"inlineSourceMap": true,
"inlineSources": true,
"lib": [
"es2018"
],
"module": "CommonJS",
"noEmitOnError": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"resolveJsonModule": true,
"strict": true,
"strictNullChecks": true,
"strictPropertyInitialization": true,
"stripInternal": true,
"target": "ES2018"
},
"include": [
"**/*.ts"
],
"exclude": [
"node_modules"
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment