Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable strict mode in tsconfig and fix type errors #11200

Merged
merged 33 commits into from
Nov 10, 2023
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
aca904f
Enable strict mode in tsconfig.json
jerelmiller Sep 7, 2023
0da3d3d
Fix type issues in utilities/graphql/transform
jerelmiller Sep 7, 2023
78ccf61
Use spread to push incoming objects in offsetLimitPagination
jerelmiller Sep 7, 2023
69d528a
Fix type issues in writeToStore test
jerelmiller Sep 7, 2023
e503cbb
Fix type issues in Concast
jerelmiller Sep 7, 2023
0fe49a0
Remove unused filterInPlace utility
jerelmiller Sep 7, 2023
e34d084
Add this type to itAsync
jerelmiller Sep 7, 2023
962bd47
Add ! annotation to mockLink
jerelmiller Sep 7, 2023
36129f8
Fix assignment from unknown in error link
jerelmiller Sep 7, 2023
cea054e
Fix type issue in readFromStore
jerelmiller Sep 7, 2023
bed3439
Fix type issues in useQuery
jerelmiller Sep 7, 2023
b568689
some progress
phryneas Sep 8, 2023
6498326
more type fixes
phryneas Sep 13, 2023
b8c6eb6
change `addExportedVariables` signature
phryneas Sep 13, 2023
c3a761d
better typing
phryneas Sep 13, 2023
9eb5e3e
undo deprecation
phryneas Sep 13, 2023
0966cc9
Merge branch 'main' into enable-strict-mode
phryneas Sep 13, 2023
a101977
test types
phryneas Sep 13, 2023
55a6351
add api extractor
phryneas Sep 14, 2023
f909921
add api reports
phryneas Sep 14, 2023
e1e2fbb
add workflow
phryneas Sep 14, 2023
0426c84
formatting
phryneas Sep 14, 2023
be151b0
package lock
phryneas Sep 14, 2023
c83b042
remove `ensureResult` for this PR, add `TODO` type
phryneas Sep 14, 2023
4aa485b
Merge branch 'pr/api-extractor' into enable-strict-mode
phryneas Sep 14, 2023
1e7c5c6
API updates for this PR
phryneas Sep 14, 2023
c080309
Merge remote-tracking branch 'origin/main' into enable-strict-mode
phryneas Nov 10, 2023
0b2cf25
size-limit
phryneas Nov 10, 2023
9303630
introduce IDE-only `tsconfig.json`
phryneas Nov 10, 2023
5e3fb70
formatting
phryneas Nov 10, 2023
04dcc0d
fix path
phryneas Nov 10, 2023
2cb5c83
Merge pull request #11359 from apollographql/pr/enable-test-ts
jerelmiller Nov 10, 2023
94b07f9
Add changeset
jerelmiller Nov 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add api extractor
phryneas committed Sep 14, 2023
commit 55a63515283eda5c48400b8685d13fa0f6e65b60
127 changes: 127 additions & 0 deletions api-extractor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/**
* Config file for API Extractor. For more info, please visit: https://api-extractor.com
*/
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"projectFolder": ".",
"mainEntryPointFilePath": "<projectFolder>/dist/index.d.ts",
"bundledPackages": [],
"newlineKind": "lf",

/**
* Set to true when invoking API Extractor's test harness. When `testMode` is true, the `toolVersion` field in the
* .api.json file is assigned an empty string to prevent spurious diffs in output files tracked for tests.
*
* DEFAULT VALUE: "false"
*/
// "testMode": false,

/**
* Determines how the TypeScript compiler engine will be invoked by API Extractor.
*/
"compiler": {
"tsconfigFilePath": "<projectFolder>/tsconfig.json",
"overrideTsconfig": {},
"skipLibCheck": true
},

/**
* Configures how the API report file (*.api.md) will be generated.
*/
"apiReport": {
"enabled": true,
"reportFileName": "<unscopedPackageName>.api.md",
"reportFolder": "<projectFolder>/.api-reports/",
"reportTempFolder": "<projectFolder>/.api-reports/temp/",
"includeForgottenExports": true
},

"docModel": {
"enabled": false
},

"dtsRollup": {
"enabled": false

},
"tsdocMetadata": {
"enabled": false
},

/**
* Configures how API Extractor reports error and warning messages produced during analysis.
*
* There are three sources of messages: compiler messages, API Extractor messages, and TSDoc messages.
*/
"messages": {
/**
* Configures handling of diagnostic messages reported by the TypeScript compiler engine while analyzing
* the input .d.ts files.
*
* TypeScript message identifiers start with "TS" followed by an integer. For example: "TS2551"
*
* DEFAULT VALUE: A single "default" entry with logLevel=warning.
*/
"compilerMessageReporting": {
/**
* Configures the default routing for messages that don't match an explicit rule in this table.
*/
"default": {
/**
* Specifies whether the message should be written to the the tool's output log. Note that
* the "addToApiReportFile" property may supersede this option.
*
* Possible values: "error", "warning", "none"
*
* Errors cause the build to fail and return a nonzero exit code. Warnings cause a production build fail
* and return a nonzero exit code. For a non-production build (e.g. when "api-extractor run" includes
* the "--local" option), the warning is displayed but the build will not fail.
*
* DEFAULT VALUE: "warning"
*/
"logLevel": "warning"

/**
* When addToApiReportFile is true: If API Extractor is configured to write an API report file (.api.md),
* then the message will be written inside that file; otherwise, the message is instead logged according to
* the "logLevel" option.
*
* DEFAULT VALUE: false
*/
// "addToApiReportFile": false
}

// "TS2551": {
// "logLevel": "warning",
// "addToApiReportFile": true
// },
//
// . . .
},

/**
* Configures handling of messages reported by API Extractor during its analysis.
*
* API Extractor message identifiers start with "ae-". For example: "ae-extra-release-tag"
*
* DEFAULT VALUE: See api-extractor-defaults.json for the complete table of extractorMessageReporting mappings
*/
"extractorMessageReporting": {
"default": {
"logLevel": "warning"
// "addToApiReportFile": false
},

"ae-missing-release-tag": {
"logLevel": "none"
}
}

// "ae-extra-release-tag": {
// "logLevel": "warning",
// "addToApiReportFile": true
// },
//
// . . .
}
}
55 changes: 55 additions & 0 deletions config/apiExtractor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import * as path from "path";
import {
Extractor,
ExtractorConfig,
ExtractorResult,
} from "@microsoft/api-extractor";
// @ts-ignore
import { map } from "./entryPoints.js";

// Load and parse the api-extractor.json file
const configObjectFullPath = path.resolve(__dirname, "../api-extractor.json");
const baseConfig = ExtractorConfig.loadFile(configObjectFullPath);
const packageJsonFullPath = path.resolve(__dirname, "../package.json");

process.exitCode = 0;

map((entryPoint: { dirs: string[] }) => {
const path = entryPoint.dirs.join("/");
const mainEntryPointFilePath =
`<projectFolder>/dist/${path}/index.d.ts`.replace("//", "/");
console.log(
"\n\nCreating API extractor report for " + mainEntryPointFilePath
);

const extractorConfig: ExtractorConfig = ExtractorConfig.prepare({
configObject: {
...baseConfig,
mainEntryPointFilePath,
apiReport: {
enabled: true,
...baseConfig.apiReport,
reportFileName: `api-report${
path ? "-" + path.replace("/", "_") : ""
}.md`,
},
},
packageJsonFullPath,
configObjectFullPath,
});

const extractorResult: ExtractorResult = Extractor.invoke(extractorConfig, {
localBuild: process.env.CI === undefined,
showVerboseMessages: true,
});

if (extractorResult.succeeded) {
console.log(`✅ API Extractor completed successfully`);
} else {
console.error(
`❗ API Extractor completed with ${extractorResult.errorCount} errors` +
` and ${extractorResult.warningCount} warnings`
);
process.exitCode = 1;
}
});
574 changes: 574 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -42,6 +42,7 @@
"prepdist": "node ./config/prepareDist.js",
"prepdist:changesets": "ts-node-script config/prepareChangesetsRelease.ts",
"postprocess-dist": "ts-node-script config/postprocessDist.ts",
"extract-api": "ts-node-script config/apiExtractor.ts",
"clean": "rimraf dist coverage lib temp",
"check:format": "prettier --check .",
"ci:precheck": "node config/precheck.js",
@@ -107,6 +108,7 @@
"@changesets/changelog-github": "0.4.8",
"@changesets/cli": "2.26.2",
"@graphql-tools/schema": "10.0.0",
"@microsoft/api-extractor": "7.36.4",
"@rollup/plugin-node-resolve": "11.2.1",
"@size-limit/esbuild-why": "8.2.6",
"@size-limit/preset-small-lib": "8.2.6",
2 changes: 1 addition & 1 deletion src/core/QueryManager.ts
Original file line number Diff line number Diff line change
@@ -96,7 +96,7 @@ interface TransformCacheEntry {
asQuery: DocumentNode;
}

type DefaultOptions = import("./ApolloClient.js").DefaultOptions;
import type { DefaultOptions } from "./ApolloClient.js";

export class QueryManager<TStore> {
public cache: ApolloCache<TStore>;