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-cli): delete *.d.ts files before creating new ones #25065

Merged
merged 1 commit into from
Jun 17, 2020

Conversation

pieh
Copy link
Contributor

@pieh pieh commented Jun 17, 2020

Description

#24381 introduced chain where gatsby-cli source files try to use build gatsby-cli files:

This weirdly doesn't cause issues other than tsc errors when trying to build already built package and it manifest with errors like these:

$ cross-env NODE_ENV=production npm run build && npm run typegen
npm WARN lifecycle The node binary used for scripts is /var/folders/7b/7_tqb8f50bx7jhyj0bn9r8v80000gn/T/yarn--1592386922492-0.026473074778530892/node but npm is using /Users/misiek/.nvm/versions/node/v10.16.3/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
> gatsby-cli@2.12.46 build /Users/misiek/dev/gatsby/packages/gatsby-cli
> babel src --out-dir lib --ignore "**/__tests__" --extensions ".ts,.js,.tsx"
Successfully compiled 43 files with Babel (2010ms).
npm WARN lifecycle The node binary used for scripts is /var/folders/7b/7_tqb8f50bx7jhyj0bn9r8v80000gn/T/yarn--1592386922492-0.026473074778530892/node but npm is using /Users/misiek/.nvm/versions/node/v10.16.3/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
> gatsby-cli@2.12.46 typegen /Users/misiek/dev/gatsby/packages/gatsby-cli
> tsc --emitDeclarationOnly --declaration --declarationDir lib/
error TS5055: Cannot write file '/Users/misiek/dev/gatsby/packages/gatsby-cli/lib/reporter/constants.d.ts' because it would overwrite input file.
error TS5055: Cannot write file '/Users/misiek/dev/gatsby/packages/gatsby-cli/lib/reporter/index.d.ts' because it would overwrite input file.
error TS5055: Cannot write file '/Users/misiek/dev/gatsby/packages/gatsby-cli/lib/reporter/redux/types.d.ts' because it would overwrite input file.
error TS5055: Cannot write file '/Users/misiek/dev/gatsby/packages/gatsby-cli/lib/reporter/reporter-phantom.d.ts' because it would overwrite input file.
error TS5055: Cannot write file '/Users/misiek/dev/gatsby/packages/gatsby-cli/lib/reporter/reporter-progress.d.ts' because it would overwrite input file.
error TS5055: Cannot write file '/Users/misiek/dev/gatsby/packages/gatsby-cli/lib/reporter/reporter-timer.d.ts' because it would overwrite input file.
error TS5055: Cannot write file '/Users/misiek/dev/gatsby/packages/gatsby-cli/lib/reporter/reporter.d.ts' because it would overwrite input file.
error TS5055: Cannot write file '/Users/misiek/dev/gatsby/packages/gatsby-cli/lib/reporter/types.d.ts' because it would overwrite input file.
error TS5055: Cannot write file '/Users/misiek/dev/gatsby/packages/gatsby-cli/lib/structured-errors/error-map.d.ts' because it would overwrite input file.
error TS5055: Cannot write file '/Users/misiek/dev/gatsby/packages/gatsby-cli/lib/structured-errors/types.d.ts' because it would overwrite input file.
Found 10 errors.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! gatsby-cli@2.12.46 typegen: `tsc --emitDeclarationOnly --declaration --declarationDir lib/`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the gatsby-cli@2.12.46 typegen script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/misiek/.npm/_logs/2020-06-17T09_42_11_646Z-debug.log
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Making sure we don't have declaration files before running typegen seems to fix (or rather work around this), so this is what this PR does

To reproduce the problem:

cd packages/gatsby-cli
yarn prepare
yarn prepare

2nd prepare will show those errors (1st one might too if you have those .d.ts files around already)

@pieh pieh requested a review from a team as a code owner June 17, 2020 16:06
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jun 17, 2020
@pieh pieh added topic: TypeScript migration and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Jun 17, 2020
@blainekasten
Copy link
Contributor

Yeah, this makes a ton of sense. We'll need to do this to gatsby-core-utils too probably

Copy link
Contributor

@ascorbic ascorbic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It aint pretty, but until we fix the imports this does the job

@blainekasten blainekasten merged commit b32c8d3 into master Jun 17, 2020
@blainekasten blainekasten deleted the fix/gatsby-cli/typegen branch June 17, 2020 16:54
pragmaticpat pushed a commit to pragmaticpat/gatsby that referenced this pull request Apr 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants