Skip to content
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

fix(go): nested types are not namespaced #2650

Merged
merged 7 commits into from
Mar 12, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/jsii-pacmak/.eslintrc.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
---
extends: ../../eslint-config.yaml

ignorePatterns:
- test/generated-code/examples/**
19 changes: 15 additions & 4 deletions packages/jsii-pacmak/lib/targets/go/types/go-type.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CodeMaker, toCamelCase, toPascalCase } from 'codemaker';
import { CodeMaker, toPascalCase } from 'codemaker';
import { Type } from 'jsii-reflect';

import { EmitContext } from '../emit-context';
Expand All @@ -14,9 +14,20 @@ export abstract class GoType {

public constructor(public pkg: Package, public type: Type) {
this.name = toPascalCase(type.name);
// add "_jsiiProxy" postfix to private struct name to avoid keyword
// conflicts such as "default". see https://github.com/aws/jsii/issues/2637
this.proxyName = `${toCamelCase(type.name)}_jsiiProxy`;

// Prefix witht he nesting parent name(s), using an _ delimiter.
RomainMuller marked this conversation as resolved.
Show resolved Hide resolved
for (
let parent = type.nestingParent;
parent != null;
parent = parent.nestingParent
) {
this.name = `${toPascalCase(parent.name)}_${this.name}`;
}

// Add "jsiiProxy_" prefix to private struct name to avoid keyword conflicts
// such as "default". See https://github.com/aws/jsii/issues/2637
this.proxyName = `jsiiProxy_${this.name}`;

this.fqn = type.fqn;
}

Expand Down
1 change: 1 addition & 0 deletions packages/jsii-pacmak/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"@types/yargs": "^16.0.0",
"eslint": "^7.20.0",
"jest": "^26.6.3",
"jsii": "^0.0.0",
"jsii-build-tools": "^0.0.0",
"jsii-calc": "^3.20.120",
"prettier": "^2.2.1",
Expand Down
Loading