Skip to content

Commit cee0d74

Browse files
committed
Update to typescript 5.1
1 parent e9ef7a5 commit cee0d74

File tree

7 files changed

+31
-11
lines changed

7 files changed

+31
-11
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"path-equal": "^1.2.5",
4848
"safe-stable-stringify": "^2.2.0",
4949
"ts-node": "^10.9.1",
50-
"typescript": "~4.9.5",
50+
"typescript": "~5.1.0",
5151
"yargs": "^17.1.1"
5252
},
5353
"devDependencies": {

test/programs/const-keyword/main.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
const fn = <const T>(value: T) =>
2+
({ value });
3+
4+
export type Object = ReturnType<typeof fn<"value">>;
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"properties": {
4+
"value": {
5+
"const": "value",
6+
"type": "string"
7+
}
8+
},
9+
"required": ["value"],
10+
"type": "object"
11+
}
12+

test/schema.test.ts

+4
Original file line numberDiff line numberDiff line change
@@ -523,3 +523,7 @@ describe("when reusing a generator", () => {
523523
describe("satisfies keyword - ignore from a \"satisfies\" and build by rally type", () => {
524524
assertSchema("satisfies-keyword", "Specific");
525525
});
526+
527+
describe("const keyword", () => {
528+
assertSchema("const-keyword", "Object");
529+
});

tsconfig.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
"noLib": false,
2020
"preserveConstEnums": true,
2121
"sourceMap": true,
22-
"watch": false,
23-
"typeRoots" : ["node_modules/@types"]
22+
"typeRoots" : ["node_modules/@types"],
23+
"ignoreDeprecations": "5.0"
2424
},
2525
"include": [
2626
"**/*.ts",

typescript-json-schema.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1052,8 +1052,8 @@ export class JsonSchemaGenerator {
10521052
return !(
10531053
decls &&
10541054
decls.filter((decl) => {
1055-
const mods = decl.modifiers;
1056-
return mods && mods.filter((mod) => mod.kind === ts.SyntaxKind.PrivateKeyword).length > 0;
1055+
const mods = (decl as any).modifiers;
1056+
return mods && mods.filter((mod: any) => mod.kind === ts.SyntaxKind.PrivateKeyword).length > 0;
10571057
}).length > 0
10581058
);
10591059
});
@@ -1154,7 +1154,7 @@ export class JsonSchemaGenerator {
11541154
const requiredProps = props.reduce((required: string[], prop: ts.Symbol) => {
11551155
const def = {};
11561156
this.parseCommentsIntoDefinition(prop, def, {});
1157-
const allUnionTypesFlags: number[] = (<any>prop).type?.types?.map?.((t: any) => t.flags) || [];
1157+
const allUnionTypesFlags: number[] = (<any>prop).links?.type?.types?.map?.((t: any) => t.flags) || [];
11581158
if (
11591159
!(prop.flags & ts.SymbolFlags.Optional) &&
11601160
!(prop.flags & ts.SymbolFlags.Method) &&
@@ -1373,7 +1373,7 @@ export class JsonSchemaGenerator {
13731373

13741374
if (definition.type === undefined) {
13751375
// if users override the type, do not try to infer it
1376-
if (typ.flags & ts.TypeFlags.Union) {
1376+
if (typ.flags & ts.TypeFlags.Union && (node === null || node.kind !== ts.SyntaxKind.EnumDeclaration)) {
13771377
this.getUnionDefinition(typ as ts.UnionType, unionModifier, definition);
13781378
} else if (typ.flags & ts.TypeFlags.Intersection) {
13791379
if (this.args.noExtraProps) {

yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -894,10 +894,10 @@ type-detect@^4.0.0, type-detect@^4.0.5:
894894
resolved "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz"
895895
integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==
896896

897-
typescript@~4.9.5:
898-
version "4.9.5"
899-
resolved "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz"
900-
integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==
897+
typescript@~5.1.0:
898+
version "5.1.6"
899+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.1.6.tgz#02f8ac202b6dad2c0dd5e0913745b47a37998274"
900+
integrity sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==
901901

902902
uri-js@^4.2.2:
903903
version "4.4.1"

0 commit comments

Comments
 (0)