Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
"build": "babel --extensions .ts --ignore '**/*.test.ts' ./src -d dist --source-maps",
"test": "jest",
"typecheck": "tsc -p . --noEmit",
"prepack": "yarn build"
"prepack": "yarn build",
"typescript2python": "yarn --silent single src/index.ts"
},
"bin": {
"typescript2python": "./dist/index.js"
Expand Down
4 changes: 4 additions & 0 deletions src/parseInlineType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ export const tryToParseInlineType = (
// TODO: figure out why we reach this and replace with correct type definition
return `object`;
}
} else if (type.flags & TypeFlags.TemplateLiteral) {
// there is no way to represent template literals in Python,
// so we fallback to string
return "str";
} else {
// assume interface or object, we need to create a helper type
if (!globalScope) {
Expand Down
2 changes: 1 addition & 1 deletion src/parseTypeDefinition.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ts from "typescript";
import ts, { TypeFlags } from "typescript";
import { ParserState } from "./ParserState";
import { getDocumentationStringForDict, parseProperty, parsePropertyForDict } from "./parseProperty";
import { getDocumentationStringForType } from "./getDocumentationStringForType";
Expand Down
1 change: 1 addition & 0 deletions src/testing/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ describe("transpiling basic types", () => {
// without strict mode the `undefined` gets lost here
"T = float",
],
["export type T = `a.b.${string}`", "T = str"],
])("transpiles %p to %p", async (input, expected) => {
const result = await transpileString(input);
expect(result).toEqual(expected);
Expand Down