Skip to content

Bug: library .d.ts files should not import its .ts files - this can cause compilation errors in user projects #397

@azerum

Description

@azerum

Overivew

When library .d.ts files import .ts files, those .ts files are included in the compilation step of the user projects. For example, since index.d.ts imports toolProperties.ts here, toolProperties.ts will be compiles as part of the user project

This is problematic since file may not compile under tsconfig.json settings of the user

For example, this library is targets CJS, but uses ESM syntax (export). If users use verbatimModuleSyntax: true - which requires that CJS files use CJS syntax - their compilation will fail, with no easy fix

Similarly, if users if users use any strict* option this project doesn't, toolProperties.ts may not compile

Effectively, toolProperties.ts of this library limits what tsconfig.json settings users can use

Expected behavior

Library's .d.ts files may import only other .d.ts files, but not .ts files

Actual behavior

index.d.ts imports toolProperties.ts here

Example user project that fails to compile due to this: https://github.com/azerum/azure-functions-type-check-bug

Suggested fix

Generate .d.ts file for toolProperties.ts and export that. I am not familiar with why .d.ts files of this library are written manually and not generated from .ts files, I assume there must be a good reason..

Metadata

Metadata

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