Skip to content

Narrow type for config.kit.typescript.config #13572

Open
@hyunbinseo

Description

@hyunbinseo

Describe the problem

Current type: https://svelte.dev/docs/kit/configuration#typescript

config?: (config: Record<string, any>) => Record<string, any> | void;

Describe the proposed solution

Since the config param is generated by SvelteKit, it can be narrowed like this:

import type { CompilerOptions } from 'typescript';

type Config = {
  compilerOptions: CompilerOptions;
  include: string[];
  exclude: string[];
};

Alternatives considered

This does not work:

/**
 * @typedef {import('typescript').CompilerOptions} CompilerOptions
 * @typedef {Object} Config
 * @property {CompilerOptions} compilerOptions
 * @property {string[]} include
 * @property {string[]} exclude
 * @param {Config} config
 */v

Type 'Record<string, any>' is missing the following properties from type 'Config': compilerOptions, include, exclude ts(2322)

Importance

nice to have

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions