Skip to content

Commit

Permalink
Fix TS4.8 compilation issue (#438)
Browse files Browse the repository at this point in the history
* Support ts 4.8

* Fix ts4.8 issue
  • Loading branch information
colinhacks authored Sep 4, 2022
1 parent 68299c8 commit dd25635
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 30 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "edgedb",
"version": "0.22.1",
"version": "0.22.2",
"description": "The official Node.js client library for EdgeDB",
"homepage": "https://edgedb.com/docs",
"author": "EdgeDB <[email protected]>",
Expand Down Expand Up @@ -42,7 +42,7 @@
"typescript": "^4.4"
},
"scripts": {
"build": "yarn build:cjs && yarn build:esm && yarn build:deno && yarn syntax:make && yarn syntax:clean && yarn set-version",
"build": "echo 'Building edgedb-js...' && yarn build:cjs && yarn build:esm && yarn build:deno && yarn syntax:make && yarn syntax:clean && yarn set-version",
"build:esm": "tsc --project tsconfig.build-esm.json",
"build:cjs": "tsc --project tsconfig.build.json",
"build:deno": "deno run --unstable --allow-env --allow-read --allow-write tools/compileForDeno.ts && yarn syntax:make --deno",
Expand Down
2 changes: 1 addition & 1 deletion qb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"superjson": "^1.7.5",
"ts-jest": "^27.0.3",
"tsx": "^3.8.0",
"typescript": "^4.4"
"typescript": "4.8"
},
"resolutions": {
"edgedb": "portal:.."
Expand Down
11 changes: 3 additions & 8 deletions qb/playground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,12 @@ import e from "./dbschema/edgeql-js";
async function run() {
const {client} = await setupTests();
console.log(`~~~~~~~~~~~~~~~~~~~~~~~~~~~`);
await client.query(
`
with languages := <json>$languages
select json_array_unpack(languages)
`,
{languages: [{title: "test"}]}
);

// const query = e.for(e.Bag, bag => {});
const query = e.select(e.Movie, () => ({
const query = e.select(e.Movie, movie => ({
id: true,
title: true,
filter: e.op(movie.genre, "=", e.Genre.Action),
}));
console.log(query.toEdgeQL());
const result = await query.run(client);
Expand Down
18 changes: 9 additions & 9 deletions qb/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3966,7 +3966,7 @@ resolve@^1.20.0:
superjson: ^1.7.5
ts-jest: ^27.0.3
tsx: ^3.8.0
typescript: ^4.4
typescript: 4.8
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -4471,23 +4471,23 @@ resolve@^1.20.0:
languageName: node
linkType: hard

typescript@^4.4:
version: 4.7.4
resolution: "typescript@npm:4.7.4"
"typescript@npm:4.8":
version: 4.8.2
resolution: "typescript@npm:4.8.2"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 5750181b1cd7e6482c4195825547e70f944114fb47e58e4aa7553e62f11b3f3173766aef9c281783edfd881f7b8299cf35e3ca8caebe73d8464528c907a164df
checksum: 7f5b81d0d558c9067f952c7af52ab7f19c2e70a916817929e4a5b256c93990bf3178eccb1ac8a850bc75df35f6781b6f4cb3370ce20d8b1ded92ed462348f628
languageName: node
linkType: hard

"typescript@patch:typescript@^4.4#~builtin<compat/typescript>":
version: 4.7.4
resolution: "typescript@patch:typescript@npm%3A4.7.4#~builtin<compat/typescript>::version=4.7.4&hash=a1c5e5"
"typescript@patch:typescript@4.8#~builtin<compat/typescript>":
version: 4.8.2
resolution: "typescript@patch:typescript@npm%3A4.8.2#~builtin<compat/typescript>::version=4.8.2&hash=a1c5e5"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 9096d8f6c16cb80ef3bf96fcbbd055bf1c4a43bd14f3b7be45a9fbe7ada46ec977f604d5feed3263b4f2aa7d4c7477ce5f9cd87de0d6feedec69a983f3a4f93e
checksum: 5cb0f02f414f5405f4b0e7ee1fd7fa9177b6a8783c9017b6cad85f56ce4c4f93e0e6f2ce37e863cb597d44227cd009474c9fbd85bf7a50004e5557426cb58079
languageName: node
linkType: hard

Expand Down
2 changes: 1 addition & 1 deletion src/syntax/funcops.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export function $resolveOverload(
funcName.includes("::")
? `'e.${funcName.split("::")[1]}()'`
: `operator '${funcName}'`
} with args: ${JSON.stringify(args)}`
} with args: ${args.map(arg => `${arg}`).join(", ")}`
);
}

Expand Down
10 changes: 6 additions & 4 deletions src/syntax/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ export type SelectModifiers = {
limit?: LimitExpression | number;
};

export type UnknownSelectModifiers = {[k in keyof SelectModifiers]: unknown};

export type NormalisedSelectModifiers = {
filter?: SelectFilterExpression;
order_by?: OrderByObjExpr[];
Expand Down Expand Up @@ -217,7 +219,7 @@ type argCardToResultCard<

export type InferFilterCardinality<
Base extends TypeSet,
Filter extends TypeSet | undefined
Filter
> = Filter extends TypeSet
? // Base is ObjectTypeExpression &
Base extends ObjectTypeSet // $expr_PathNode
Expand Down Expand Up @@ -275,7 +277,7 @@ export type InferFilterCardinality<

export type InferOffsetLimitCardinality<
Card extends Cardinality,
Modifers extends SelectModifiers
Modifers extends UnknownSelectModifiers
> = Modifers["limit"] extends number | LimitExpression
? cardinalityUtil.overrideLowerBound<Card, "Zero">
: Modifers["offset"] extends number | OffsetExpression
Expand All @@ -284,7 +286,7 @@ export type InferOffsetLimitCardinality<

export type ComputeSelectCardinality<
Expr extends ObjectTypeExpression,
Modifiers extends SelectModifiers
Modifiers extends UnknownSelectModifiers
> = InferOffsetLimitCardinality<
InferFilterCardinality<Expr, Modifiers["filter"]>,
Modifiers
Expand Down Expand Up @@ -700,7 +702,7 @@ export function select<Expr extends TypeSet>(
export function select<
Expr extends ObjectTypeExpression,
Shape extends objectTypeToSelectShape<Expr["__element__"]> & SelectModifiers,
Modifiers = Pick<Shape, SelectModifierNames>
Modifiers extends UnknownSelectModifiers = Pick<Shape, SelectModifierNames>
>(
expr: Expr,
shape: (
Expand Down
1 change: 1 addition & 0 deletions tools/cleanSyntax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const distSyntax = path.join(__dirname, "..", "dist", "syntax");
const esmSyntax = path.join(__dirname, "..", "dist", "__esm", "syntax");

async function run() {
console.log(`Cleaning up...`);
const mockSyntax = path.join(__dirname, "..", "dist", "syntax", "genMock");
console.log(`Removing ${mockSyntax}`);
await fs.rm(mockSyntax, {recursive: true, force: true});
Expand Down
8 changes: 4 additions & 4 deletions tools/compileForDeno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ await run({
],
})
)
.then(async () =>
Deno.writeTextFile(
.then(async () => {
await Deno.writeTextFile(
"./edgedb-deno/generate.ts",
`
export * from "./_src/reflection/cli.ts";
`
)
);
);
});

async function run({
sourceDir,
Expand Down
2 changes: 1 addition & 1 deletion tools/makeSyntax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ async function readGlob(params: {

async function run() {
// DTS

const dtsFiles = await readGlob({
pattern: "*.d.ts",
cwd: distSyntax,
Expand Down Expand Up @@ -177,4 +176,5 @@ async function run() {

console.log(`Generated syntax files.`);
}

run();

0 comments on commit dd25635

Please sign in to comment.