tsconfig's verbatimModuleSyntax preserves type imports · Issue #1623 · TypeScriptToLua/TypeScriptToLua · GitHub
Skip to content

tsconfig's verbatimModuleSyntax preserves type imports #1623

Open

Description

@lineargraph

With verbatimModuleSyntax set in tsconfig.json imports like:

import { type Side } from "SideTypes";

get preserved into

local ____SideTypes = require("SideTypes")
local Side = ____SideTypes.Side

The SideTypes module is declared like so:

/** @noSelfInFile **/

/** @noResolution */
declare module "SideTypes" {
  export type DefaultSideNames = ['bottom', 'top', 'back', 'front', 'right', 'left'];
  export type Side = (typeof import("sides"))[DefaultSideNames[number]]
}

/** @noResolution **/
declare module "sides" {
  import { type DefaultSideNames } from "SideTypes";
  const table: DefaultSideNames & {
    down: 0,
    negy: 0,
    bottom: 0,

    up: 1,
    posy: 1,
    top: 1,

    north: 2,
    negz: 2,
    back: 2,

    south: 3,
    posz: 3,
    forward: 3,
    front: 3,

    west: 4,
    negx: 4,
    right: 4,

    east: 5,
    posx: 5,
    left: 5,
  };

  export = table;
}

If i unset verbatimModuleSyntax to false, that import gets omitted, like expected.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions