-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Internal improvement: Make consistent use of import type
in most TS packages
#4110
Conversation
Wrt reclassifying e.g.
import * as Preserve from "@truffle/preserve";
import { TargetPathOptions } from "./types";
export declare function targetPath(options: TargetPathOptions): Preserve.Process<Preserve.Target>; If we set |
@rkalis Is that true? All of the type info gets stripped out during compilation according to the docs. "It always gets fully erased" https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html I guess we can test this. |
I'm not 100% what the interaction will be in this case, but the snippet I pasted above is the compiled We can test the interaction to be sure. |
I mean, if you only need the dependency to compile, then it's a devDependency, right? |
Yes, but I don't think the package's devDependencies get installed when installing a package, which means that type checking would fail when compiling a project that uses @truffle/preserve-fs. I might be wrong there though. |
Let's play it safe and keep it a regular dep for now. |
…serve-fs" This reverts commit 83cd5b7.
OK, reverted that commit. |
In our Typescript packages, we've often been using
import
when we could be usingimport type
. This PR is the start of an attempt at fixing that. Basically I went over most of the TS packages and replaced everyimport
I could find that was only importing types withimport type
(I also did the same thing with exports where it seemed appropriate).I did not touch
codec
ordecoder
because #3974 is still outstanding and I don't want even more merge conflicts.I did not touch
db
ordb-kit
because they're large and confusing and I don't know them well, and I'm hoping someone else can handle those. Edit: According to @gnidan, these packages already do this properly, so I don't need to do anything there! Hooray!I did not touch testing code, because I did not really see a need.
While doing this, I also noticed that:
@truffle/preserve-fs
only uses@truffle/preserve
for types, and@truffle/preserve-to-ipfs
only usescids
for typesSo I reclassified both of those dependencies as devDependencies. The former seems a little weird, but that's what the code says! I don't know these packages really.