Skip to content

Commit

Permalink
Update to typescript 5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sukovanej committed Aug 13, 2023
1 parent e9ef7a5 commit 094964f
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 11 deletions.
10 changes: 10 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,16 @@ export interface MyObject {
```


## [const-keyword](./test/programs/const-keyword)

```ts
const fn = <const T>(value: T) =>
({ value });

export type Object = ReturnType<typeof fn<"value">>;
```


## [custom-dates](./test/programs/custom-dates)

```ts
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"path-equal": "^1.2.5",
"safe-stable-stringify": "^2.2.0",
"ts-node": "^10.9.1",
"typescript": "~4.9.5",
"typescript": "~5.1.0",
"yargs": "^17.1.1"
},
"devDependencies": {
Expand Down
4 changes: 4 additions & 0 deletions test/programs/const-keyword/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const fn = <const T>(value: T) =>
({ value });

export type Object = ReturnType<typeof fn<"value">>;
12 changes: 12 additions & 0 deletions test/programs/const-keyword/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"value": {
"const": "value",
"type": "string"
}
},
"required": ["value"],
"type": "object"
}

4 changes: 4 additions & 0 deletions test/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -523,3 +523,7 @@ describe("when reusing a generator", () => {
describe("satisfies keyword - ignore from a \"satisfies\" and build by rally type", () => {
assertSchema("satisfies-keyword", "Specific");
});

describe("const keyword", () => {
assertSchema("const-keyword", "Object");
});
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"noLib": false,
"preserveConstEnums": true,
"sourceMap": true,
"watch": false,
"typeRoots" : ["node_modules/@types"]
"typeRoots" : ["node_modules/@types"],
"ignoreDeprecations": "5.0"
},
"include": [
"**/*.ts",
Expand Down
8 changes: 4 additions & 4 deletions typescript-json-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1052,8 +1052,8 @@ export class JsonSchemaGenerator {
return !(
decls &&
decls.filter((decl) => {
const mods = decl.modifiers;
return mods && mods.filter((mod) => mod.kind === ts.SyntaxKind.PrivateKeyword).length > 0;
const mods = (decl as any).modifiers;
return mods && mods.filter((mod: any) => mod.kind === ts.SyntaxKind.PrivateKeyword).length > 0;
}).length > 0
);
});
Expand Down Expand Up @@ -1154,7 +1154,7 @@ export class JsonSchemaGenerator {
const requiredProps = props.reduce((required: string[], prop: ts.Symbol) => {
const def = {};
this.parseCommentsIntoDefinition(prop, def, {});
const allUnionTypesFlags: number[] = (<any>prop).type?.types?.map?.((t: any) => t.flags) || [];
const allUnionTypesFlags: number[] = (<any>prop).links?.type?.types?.map?.((t: any) => t.flags) || [];
if (
!(prop.flags & ts.SymbolFlags.Optional) &&
!(prop.flags & ts.SymbolFlags.Method) &&
Expand Down Expand Up @@ -1373,7 +1373,7 @@ export class JsonSchemaGenerator {

if (definition.type === undefined) {
// if users override the type, do not try to infer it
if (typ.flags & ts.TypeFlags.Union) {
if (typ.flags & ts.TypeFlags.Union && (node === null || node.kind !== ts.SyntaxKind.EnumDeclaration)) {
this.getUnionDefinition(typ as ts.UnionType, unionModifier, definition);
} else if (typ.flags & ts.TypeFlags.Intersection) {
if (this.args.noExtraProps) {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -894,10 +894,10 @@ type-detect@^4.0.0, type-detect@^4.0.5:
resolved "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz"
integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==

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

uri-js@^4.2.2:
version "4.4.1"
Expand Down

0 comments on commit 094964f

Please sign in to comment.