diff --git a/.vscode/launch.json b/.vscode/launch.json index b3edf9050..c39a95ae0 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -11,7 +11,7 @@ "--config", "${workspaceFolder}/.config/mocha.fast.json", "-g", - "2135" + "2200" ], "internalConsoleOptions": "openOnSessionStart", "name": "Debug Tests", diff --git a/CHANGELOG.md b/CHANGELOG.md index b02f27f34..4e9c0045b 100644 --- a/CHANGELOG.md +++ b/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 diff --git a/src/lib/converter/symbols.ts b/src/lib/converter/symbols.ts index 62ef87349..df04f6d84 100644 --- a/src/lib/converter/symbols.ts +++ b/src/lib/converter/symbols.ts @@ -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); diff --git a/src/test/converter2/issues/gh2200.ts b/src/test/converter2/issues/gh2200.ts new file mode 100644 index 000000000..e22bd8ed8 --- /dev/null +++ b/src/test/converter2/issues/gh2200.ts @@ -0,0 +1,5 @@ +declare function buildObj(x: T): { + [K in keyof T]?: 1; +}; + +export const Test = buildObj({ x: 1 }); diff --git a/src/test/issueTests.ts b/src/test/issueTests.ts index d118c3136..f2b7c607c 100644 --- a/src/test/issueTests.ts +++ b/src/test/issueTests.ts @@ -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 + ); + }, };