-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
chore(gatsby): Create type declarations for gatsby plugin files #4928
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
635586e
add tsconfig and package.json script for creating types files
lobsterkatie ce93b9a
include new types files in npm package
lobsterkatie a43e715
add types files to eslint ignore list
lobsterkatie ccef62c
add types files to .gitignore
lobsterkatie 4b9f83d
add types files to cleaning script
lobsterkatie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,3 +40,5 @@ tmp.js | |
# eslint | ||
.eslintcache | ||
eslintcache/* | ||
|
||
*.d.ts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,5 @@ | |
# Gatsby specific | ||
!gatsby-browser.js | ||
!gatsby-node.js | ||
!gatsby-browser.d.ts | ||
!gatsby-node.d.ts | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
|
||
"include": ["gatsby-browser.js", "gatsby-node.js"], | ||
|
||
"compilerOptions": { | ||
// should include all types from `./tsconfig.json` plus types for all test frameworks used | ||
// "types": ["node", "jest"] | ||
"declaration": true, | ||
"declarationMap": false, | ||
"emitDeclarationOnly": true, | ||
"allowJs": true, | ||
"skipLibCheck": true | ||
|
||
// other package-specific, plugin-specific options | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: Do we want to include these declaration files in the tarball? If yes, then we need to adjust the Gatsby-specific
prepack
script to copy them tobuild
, too. Currently they do not end up in the tarball. Or is there another reason why we're adding them to.npmignore
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was on the fence about this. I opted for including them because they're useful for debugging, but I don't feel strongly about it. What do you think?
Oh, good catch. Unless you think it's a terrible idea to add them, I'll fix this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it can't hurt to include them. Don't know enough about Gatsby to know how many people would need them but if we're already producing them why not. We have to copy them to
build/types
to be found by thetypes
entry point, i think, right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing just came to my mind: If, in the tarball, they end up in
build/types
, we could just adjusttsconfig.plugin.json
to output them tobuild/types
, right? Then we don't have to adjust Gatsby'sprepack.ts
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You know, this is an excellent question, to which I don't actually know the answer.
ts-jest
finds them where they are, and I'd have to experiment to see if it similarly finds them intypes/
. Another thought I have here, though, is that these two JS files are already outside of the entrypoint structure, so maybe it's fine that their declaration files are, too. Is thetypes
endpoint even supposed to include them, given thatmain
andmodule
don't include the original source files?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update: I added them to the prepack script (and a few other places I'd forgotten about), but left them alongside the the source files they describe. I say we try it like this, and if it's a problem, someone will tell us. (Though my gut says it's fine.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good point, I didn't think about that. I say if it works for the source file this way, then why not for the declarations as well. Sounds good.