Skip to content

Commit

Permalink
build: update typescript to 5.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
hbofolts1 committed Aug 29, 2023
1 parent d2b147f commit 6a0b8c5
Show file tree
Hide file tree
Showing 7 changed files with 2,504 additions and 3,247 deletions.
5,713 changes: 2,475 additions & 3,238 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"glob": "^7.1.6",
"node-plantuml": "0.9.0",
"plantuml-encoder": "^1.4.0",
"typescript": "4.0.3"
"typescript": "5.2.2"
},
"devDependencies": {
"@types/glob": "^7.1.1",
Expand All @@ -53,8 +53,8 @@
"@typescript-eslint/eslint-plugin": "^6.5.0",
"@typescript-eslint/parser": "^6.5.0",
"eslint": "^8.48.0",
"jest": "^27.0.6",
"ts-jest": "^27.0.3"
"jest": "^29.1.1",
"ts-jest": "^29.1.1"
},
"jest": {
"preset": "ts-jest",
Expand Down
15 changes: 11 additions & 4 deletions src/Factories/ComponentFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export function create(fileName: string, node: ts.Node, checker: ts.TypeChecker)
return componentComposites;
}

function getModifier(modifiers: ts.NodeArray<ts.Modifier>): Modifier {
function getModifier(modifiers: readonly ts.Modifier[]): Modifier {
for (const modifier of modifiers) {
if (modifier.kind === ts.SyntaxKind.PrivateKeyword) {
return 'private';
Expand Down Expand Up @@ -119,7 +119,7 @@ function getOriginalFile(typeSymbol: ts.Symbol, checker: ts.TypeChecker): string
deAliasSymbol = typeSymbol;
}

return deAliasSymbol.declarations?.[0].getSourceFile().fileName;
return deAliasSymbol.declarations?.[0].getSourceFile().fileName ?? '';
}

export function getOriginalFileOriginalType(tsType: ts.Type, checker: ts.TypeChecker): string {
Expand Down Expand Up @@ -160,7 +160,10 @@ function isTypeParameter(declaration: ts.NamedDeclaration): boolean {
}

export function getMemberModifier(memberDeclaration: ts.Declaration): Modifier {
const memberModifiers: ts.NodeArray<ts.Modifier> | undefined = memberDeclaration.modifiers;
if (!ts.canHaveModifiers(memberDeclaration)) {
return 'public';
}
const memberModifiers: readonly ts.Modifier[] | undefined = ts.getModifiers(memberDeclaration);

if (memberModifiers === undefined) {
return 'public';
Expand All @@ -171,7 +174,11 @@ export function getMemberModifier(memberDeclaration: ts.Declaration): Modifier {

export function isModifier(memberDeclaration: ts.Declaration, modifierKind: ts.SyntaxKind): boolean {

const memberModifiers: ts.NodeArray<ts.Modifier> | undefined = memberDeclaration.modifiers;
if (!ts.canHaveModifiers(memberDeclaration)) {
return false;
}

const memberModifiers: readonly ts.Modifier[] | undefined = ts.getModifiers(memberDeclaration);

if (memberModifiers !== undefined) {
for (const memberModifier of memberModifiers) {
Expand Down
2 changes: 1 addition & 1 deletion src/Factories/MethodFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function create(signature: ts.Symbol, namedDeclaration: ts.NamedDeclarati
result.typeParameters = methodSignature.typeParameters
.map(
(typeParameter: ts.TypeParameter) =>
TypeParameterFactory.create(typeParameter.symbol, typeParameter.symbol.declarations[0], checker)
TypeParameterFactory.create(typeParameter.symbol, typeParameter.symbol.declarations?.[0], checker)
);
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/Factories/ParameterFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ export function create(parameterSymbol: ts.Symbol, checker: ts.TypeChecker): Par
declaration = declarations[0];
}

if (parameterSymbol.valueDeclaration === undefined) {
throw new Error("unable to determine parameterType");
}

const typeOfSymbol: ts.Type = checker.getTypeOfSymbolAtLocation(
parameterSymbol,
parameterSymbol.valueDeclaration
Expand Down
5 changes: 5 additions & 0 deletions src/Factories/PropertyFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ export function create(signature: ts.Symbol, namedDeclaration: ts.NamedDeclarati
result.isOptional = ComponentFactory.isOptional(<ts.PropertyDeclaration>namedDeclaration);
result.isStatic = ComponentFactory.isModifier(namedDeclaration, ts.SyntaxKind.StaticKeyword);
result.isReadonly = ComponentFactory.isModifier(namedDeclaration, ts.SyntaxKind.ReadonlyKeyword);

if (signature.valueDeclaration === undefined) {
throw new Error("unable to determing returnType");
}

result.returnType = checker.typeToString(
checker.getTypeOfSymbolAtLocation(
signature,
Expand Down
6 changes: 5 additions & 1 deletion src/Factories/TypeParameterFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ export function getConstraint(memberDeclaration: ts.Declaration, checker: ts.Typ
return checker.getTypeFromTypeNode(effectiveConstraint);
}

export function create(signature: ts.Symbol, namedDeclaration: ts.NamedDeclaration, checker: ts.TypeChecker): TypeParameter {
export function create(signature: ts.Symbol, namedDeclaration: ts.NamedDeclaration | undefined, checker: ts.TypeChecker): TypeParameter {
const result: TypeParameter = new TypeParameter(signature.getName());

if (namedDeclaration === undefined) {
return result;
}

const constraintType: ts.Type | undefined = getConstraint(namedDeclaration, checker);

if (constraintType !== undefined) {
Expand Down

0 comments on commit 6a0b8c5

Please sign in to comment.