Skip to content

Commit

Permalink
make TS check strictest (#421)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed Sep 29, 2024
1 parent 40c7698 commit 59c89bd
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 20 deletions.
7 changes: 4 additions & 3 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { PlaywrightTestConfig } from '@playwright/test';
import { devices } from '@playwright/test';

const isCI = !!process.env['CI'];
/**
* See https://playwright.dev/docs/test-configuration.
*/
Expand All @@ -18,11 +19,11 @@ const config: PlaywrightTestConfig = {
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
forbidOnly: isCI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
retries: isCI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
workers: isCI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: [['html', { open: 'never' }]],
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
Expand Down
27 changes: 16 additions & 11 deletions scripts/gen-changelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ async function genChangeLog(): Promise<string> {
.map((label) => label.name)
.filter((label) => label.startsWith('PR: '));

if (labels.length === 0) {
const label = labels[0];
if (label == null) {
throw new Error(`PR is missing label. See ${pr.url}`);
}
if (labels.length > 1) {
Expand All @@ -92,7 +93,6 @@ async function genChangeLog(): Promise<string> {
);
}

const label = labels[0];
if (labelsConfig[label] == null) {
throw new Error(`Unknown label: ${label}. See ${pr.url}`);
}
Expand Down Expand Up @@ -275,22 +275,27 @@ function commitInfoToPR(commit: CommitInfo): number {
const associatedPRs = commit.associatedPullRequests.nodes.filter(
(pr) => pr.repository.nameWithOwner === `${githubOrg}/${githubRepo}`,
);
if (associatedPRs.length === 0) {
const match = / \(#(?<prNumber>[0-9]+)\)$/m.exec(commit.message);
if (match?.groups?.prNumber != null) {
return parseInt(match.groups.prNumber, 10);
}

if (associatedPRs.length > 1) {
throw new Error(
`Commit ${commit.oid} has no associated PR: ${commit.message}`,
`Commit ${commit.oid} is associated with multiple PRs: ${commit.message}`,
);
}
if (associatedPRs.length > 1) {

const associatedPR = associatedPRs[0];
if (associatedPR == null) {
const match = / \(#(?<prNumber>[0-9]+)\)$/m.exec(commit.message);
const { prNumber } = match?.groups ?? {};

if (prNumber != null) {
return parseInt(prNumber, 10);
}
throw new Error(
`Commit ${commit.oid} is associated with multiple PRs: ${commit.message}`,
`Commit ${commit.oid} has no associated PR: ${commit.message}`,
);
}

return associatedPRs[0].number;
return associatedPR.number;
}

async function getPRsInfo(
Expand Down
8 changes: 4 additions & 4 deletions src/introspection/introspection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ function removeRelayTypes(schema: GraphQLSchema) {
}

const connectionFields = connectionType.getFields();
const edgeType = getNamedType(connectionFields.edges?.type);
if (!isObjectType(edgeType) || connectionFields.pageInfo == null) {
const edgeType = getNamedType(connectionFields['edges']?.type);
if (!isObjectType(edgeType) || connectionFields['pageInfo'] == null) {
continue;
}

const edgeFields = edgeType.getFields();
const nodeType = edgeFields.node?.type;
if (nodeType == null || edgeFields.cursor == null) {
const nodeType = edgeFields['node']?.type;
if (nodeType == null || edgeFields['cursor'] == null) {
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion src/introspection/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function typeNameToId(name: string) {
return `TYPE::${name}`;
}

export function extractTypeName(typeID: string) {
export function extractTypeName(typeID: string): string {
const [, type] = typeID.split('::');
return type;
}
Expand Down
22 changes: 21 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
{
"compilerOptions": {
// copy of https://github.com/tsconfig/bases/blob/main/bases/strictest.json
"strict": true,
"allowUnusedLabels": false,
"allowUnreachableCode": false,
// FIXME: "exactOptionalPropertyTypes": true,
"noFallthroughCasesInSwitch": true,
// FIXME: "noImplicitOverride": true,
"noImplicitReturns": true,
"noPropertyAccessFromIndexSignature": true,
// FIXME: "noUncheckedIndexedAccess": true,
"noUnusedLocals": true,
"noUnusedParameters": true,

"isolatedModules": true,

"checkJs": true,

// FIXME: "esModuleInterop": true,
"skipLibCheck": true,
// end copy

"module": "es2015",
"moduleResolution": "node",
"target": "es2021",
"allowSyntheticDefaultImports": true,
"strict": true,
"sourceMap": true,
"noEmit": true,
"pretty": true,
Expand Down

0 comments on commit 59c89bd

Please sign in to comment.