Typescript generation does not use type only import syntax
See original GitHub issueWhat are the steps to reproduce this issue?
Generate any typescript api: svelte, react or vue
What happens?
Generated import:
import axios,{
AxiosRequestConfig,
AxiosResponse,
AxiosError
} from 'axios'
import {
useQuery,
useMutation,
UseQueryOptions,
UseMutationOptions,
QueryFunction,
MutationFunction,
UseQueryStoreResult,
QueryKey
} from '@sveltestack/svelte-query'
What were you expecting to happen?
Should instead generate:
import axios,{
type AxiosRequestConfig,
type AxiosResponse,
AxiosError
} from 'axios'
import {
useQuery,
useMutation,
type UseQueryOptions,
type UseMutationOptions,
type QueryFunction,
type MutationFunction,
type UseQueryStoreResult,
type QueryKey
} from '@sveltestack/svelte-query'
Any logs, error output, etc?
none
Any other comments?
Since this feature was released in Typescript 3.8 (released Feb 20, 2020) I assume it should be safe to turn this on by default. Codebases with ‘preserveValueImports’ and ‘isolatedModules’ turned on will have issues otherwise like follows:
'UseMutationOptions' is a type and must be imported using a type-only import when 'preserveValueImports' and 'isolatedModules' are both enabled.ts(1444)
What versions are you using?
Operating System: OSX Package Version: v6.7.1 Browser Version: n/a
Issue Analytics
- State:
- Created a year ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Documentation - TypeScript 3.8
TypeScript 3.8 adds a new syntax for type-only imports and exports. ... When using import type to import a class, you can't do...
Read more >type-only imports — A new TypeScript feature that benefits ...
Solved by TypeScript 3.8. TypeScript 3.8 introduces new syntax which, when utilized, adds certainty to the type resolution process. Now a ...
Read more >Typedoc / Typescript Compiler throws error on an imported type
I would have expected my import statements to only include the literal type I am importing, and the enums required for the properties....
Read more >How we employed the new ECMAScript Module Support in ...
Just by adding type after import tells TS this should not be added to the output file. It then just resolves the type...
Read more >API - esbuild
You may also find the TypeScript type definitions for esbuild helpful as a ... import a file only if the export is actually...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Will be fix with the next release
I thought it wasn’t needed to split them if you have type and normal import at the same time. Will Check to change that quickly then