question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typescript generation does not use type only import syntax

See original GitHub issue

What 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:closed
  • Created a year ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
anymaniaxcommented, Jul 3, 2022

Will be fix with the next release

1reaction
anymaniaxcommented, May 14, 2022

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found