Skip to content

Commit

Permalink
Treat names starting with dot as non-supportable
Browse files Browse the repository at this point in the history
  • Loading branch information
Schahen committed Dec 1, 2019
1 parent 9a880f3 commit 7457cd6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions compiler/test/data/typescript/escaping/escaping.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ interface This {
'another-string-literal': string;
"this_one_shouldnt_be_escaped": boolean;
":authority"?: string;
".xxx": any;
'3х': string;
200: string;
300?: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,10 @@ private fun String.shouldEscape(): Boolean {
val startsWithNumber = this.contains(STARTS_WITH_NUMBER)
val isEscapedAlready = this.startsWith("`")
val isStartingWithColon = this.startsWith(":")
val isStartingWithDot = this.startsWith(".")

return !isEscapedAlready && (isReservedWord || containsDollarSign || containsOnlyUnderscores || containsMinusSign || startsWithNumber || isStartingWithColon)
return !isEscapedAlready &&
(isReservedWord || containsDollarSign || containsOnlyUnderscores || containsMinusSign || startsWithNumber || isStartingWithColon || isStartingWithDot)
}

private fun String.escape(): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private fun NameEntity.contains(str: String): Boolean {
private val STARTS_WITH_NUMBER = "^`\\d+".toRegex()

private fun NameEntity.isInvalidJsName(): Boolean {
return contains(STARTS_WITH_NUMBER) || contains("-") || startsWith("`:")
return contains(STARTS_WITH_NUMBER) || contains("-") || startsWith("`:") || startsWith("`.")
}

private fun MemberModel.getType(): TypeModel? {
Expand Down

0 comments on commit 7457cd6

Please sign in to comment.