We are bound to run into problems with duplicate imports sooner rather than later.
Why
Say we have two plugins that both need to add a context provider in _app.tsx. Now say each of these plugins imports React from "react", in order to later reference React.createContext.
Now the CLI will generate the duplicate imports
import React from "react";
import React from "react";
which will throw Duplicate identifier 'React'. ts(2300)
The solution
Before running Prettier on the generated code base at the end of the setup process, perform the organizeImports function from the TypeScript Language Service, which is available through the typescript package.
We are bound to run into problems with duplicate imports sooner rather than later.
Why
Say we have two plugins that both need to add a context provider in
_app.tsx
. Now say each of these plugins importsReact from "react"
, in order to later referenceReact.createContext
.Now the CLI will generate the duplicate imports
which will throw
Duplicate identifier 'React'. ts(2300)
The solution
Before running Prettier on the generated code base at the end of the setup process, perform the
organizeImports
function from the TypeScript Language Service, which is available through thetypescript
package.Resources: