-
Notifications
You must be signed in to change notification settings - Fork 10.2k
chore: Properly typecheck gatsby
#31519
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
Changes from 6 commits
bf79526
5b9bde1
eeafe22
2cbb2da
add4e34
78cb31e
894bdf9
c2b1b7e
bc61bf0
e871e54
5f9743e
284b10f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,7 +54,7 @@ exports.create = function (args): typeof DiskStore { | |
| return new DiskStore(args && args.options ? args.options : args) | ||
| } | ||
|
|
||
| function DiskStore(options): void { | ||
| function DiskStore(this: any, options): void { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixes
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TIL: about typing
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this equal to DiskStore? (I'm also new to this in typescript 😂)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this was about having it implicitly:
I didn't want to type everything so this is the best middleground for now |
||
| options = options || {} | ||
|
|
||
| this.options = { | ||
|
|
@@ -91,7 +91,12 @@ function DiskStore(options): void { | |
| * @param {function} [cb] | ||
| * @returns {Promise} | ||
| */ | ||
| DiskStore.prototype.set = wrapCallback(async function (key, val, options) { | ||
| DiskStore.prototype.set = wrapCallback(async function ( | ||
| this: any, | ||
| key, | ||
| val, | ||
| options | ||
| ) { | ||
| key = key + `` | ||
| const filePath = this._getFilePathByKey(key) | ||
|
|
||
|
|
@@ -128,7 +133,7 @@ DiskStore.prototype.set = wrapCallback(async function (key, val, options) { | |
| * @param {function} [cb] | ||
| * @returns {Promise} | ||
| */ | ||
| DiskStore.prototype.get = wrapCallback(async function (key) { | ||
| DiskStore.prototype.get = wrapCallback(async function (this: any, key) { | ||
| key = key + `` | ||
| const filePath = this._getFilePathByKey(key) | ||
|
|
||
|
|
@@ -172,7 +177,7 @@ DiskStore.prototype.get = wrapCallback(async function (key) { | |
| /** | ||
| * delete entry from cache | ||
| */ | ||
| DiskStore.prototype.del = wrapCallback(async function (key) { | ||
| DiskStore.prototype.del = wrapCallback(async function (this: any, key) { | ||
| const filePath = this._getFilePathByKey(key) | ||
| try { | ||
| if (this.options.subdirs) { | ||
|
|
@@ -196,7 +201,9 @@ DiskStore.prototype.del = wrapCallback(async function (key) { | |
| /** | ||
| * cleanup cache on disk -> delete all files from the cache | ||
| */ | ||
| DiskStore.prototype.reset = wrapCallback(async function (): Promise<void> { | ||
| DiskStore.prototype.reset = wrapCallback(async function ( | ||
| this: any | ||
| ): Promise<void> { | ||
| const readdir = promisify(fs.readdir) | ||
| const stat = promisify(fs.stat) | ||
| const unlink = promisify(fs.unlink) | ||
|
|
@@ -265,10 +272,10 @@ function innerLock(resolve, reject, filePath): void { | |
| * unlocks a file path | ||
| * @type {Function} | ||
| * @param {string} filePath | ||
| * @returns {Promise} | ||
| * @returns {void} | ||
| * @private | ||
| */ | ||
| DiskStore.prototype._unlock = function _unlock(filePath): Promise<void> { | ||
| DiskStore.prototype._unlock = function _unlock(filePath): void { | ||
| globalGatsbyCacheLock.delete(filePath) | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,8 +37,8 @@ module.exports = function wrapCallback<T>( | |
| cb = args.pop() | ||
| } | ||
|
|
||
| // eslint-disable-next-line @babel/no-invalid-this | ||
| const promise = fn.apply(this, args) | ||
| // @ts-ignore - unsure if fixing this introduces problems | ||
| const promise = fn.apply(this, args) // eslint-disable-line @babel/no-invalid-this | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wouldn't eslint-disable-next-line still work because next line is also a comment?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, it didn't work for me so I had to move it :/ |
||
|
|
||
| if (typeof cb === `function`) { | ||
| promise.then( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,7 +73,9 @@ module.exports = async function build(program: IBuildArgs): Promise<void> { | |
|
|
||
| telemetry.trackCli(`BUILD_START`) | ||
| signalExit(exitCode => { | ||
| telemetry.trackCli(`BUILD_END`, { exitCode }) | ||
| telemetry.trackCli(`BUILD_END`, { | ||
| exitCode: exitCode as number | undefined, | ||
| }) | ||
| }) | ||
|
|
||
| const buildSpan = buildActivity.span | ||
|
|
@@ -196,7 +198,7 @@ module.exports = async function build(program: IBuildArgs): Promise<void> { | |
| { parentSpan: buildSpan } | ||
| ) | ||
| buildSSRBundleActivityProgress.start() | ||
| let pageRenderer: string | ||
| let pageRenderer = `` | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Used before initialized error" - setting a default here will also assign it |
||
| let waitForCompilerCloseBuildHtml | ||
| try { | ||
| const result = await buildRenderer(program, Stage.BuildHTML, buildSpan) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.