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

chore(gatsby): convert api-node-helpers-docs to typescript #36326

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
// package (used to parse jsdoc and provide content for API reference pages)
// behaviour is inconsistent when not using semicolons after
// object declarations.
files: ["**/api-node-helpers-docs.js"],
files: ["**/api-node-helpers-docs.ts"],
options: {
semi: true,
},
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/reference/config-files/node-api-helpers.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Node API Helpers
description: Documentation on API helpers for creating nodes within Gatsby's GraphQL data layer
jsdoc: ["src/utils/api-node-helpers-docs.js"]
jsdoc: ["src/utils/api-node-helpers-docs.ts"]
apiCalls: NodeAPIHelpers
contentsHeading: Shared helpers
showTopLevelSignatures: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable no-unused-vars */

/***/
// @ts-ignore unused variable
const GatsbyReporter = {
/**
* @callback GatsbyReporterFn
Expand Down Expand Up @@ -77,9 +79,10 @@ const GatsbyReporter = {
* activity.end()
*/
activityTimer: true,
};
}

/***/
// @ts-ignore unused variable
const GatsbyCache = {
/**
* Retrieve cached value
Expand Down Expand Up @@ -108,9 +111,10 @@ const GatsbyCache = {
* await cache.del(`unique-key`)
*/
del: true,
};
}

/***/
// @ts-ignore unused variable
const GatsbyTracing = {
/**
* Global tracer instance. Check
Expand Down Expand Up @@ -154,22 +158,22 @@ const GatsbyTracing = {
* }
*/
startSpan: true,
};
}

/**
* Get cache instance by name - this should only be used by plugins that
* accept subplugins.
* @param {string} id id of the node
* @returns {GatsbyCache} See [`cache`](#cache) section for reference.
*/
module.exports.getCache = true;
export const getCache = true

/**
* Key-value store used to persist results of time/memory/cpu intensive
* tasks. All functions are async and return promises.
* @type {GatsbyCache}
*/
module.exports.cache = true;
export const cache = true

/**
* Create a stable content digest from a string or object, you can use the
Expand All @@ -187,15 +191,15 @@ module.exports.cache = true;
* }
* }
*/
module.exports.createContentDigest = true;
export const createContentDigest = true

/**
* Collection of functions used to programmatically modify Gatsby’s internal state.
*
* See [`actions`](/docs/actions/) reference.
* @type {Actions}
*/
module.exports.actions = true;
export const actions = true

/**
* Get content for a node from the plugin that created it.
Expand All @@ -212,30 +216,30 @@ module.exports.actions = true;
* }
* }
*/
module.exports.loadNodeContent = true;
export const loadNodeContent = true

/**
* Internal redux state used for application state. Do not use, unless you
* absolutely must. Store is considered a private API and can change with
* any version.
* @type {Redux.Store}
*/
module.exports.store = true;
export const store = true

/**
* Internal event emitter / listener. Do not use, unless you absolutely
* must. Emitter is considered a private API and can change with any version.
* @type {Emitter}
*/
module.exports.emitter = true;
export const emitter = true

/**
* Get array of all nodes.
* @returns {Node[]} Array of nodes.
* @example
* const allNodes = getNodes()
*/
module.exports.getNodes = true;
export const getNodes = true

/**
* Get single node by given ID.
Expand All @@ -246,7 +250,7 @@ module.exports.getNodes = true;
* @example
* const node = getNode(id)
*/
module.exports.getNode = true;
export const getNode = true

/**
* Get array of nodes of given type.
Expand All @@ -255,13 +259,13 @@ module.exports.getNode = true;
* @example
* const markdownNodes = getNodesByType(`MarkdownRemark`)
*/
module.exports.getNodesByType = true;
export const getNodesByType = true

/**
* Set of utilities to output information to user
* @type {GatsbyReporter}
*/
module.exports.reporter = true;
export const reporter = true

/**
* Get single node by given ID and create dependency for given path.
Expand All @@ -274,7 +278,7 @@ module.exports.reporter = true;
* @param {string} path of the node.
* @returns {Node} Single node instance.
*/
module.exports.getNodeAndSavePathDependency = true;
export const getNodeAndSavePathDependency = true

/**
* Utility function useful to generate globally unique and stable node IDs.
Expand All @@ -289,7 +293,7 @@ module.exports.getNodeAndSavePathDependency = true;
* ...restOfNodeData
* }
*/
module.exports.createNodeId = true;
export const createNodeId = true

/**
* Set of utilities that allow adding more detailed tracing for plugins.
Expand All @@ -298,7 +302,7 @@ module.exports.createNodeId = true;
* page for more details.
* @type {GatsbyTracing}
*/
module.exports.tracing = true;
export const tracing = true

/**
* Use to prefix resources URLs. `pathPrefix` will be either empty string or
Expand All @@ -310,7 +314,7 @@ module.exports.tracing = true;
* page for details about path prefixing.
* @type {string}
*/
module.exports.pathPrefix = true;
export const pathPrefix = true

/**
* This is the same as `pathPrefix` passed in `gatsby-config.js`.
Expand All @@ -319,4 +323,4 @@ module.exports.pathPrefix = true;
* It won't include the `assetPrefix`.
* @type {string}
*/
module.exports.basePath = true;
export const basePath = true