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

Cannot compile when Typescript namespaces contain keywords #135

Closed
haynesgt opened this issue Apr 21, 2017 · 7 comments
Closed

Cannot compile when Typescript namespaces contain keywords #135

haynesgt opened this issue Apr 21, 2017 · 7 comments

Comments

@haynesgt
Copy link

Typescript keywords in Java packages create errors (error TS1003: Identifier expected.)

The following are invalid in Typescript namespaces but can appear in java package names:

[ 'debugger',
'delete',
'export',
'function',
'in',
'typeof',
'var',
'with' ]

E.g. here is a valid java package.

package debugger.delete.export.function.in.typeof.var.with;

Here are some invalid namespaces:

namespace a.debugger.c { }
namespace a.delete.c { }
namespace a.export.c { }
namespace a.function.c { }
namespace a.import.c { }
namespace a.in.c { }
namespace a.instanceof.c { }
namespace a.typeof.c { }
namespace a.var.c { }
namespace a.with.c { }

@vojtechhabarta
Copy link
Owner

Thanks for reporting this.

I think invalid namespace identifiers are first two groups from Reserved Words (break ..., implements ...).

What do you think we should do about this? Prefix these keywords with underscore (_break) or make first letter uppercase (Break)?

@vojtechhabarta
Copy link
Owner

Aha, your list of invalid namespace identifiers is not just example but it is the first group of reserved words minus Java reserved words.

@haynesgt
Copy link
Author

Regarding solutions, both prefixes and case changes could conflict with other packages. I feel like the best option would be to add a prefix that is underscore by default (_export), but with an option (<reservedWordPrefix>) to let a user change it. I don't like uppercase namespaces because they look like classes.

@vojtechhabarta
Copy link
Owner

Yes they can conflict but it is not much probable that single project contains two packages that differ only in one _ character and both having class with the same simple name. So I don't want to add new configuration setting for this prefix (at least for now). There are possibilities how to resolve these conflicts (for example using customTypeNaming parameter).

I preferred uppercase namespace (it is common in TypeScript and C#) but since you prefer underscore prefix I used this prefix 😄

@vojtechhabarta
Copy link
Owner

Fix released: v1.24.317.
Could you please try it?

@haynesgt
Copy link
Author

It works. I can compile without errors.

Thanks!

@vojtechhabarta
Copy link
Owner

Closing old issues after release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants