Skip to content

Commit

Permalink
Restore support for TS 4.0 through 4.5
Browse files Browse the repository at this point in the history
Resolves #1945
  • Loading branch information
Gerrit0 committed Jun 1, 2022
1 parent a4945d3 commit 690543b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .gitignore
@@ -1,5 +1,6 @@
.DS_Store
.idea
.vs
.tscache
.baseDir.js
.baseDir.ts
Expand All @@ -22,4 +23,4 @@ src/test/renderer/specs/specs.json
# Built theme JS
static/main.js

/example/docs/
/example/docs/
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,9 @@
# Unreleased

### Bug Fixes

- Restore support for TS 4.0 through 4.5, #1945.

## v0.22.16 (2022-05-30)

### Features
Expand Down
5 changes: 4 additions & 1 deletion src/lib/converter/symbols.ts
Expand Up @@ -666,10 +666,13 @@ function convertProperty(
}
reflection.defaultValue = declaration && convertDefaultValue(declaration);

// FIXME: Once we drop support for TS 4.5, we can use context.checker.getTypeOfSymbol(symbol) here.
reflection.type = context.converter.convertType(
context,
(context.isConvertingTypeNode() ? parameterType : void 0) ??
context.checker.getTypeOfSymbol(symbol)
context.checker.getTypeOfSymbolAtLocation(symbol, {
kind: ts.SyntaxKind.SourceFile,
} as any)
);

if (reflection.flags.isOptional) {
Expand Down
5 changes: 3 additions & 2 deletions src/lib/types/ts-internal/index.d.ts
Expand Up @@ -21,8 +21,9 @@ declare module "typescript" {
signature: ts.Signature
): ts.TypePredicate | undefined;

//https://github.com/microsoft/TypeScript/blob/v4.7.2/src/compiler/types.ts#L4188
getTypeOfSymbol(symbol: Symbol): Type;
// Since TS 4.6, not available earlier.
// https://github.com/microsoft/TypeScript/blob/v4.7.2/src/compiler/types.ts#L4188
// getTypeOfSymbol(symbol: Symbol): Type;
}

export interface Signature {
Expand Down

0 comments on commit 690543b

Please sign in to comment.