Skip to content

tsconfig's verbatimModuleSyntax preserves type imports #1623

Open
@nea89o

Description

@nea89o

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.

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