Skip to content

Commit

Permalink
Computed Indexed Access Types | TypeBox 0.28.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sinclairzx81 committed Apr 20, 2023
1 parent b717629 commit ecefc7c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@types/prettier": "^2.7.2"
},
"dependencies": {
"@sinclair/typebox": "^0.27.8",
"@sinclair/typebox": "^0.28.1",
"prettier": "^2.8.7",
"typescript": "^5.0.4"
},
Expand Down
5 changes: 3 additions & 2 deletions src/typescript/typescript-to-typebox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ export namespace TypeScriptToTypeBox {
}
function* IndexedAccessType(node: ts.IndexedAccessTypeNode): IterableIterator<string> {
const obj = node.objectType.getText()
const key = node.indexType.getText()
yield `${obj}.properties[${key}]`
const key = Collect(node.indexType)
yield `Type.Index(${obj}, ${key})`
}
function* ExpressionWithTypeArguments(node: ts.ExpressionWithTypeArguments): IterableIterator<string> {
const name = Collect(node.expression)
Expand Down Expand Up @@ -465,6 +465,7 @@ export namespace TypeScriptToTypeBox {
typeNames.clear()
useImports = false
useGenerics = false
useTypeClone = false
const source = ts.createSourceFile('types.ts', typescriptCode, ts.ScriptTarget.ESNext, true)
const declarations = Formatter.Format([...Visit(source)].join('\n\n'))
const imports = ImportStatement(options)
Expand Down

0 comments on commit ecefc7c

Please sign in to comment.