Use new TS option to preserve imports in tests

These assertions were here to prevent imports (needed for svelte-inine-compile) from being removed.
This commit is contained in:
Ryan Gossiaux
2022-01-17 16:49:49 -05:00
parent 5d83d35e71
commit 6d2aa60d22
62 changed files with 124 additions and 74 deletions

View File

@@ -16,7 +16,8 @@
<script lang="ts">
import { getContext, setContext } from "svelte";
import { Readable, writable, Writable } from "svelte/store";
import type { Readable, Writable } from "svelte/store";
import { writable } from "svelte/store";
export let name: string;
let descriptionIds: string[] = [];
let contextStore: Writable<DescriptionContext> = writable({

View File

@@ -19,8 +19,6 @@ afterAll(() => jest.restoreAllMocks());
it("should be possible to render a DescriptionProvider", () => {
render(DescriptionProvider, { name: "test" });
// This dumb line is to trick the TS compiler to not remove my imports
expect(DescriptionProvider).not.toBe(Description);
});
it("should be possible to use a DescriptionProvider without using a Description", async () => {

View File

@@ -41,7 +41,8 @@
<script lang="ts">
import { State, useOpenClosed } from "$lib/internal/open-closed";
import { Readable, writable, Writable } from "svelte/store";
import type { Readable, Writable } from "svelte/store";
import { writable } from "svelte/store";
import { match } from "$lib/utils/match";
import { useId } from "$lib/hooks/use-id";
import { useInertOthers } from "$lib/hooks/use-inert-others";

View File

@@ -1,5 +1,6 @@
<script lang="ts" context="module">
import { Readable, writable, Writable } from "svelte/store";
import type { Readable, Writable } from "svelte/store";
import { writable } from "svelte/store";
import { getContext, setContext } from "svelte";
export enum DisclosureStates {
Open,

View File

@@ -7,7 +7,8 @@
import type { SupportedAs } from "$lib/internal/elements";
import type { HTMLActionArray } from "$lib/hooks/use-actions";
import Render from "$lib/utils/Render.svelte";
import { Writable, writable } from "svelte/store";
import type { Writable } from "svelte/store";
import { writable } from "svelte/store";
import { resolveButtonType } from "$lib/utils/resolve-button-type";
const forwardEvents = forwardEventsBuilder(get_current_component());

View File

@@ -14,7 +14,8 @@
<script lang="ts">
import { getContext, setContext } from "svelte";
import { writable, Writable } from "svelte/store";
import type { Writable } from "svelte/store";
import { writable } from "svelte/store";
export let name: string;
let labelIds: string[] = [];
let contextStore: Writable<LabelContext> = writable({

View File

@@ -58,7 +58,8 @@
calculateActiveIndex,
} from "$lib/utils/calculate-active-index";
import { createEventDispatcher, getContext, setContext } from "svelte";
import { Readable, writable, Writable } from "svelte/store";
import type { Readable, Writable } from "svelte/store";
import { writable } from "svelte/store";
import { match } from "$lib/utils/match";
import { State, useOpenClosedProvider } from "$lib/internal/open-closed";
import { forwardEventsBuilder } from "$lib/internal/forwardEventsBuilder";

View File

@@ -4,7 +4,8 @@
calculateActiveIndex,
} from "$lib/utils/calculate-active-index";
import { getContext, setContext } from "svelte";
import { Readable, writable, Writable } from "svelte/store";
import type { Readable, Writable } from "svelte/store";
import { writable } from "svelte/store";
import { State, useOpenClosedProvider } from "$lib/internal/open-closed";
import { match } from "$lib/utils/match";
import type { HTMLActionArray } from "$lib/hooks/use-actions";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { useMenuContext, MenuStates, MenuItemData } from "./Menu.svelte";
import type { MenuItemData } from "./Menu.svelte";
import { useMenuContext, MenuStates } from "./Menu.svelte";
import { useId } from "$lib/hooks/use-id";
import { Focus } from "$lib/utils/calculate-active-index";
import { afterUpdate, onDestroy, onMount, tick } from "svelte";

View File

@@ -51,7 +51,8 @@
import { State, useOpenClosedProvider } from "$lib/internal/open-closed";
import { usePopoverGroupContext } from "./PopoverGroup.svelte";
import { getContext, setContext, onMount } from "svelte";
import { Readable, writable, Writable } from "svelte/store";
import type { Readable, Writable } from "svelte/store";
import { writable } from "svelte/store";
import { forwardEventsBuilder } from "$lib/internal/forwardEventsBuilder";
import { get_current_component } from "svelte/internal";
import type { SupportedAs } from "$lib/internal/elements";

View File

@@ -19,11 +19,8 @@
focusIn,
} from "$lib/utils/focus-management";
import { getContext, setContext } from "svelte";
import {
PopoverStates,
StateDefinition,
usePopoverContext,
} from "./Popover.svelte";
import type { StateDefinition } from "./Popover.svelte";
import { PopoverStates, usePopoverContext } from "./Popover.svelte";
import { forwardEventsBuilder } from "$lib/internal/forwardEventsBuilder";
import { get_current_component } from "svelte/internal";
import type { SupportedAs } from "$lib/internal/elements";

View File

@@ -1,6 +1,7 @@
<script lang="ts" context="module">
import { getContext, setContext } from "svelte";
import { Readable, writable } from "svelte/store";
import type { Readable } from "svelte/store";
import { writable } from "svelte/store";
const PORTAL_GROUP_CONTEXT_NAME = "headlessui-portal-group-context";
export function usePortalGroupContext():

View File

@@ -13,9 +13,6 @@ beforeEach(() => {
})
it('should be possible to use a Portal', () => {
// Dummy assertion to trick TS compiler
expect(Portal).not.toBe(PortalGroup);
expect(getPortalRoot()).toBe(null)
render(svelte`

View File

@@ -2,7 +2,8 @@
import DescriptionProvider from "$lib/components/description/DescriptionProvider.svelte";
import LabelProvider from "$lib/components/label/LabelProvider.svelte";
import { createEventDispatcher, getContext, setContext } from "svelte";
import { Readable, Writable, writable } from "svelte/store";
import type { Readable, Writable } from "svelte/store";
import { writable } from "svelte/store";
import { Focus, focusIn, FocusResult } from "$lib/utils/focus-management";
import { Keys } from "$lib/utils/keyboard";
import { useId } from "$lib/hooks/use-id";

View File

@@ -2,7 +2,8 @@
import { onDestroy } from "svelte";
import DescriptionProvider from "$lib/components/description/DescriptionProvider.svelte";
import LabelProvider from "$lib/components/label/LabelProvider.svelte";
import { useRadioGroupContext, Option } from "./RadioGroup.svelte";
import type { Option } from "./RadioGroup.svelte";
import { useRadioGroupContext } from "./RadioGroup.svelte";
import { useId } from "$lib/hooks/use-id";
import { forwardEventsBuilder } from "$lib/internal/forwardEventsBuilder";
import { get_current_component } from "svelte/internal";

View File

@@ -13,7 +13,8 @@
import DescriptionProvider from "$lib/components/description/DescriptionProvider.svelte";
import LabelProvider from "$lib/components/label/LabelProvider.svelte";
import { getContext, setContext } from "svelte";
import { Writable, writable } from "svelte/store";
import type { Writable } from "svelte/store";
import { writable } from "svelte/store";
import { forwardEventsBuilder } from "$lib/internal/forwardEventsBuilder";
import { get_current_component } from "svelte/internal";
import type { SupportedAs } from "$lib/internal/elements";

View File

@@ -46,7 +46,8 @@
setContext,
} from "svelte";
import { Readable, writable, Writable } from "svelte/store";
import type { Readable, Writable } from "svelte/store";
import { writable } from "svelte/store";
import { forwardEventsBuilder } from "$lib/internal/forwardEventsBuilder";
import { get_current_component } from "svelte/internal";
import type { SupportedAs } from "$lib/internal/elements";

View File

@@ -7,7 +7,8 @@
import type { SupportedAs } from "$lib/internal/elements";
import type { HTMLActionArray } from "$lib/hooks/use-actions";
import Render, { Features } from "$lib/utils/Render.svelte";
import { writable, Writable } from "svelte/store";
import type { Writable } from "svelte/store";
import { writable } from "svelte/store";
const forwardEvents = forwardEventsBuilder(get_current_component());
export let as: SupportedAs = "div";

View File

@@ -1,12 +1,13 @@
<script lang="ts">
import { createEventDispatcher, onMount, setContext } from "svelte";
import { writable, Writable } from "svelte/store";
import type { Writable } from "svelte/store";
import { writable } from "svelte/store";
import { match } from "$lib/utils/match";
import { State, useOpenClosedProvider } from "$lib/internal/open-closed";
import { Reason, transition } from "$lib/utils/transition";
import type { NestingContextValues } from "$lib/components/transitions/common.svelte";
import {
hasChildren,
NestingContextValues,
NESTING_CONTEXT_NAME,
TreeStates,
useNesting,

View File

@@ -1,6 +1,7 @@
<script lang="ts">
import { onMount, setContext } from "svelte";
import { writable, Writable } from "svelte/store";
import type { Writable } from "svelte/store";
import { writable } from "svelte/store";
import { match } from "$lib/utils/match";
import { State, useOpenClosed } from "$lib/internal/open-closed";
import TransitionChild from "$lib/components/transitions/TransitionChild.svelte";
@@ -8,11 +9,13 @@
import { get_current_component } from "svelte/internal";
import type { SupportedAs } from "$lib/internal/elements";
import type { HTMLActionArray } from "$lib/hooks/use-actions";
import type {
NestingContextValues,
TransitionContextValues,
} from "./common.svelte";
import {
hasChildren,
NestingContextValues,
NESTING_CONTEXT_NAME,
TransitionContextValues,
TRANSITION_CONTEXT_NAME,
TreeStates,
useNesting,

View File

@@ -1,6 +1,7 @@
<script lang="ts" context="module">
import { getContext, setContext } from "svelte";
import { writable, Writable } from "svelte/store";
import type { Writable } from "svelte/store";
import { writable } from "svelte/store";
const FORCE_PORTAL_ROOT_CONTEXT_NAME = "headlessui-force-portal-root-context";
export function usePortalRoot(): Writable<boolean> | undefined {

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { ActionArray, useActions } from "$lib/hooks/use-actions";
import type { ActionArray } from "$lib/hooks/use-actions";
import { useActions } from "$lib/hooks/use-actions";
import { get_current_component } from "svelte/internal";
import { forwardEventsBuilder } from "../forwardEventsBuilder";

View File

@@ -1,8 +1,6 @@
<script lang="ts" context="module">
import {
getElementComponent,
SupportedElement,
} from "$lib/internal/elements";
import type { SupportedElement } from "$lib/internal/elements";
import { getElementComponent } from "$lib/internal/elements";
import { get_current_component, SvelteComponent } from "svelte/internal";
export enum Features {

View File

@@ -10,6 +10,7 @@
to enforce using \`import type\` instead of \`import\` for Types.
*/
"importsNotUsedAsValues": "error",
"preserveValueImports": true,
"isolatedModules": true,
"resolveJsonModule": true,
/**