Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type only imports 166 #210

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,7 @@ export function processProject(
kind: StructureKind.ImportDeclaration,
moduleSpecifier,
namedImports,
isTypeOnly: true,
})
return structures
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface Empty { }
export interface Empty {}
export { CustomGuardAlias };`,
'test.guard.ts': `
import { Empty } from "./test";
import type { Empty } from "./test";

export function isEmpty(obj: unknown): obj is Empty {
const typedObj = obj as Empty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ testProcessProject(
{
'test.ts': null,
'test.debug.ts': `
import { Foo } from "./test";
import type { Foo } from "./test";

export function isFoo(obj: unknown): obj is Foo {
const typedObj = obj as Foo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ testProcessProject(
{
'test.ts': null,
'test.guard.ts': `
import { AnyAndString, UnknownAndString, AnyAndUnknownAndString } from "./test";
import type { AnyAndString, UnknownAndString, AnyAndUnknownAndString } from "./test";

export function isAnyAndString(obj: unknown): obj is AnyAndString {
const typedObj = obj as AnyAndString
Expand Down
2 changes: 1 addition & 1 deletion tests/features/any_and_unknown_work_in_union_types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ testProcessProject(
{
'test.ts': null,
'test.guard.ts': `
import { AnyOrString, UnknownOrString, AnyOrUnknownOrString } from "./test";
import type { AnyOrString, UnknownOrString, AnyOrUnknownOrString } from "./test";

export function isAnyOrString(obj: unknown): obj is AnyOrString {
const typedObj = obj as AnyOrString
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ testProcessProject(
{
'test.ts': null,
'test.guard.ts': `
import { TestType } from "./test";
import type { TestType } from "./test";

export function isTestType(obj: unknown): obj is TestType {
const typedObj = obj as TestType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ testProcessProject(
{
'test.ts': null,
'test.guard.ts': `
import { TestType } from "./test";
import type { TestType } from "./test";

export function isTestType(obj: unknown): obj is TestType {
const typedObj = obj as TestType
Expand Down
2 changes: 1 addition & 1 deletion tests/features/correctly_handles_default_export.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ testProcessProject(
{
'test.ts': null,
'test.guard.ts': `
import Foo from "./test";
import type Foo from "./test";

export function isFoo(obj: unknown): obj is Foo {
const typedObj = obj as Foo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ testProcessProject(
{
'test.ts': null,
'test.guard.ts': `
import { TestType } from "./test";
import type { TestType } from "./test";

export function isTestType(obj: unknown): obj is TestType {
const typedObj = obj as TestType
Expand Down
4 changes: 2 additions & 2 deletions tests/features/duplicate_guard_re-exports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ testProcessProject(
* Generated type guards for "custom.ts".
* WARNING: Do not manually change this file.
*/
import { Color } from "./custom";
import type { Color } from "./custom";

export function isColor(obj: unknown): obj is Color {
const typedObj = obj as Color
Expand Down Expand Up @@ -46,7 +46,7 @@ testProcessProject(
* Generated type guards for "custom.ts".
* WARNING: Do not manually change this file.
*/
import { Color } from "./custom";
import type { Color } from "./custom";

export function isColor(obj: unknown): obj is Color {
const typedObj = obj as Color
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ testProcessProject(
{
'test.ts': null,
'test.guard.ts': `
import { Foo } from "./test";
import type { Foo } from "./test";

export function isFoo(obj: unknown): obj is Foo {
const typedObj = obj as Foo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ testProcessProject(
{
'test.ts': null,
'test.guard.ts': `
import { X } from "./test";
import type { X } from "./test";

export function isX(obj: unknown): obj is X {
const typedObj = obj as X
Expand Down
2 changes: 1 addition & 1 deletion tests/features/generated_type_guards_for_enums.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ testProcessProject(
{
'test.ts': null,
'test.guard.ts': `
import { Types } from "./test";
import type { Types } from "./test";

export function isTypes(obj: unknown): obj is Types {
const typedObj = obj as Types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ testProcessProject(
{
'test.ts': null,
'test.guard.ts': `
import { X } from "./test";
import type { X } from "./test";

export function isX(obj: unknown): obj is X {
const typedObj = obj as X
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ testProcessProject(
{
'test.ts': null,
'test.guard.ts': `
import { Foo } from "./test";
import type { Foo } from "./test";

export function isFoo(obj: unknown): obj is Foo {
const typedObj = obj as Foo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ testProcessProject(
{
'test.ts': null,
'test.guard.ts': `
import { Types, TestItem } from "./test";
import type { Types, TestItem } from "./test";

export function isTypes(obj: unknown): obj is Types {
const typedObj = obj as Types
Expand Down
2 changes: 1 addition & 1 deletion tests/features/generates_tuples.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ testProcessProject(
{
'test.ts': null,
'test.guard.ts': `
import { A } from "./test";
import type { A } from "./test";

export function isA(obj: unknown): obj is A {
const typedObj = obj as A
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ testProcessProject(
{
'test.ts': null,
'test.guard.ts': `
import { Bool } from "./test";
import type { Bool } from "./test";

export function isBool(obj: unknown): obj is Bool {
const typedObj = obj as Bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ testProcessProject(
{
'test.ts': null,
'test.guard.ts': `
import { Foo } from "./test";
import type { Foo } from "./test";

export function isFoo(obj: unknown): obj is Foo {
const typedObj = obj as Foo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ testProcessProject(
{
'test.ts': null,
'test.guard.ts': `
import { Foo } from "./test";
import type { Foo } from "./test";

export function isFoo(obj: unknown): obj is Foo {
const typedObj = obj as Foo
Expand Down
2 changes: 1 addition & 1 deletion tests/features/generates_type_guards_for_boolean.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ testProcessProject(
{
'test.ts': null,
'test.guard.ts': `
import { Bool } from "./test";
import type { Bool } from "./test";

export function isBool(obj: unknown): obj is Bool {
const typedObj = obj as Bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ testProcessProject(
{
'test.ts': null,
'test.guard.ts': `
import { TestType } from "./test";
import type { TestType } from "./test";

export function isTestType(obj: unknown): obj is TestType {
const typedObj = obj as TestType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ testProcessProject(
{
'test.ts': null,
'test.guard.ts': `
import { Empty } from "./test";
import type { Empty } from "./test";

export function isEmpty(obj: unknown): obj is Empty {
const typedObj = obj as Empty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ testProcessProject(
{
'test.ts': null,
'test.guard.ts': `
import { Foo } from "./test";
import type { Foo } from "./test";

export function isFoo(obj: unknown): obj is Foo {
const typedObj = obj as Foo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ testProcessProject(
{
'test.ts': null,
'test.guard.ts': `
import { Bar, Foo } from "./test";
import type { Bar, Foo } from "./test";

export function isBar(obj: unknown): obj is Bar {
const typedObj = obj as Bar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ testProcessProject(
{
'test.ts': null,
'test.guard.ts': `
import { Foo } from "./test";
import type { Foo } from "./test";

export function isFoo(obj: unknown): obj is Foo {
const typedObj = obj as Foo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ testProcessProject(
{
'test.ts': null,
'test.guard.ts': `
import { Bar, Foo } from "./test";
import type { Bar, Foo } from "./test";

export function isBar(obj: unknown): obj is Bar {
const typedObj = obj as Bar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ testProcessProject(
{
'test.ts': null,
'test.guard.ts': `
import { Foo } from "./test";
import type { Foo } from "./test";

export function isFoo(obj: unknown): obj is Foo {
const typedObj = obj as Foo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ testProcessProject(
{
'test.ts': null,
'test.guard.ts': `
import { Foo } from "./test";
import type { Foo } from "./test";

export function isFoo(obj: unknown): obj is Foo {
const typedObj = obj as Foo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ testProcessProject(
{
'test.ts': null,
'test.guard.ts': `
import { Foo } from "./test";
import type { Foo } from "./test";

export function isFoo(obj: unknown): obj is Foo {
const typedObj = obj as Foo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ testProcessProject(
{
'test.ts': null,
'test.guard.ts': `
import { PropertyValueType, PropertyName, Foo } from "./test";
import type { PropertyValueType, PropertyName, Foo } from "./test";

export function isPropertyValueType(obj: unknown): obj is PropertyValueType {
const typedObj = obj as PropertyValueType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ testProcessProject(
{
'test.ts': null,
'test.guard.ts': `
import { Foo } from "./test";
import type { Foo } from "./test";

export function isFoo(obj: unknown): obj is Foo {
const typedObj = obj as Foo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ testProcessProject(
{
'test.ts': null,
'test.guard.ts': `
import { Bar, Foo } from "./test";
import type { Bar, Foo } from "./test";

export function isBar(obj: unknown): obj is Bar {
const typedObj = obj as Bar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ for (const propertyName of nonAlphanumericCharacterPropertyNames) {
{
'test.ts': null,
'test.guard.ts': `
import { Foo } from "./test";
import type { Foo } from "./test";

export function isFoo(obj: unknown): obj is Foo {
const typedObj = obj as Foo
Expand All @@ -59,7 +59,7 @@ for (const propertyName of nonAlphanumericCharacterPropertyNames) {
{
'test.ts': null,
'test.guard.ts': `
import { Foo } from "./test";
import type { Foo } from "./test";

export function isFoo(obj: unknown): obj is Foo {
const typedObj = obj as Foo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ testProcessProject(
{
'test.ts': null,
'test.guard.ts': `
import { TestType } from "./test";
import type { TestType } from "./test";

export function isTestType(obj: unknown): obj is TestType {
const typedObj = obj as TestType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ testProcessProject(
{
'test.ts': null,
'test.guard.ts': `
import { Branch1, Branch2, Branch3 } from "./test";
import type { Branch1, Branch2, Branch3 } from "./test";

export function isBranch1(obj: unknown): obj is Branch1 {
const typedObj = obj as Branch1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ testProcessProject(
{
'test.ts': null,
'test.guard.ts': `
import { Foo } from "./test";
import type { Foo } from "./test";

export function isFoo(obj: unknown): obj is Foo {
const typedObj = obj as Foo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ testProcessProject(
{
'test.ts': null,
'test.guard.ts': `
import { Foo } from "./test";
import type { Foo } from "./test";

export function isFoo(obj: unknown): obj is Foo {
const typedObj = obj as Foo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ testProcessProject(
{
'test.ts': null,
'test.guard.ts': `
import { Foo } from "./test";
import type { Foo } from "./test";

export function isFoo(obj: unknown): obj is Foo {
const typedObj = obj as Foo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ testProcessProject(
{
'test.ts': null,
'test.guard.ts': `
import { Foo } from "./test";
import type { Foo } from "./test";

export function isFoo(obj: unknown): obj is Foo {
if (DEBUG) return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ testProcessProject(
'test.ts': null,
'test-list.ts': null,
'test-list.guard.ts': `
import { isTestType } from "./test.guard";
import { TestTypeList } from "./test-list";
import type { isTestType } from "./test.guard";
import type { TestTypeList } from "./test-list";

export function isTestTypeList(obj: unknown): obj is TestTypeList {
const typedObj = obj as TestTypeList
Expand All @@ -34,7 +34,7 @@ testProcessProject(
}
`,
'test.guard.ts': `
import { TestType } from "./test";
import type { TestType } from "./test";

export function isTestType(obj: unknown): obj is TestType {
const typedObj = obj as TestType
Expand Down
Loading