Skip to content

Commit

Permalink
Fix #2200
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit0 committed Mar 16, 2023
1 parent 09aa616 commit d2057a1
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Expand Up @@ -11,7 +11,7 @@
"--config",
"${workspaceFolder}/.config/mocha.fast.json",
"-g",
"2135"
"2200"
],
"internalConsoleOptions": "openOnSessionStart",
"name": "Debug Tests",
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,14 @@
# Unreleased

### Bug Fixes

- Fixed a bug where optional properties were not appropriately marked as optional, #2200.
- Fixed shifted navigation pane on devices 1024px wide, #2191.

### Thanks!

- @futurGH

## v0.23.26 (2023-02-26)

### Features
Expand Down
8 changes: 6 additions & 2 deletions src/lib/converter/symbols.ts
Expand Up @@ -633,9 +633,13 @@ function convertProperty(
(ts.isPropertyDeclaration(declaration) ||
ts.isPropertySignature(declaration) ||
ts.isParameter(declaration) ||
ts.isPropertyAccessExpression(declaration))
ts.isPropertyAccessExpression(declaration) ||
ts.isPropertyAssignment(declaration))
) {
if (!ts.isPropertyAccessExpression(declaration)) {
if (
!ts.isPropertyAccessExpression(declaration) &&
!ts.isPropertyAssignment(declaration)
) {
parameterType = declaration.type;
}
setModifiers(symbol, declaration, reflection);
Expand Down
5 changes: 5 additions & 0 deletions src/test/converter2/issues/gh2200.ts
@@ -0,0 +1,5 @@
declare function buildObj<T>(x: T): {
[K in keyof T]?: 1;
};

export const Test = buildObj({ x: 1 });
9 changes: 9 additions & 0 deletions src/test/issueTests.ts
Expand Up @@ -854,4 +854,13 @@ export const issueTests: {
equal(def.type?.type, "intrinsic");
equal(def.type.toString(), "undefined");
},

gh2200(project) {
const Test = query(project, "Test");
equal(Test.type?.type, "reflection" as const);
equal(
Test.type.declaration.getChildByName("x")?.flags.isOptional,
true
);
},
};

0 comments on commit d2057a1

Please sign in to comment.