-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Question: should we use allowSyntheticDefaultImports:true
or skipLibCheck:true
in every React project?
#8964
Comments
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs. |
Once the react RFC is figured out we can provide recommendations here I think. |
FWIW, we recommend WRT: |
@orta why we should enable skipLibCheck since 3.9? |
In my experience type checking is significantly faster with |
This will be much faster, and I will also set |
There are currently two ways of writing in the community:
In TypeScript Documentation it write:
and in CRA:
create-react-app/packages/cra-template-typescript/template/src/index.tsx
Line 1 in 9123aae
For users of a library, both usages are allowed. Because CRA has enabled
allowSyntheticDefaultImports
andskipLibCheck
.create-react-app/packages/react-scripts/scripts/utils/verifyTypeScriptSetup.js
Lines 104 to 106 in 30fc0bf
But for users of the library, the problem arises:
If I write a library using
import React from 'react';
.Then downstream users must enable
allowSyntheticDefaultImports
orskipLibCheck
, otherwise they will not be able to use this library in Typescript.For users who configure webpack and tsconfig themselves, it is common to turn off
allowSyntheticDefaultImports
andskipLibCheck
(default behavior).Question: Which of the following two methods is more recommended?
import * as React from 'react';
, but not restrict library users to useimport * as React from 'react';
orimport React from 'react';
Whichever method we choose, we should specify this behavior in the react / create-react-app / TypeScript documentation website, and we should have some more detailed suggestions for the react library authors and react library users.
related issues:
@ianschmitz @gaearon @RyanCavanaugh @DanielRosenwasser @orta
The text was updated successfully, but these errors were encountered: