-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Add warning for TypeScript set up issues and fix Babel config #10998
Conversation
f0b4d41
to
34bc671
Compare
34bc671
to
c859205
Compare
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 comment otherwise LGTM
lib/cli/src/warn.ts
Outdated
|
||
export const warn = ({ hasTSDependency }: Options) => { | ||
if (!hasTSDependency) { | ||
const hasTSFiles = !!globby.sync(['**/*.(ts|tsx)', '!**/node_modules', '!**/*.d.ts']).length; |
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.
'**/*.(ts|tsx)'
is not a proper glob 😄 See #10926
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.
This is what I used in codemod if it's useful:
https://github.com/storybookjs/storybook/blob/next/lib/codemod/src/index.js#L45
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.
According to the docs here:
https://github.com/isaacs/minimatch#usage
https://github.com/sindresorhus/globby#patterns
This is supported, and is called extglob
. Maybe you can give me some more info around the change? I didn't see any docs linked in the PR referenced.
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.
const hasTSFiles = !!globby.sync(['**/*.(ts|tsx)', '!**/node_modules', '!**/*.d.ts']).length;
should be
const hasTSFiles = !!globby.sync(['**/*.@(ts|tsx)', '!**/node_modules', '!**/*.d.ts']).length;
lib/cli/src/warn.ts
Outdated
|
||
export const warn = ({ hasTSDependency }: Options) => { | ||
if (!hasTSDependency) { | ||
const hasTSFiles = !!globby.sync(['**/*.(ts|tsx)', '!**/node_modules', '!**/*.d.ts']).length; |
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.
const hasTSFiles = !!globby.sync(['**/*.(ts|tsx)', '!**/node_modules', '!**/*.d.ts']).length;
should be
const hasTSFiles = !!globby.sync(['**/*.@(ts|tsx)', '!**/node_modules', '!**/*.d.ts']).length;
c859205
to
34506bd
Compare
OK, I found the reference here: |
@@ -0,0 +1,39 @@ | |||
import globby from 'globby'; |
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.
any reason to add a dep when we already depend on glob
?
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.
In CLI, there was no dependency. Globby seemed more reliable from my (quick) testing of the two, and supports arrays. This implementation was lifted from the same check in CRA.
Issue: #10943
What I did
How to test
Tests have been added for the CLI.