Skip to content

Commit d2057a1

Browse files
committed
Fix #2200
1 parent 09aa616 commit d2057a1

File tree

5 files changed

+30
-3
lines changed

5 files changed

+30
-3
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"--config",
1212
"${workspaceFolder}/.config/mocha.fast.json",
1313
"-g",
14-
"2135"
14+
"2200"
1515
],
1616
"internalConsoleOptions": "openOnSessionStart",
1717
"name": "Debug Tests",

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Unreleased
22

3+
### Bug Fixes
4+
5+
- Fixed a bug where optional properties were not appropriately marked as optional, #2200.
6+
- Fixed shifted navigation pane on devices 1024px wide, #2191.
7+
8+
### Thanks!
9+
10+
- @futurGH
11+
312
## v0.23.26 (2023-02-26)
413

514
### Features

src/lib/converter/symbols.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,9 +633,13 @@ function convertProperty(
633633
(ts.isPropertyDeclaration(declaration) ||
634634
ts.isPropertySignature(declaration) ||
635635
ts.isParameter(declaration) ||
636-
ts.isPropertyAccessExpression(declaration))
636+
ts.isPropertyAccessExpression(declaration) ||
637+
ts.isPropertyAssignment(declaration))
637638
) {
638-
if (!ts.isPropertyAccessExpression(declaration)) {
639+
if (
640+
!ts.isPropertyAccessExpression(declaration) &&
641+
!ts.isPropertyAssignment(declaration)
642+
) {
639643
parameterType = declaration.type;
640644
}
641645
setModifiers(symbol, declaration, reflection);

src/test/converter2/issues/gh2200.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
declare function buildObj<T>(x: T): {
2+
[K in keyof T]?: 1;
3+
};
4+
5+
export const Test = buildObj({ x: 1 });

src/test/issueTests.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,4 +854,13 @@ export const issueTests: {
854854
equal(def.type?.type, "intrinsic");
855855
equal(def.type.toString(), "undefined");
856856
},
857+
858+
gh2200(project) {
859+
const Test = query(project, "Test");
860+
equal(Test.type?.type, "reflection" as const);
861+
equal(
862+
Test.type.declaration.getChildByName("x")?.flags.isOptional,
863+
true
864+
);
865+
},
857866
};

0 commit comments

Comments
 (0)