Use type imports in typescript templates
Created by: wallw-teal
This is specifically for typescript-fetch
, but may be applicable to all the TS templates:
The issue we are having is related to using preserveValueImports
and isolatedModules
in the TS config with TypeScript 4.5+. These are common config values for Svelte or Vue projects with TypeScript integration.
TS1444: 'ClassName' is a type and must be imported using a type-only import when 'preserveValueImports' and 'isolatedModules' are both enabled.
(where "ClassName" is a model or api class)
Basically, it is complaining that one of the imports is only used as a type (which is true), and therefore should be import type SomeType from ...;
instead.
Describe the solution you'd like
I would like to see TS 3.8+ use type imports for imports which are only used as types.
Describe alternatives you've considered
I am currently looking into simply suppressing the warning for our generated code only. Additionally, it may be possible to post process the files and fix them.
I can potentially help out with a PR if the team is amenable to this change, but I am not familiar enough with the templating system to know whether there is sufficient information there to only modify the template or if a larger change would be necessary.