Skip to content

Conversation

ankddev
Copy link
Contributor

@ankddev ankddev commented Aug 14, 2025

Closes #2003

Description

Add integration test for TS type declarations. It compiles project and then runs tsc with --noEmit flag, so it won't generate JS files.

Copy link
Member

@lpil lpil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I've left a bunch of comments inline

When you are ready for a review please un-draft this PR and tag me for a review. Thank you!

.PHONY: build
test:
cargo run --quiet -- build
tsc ./build/dev/javascript/typescript_declarations/typescript_declarations.d.mts --noEmit --lib es2015
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we write this in a way where they don't need to install tsc globally? Perhaps deno can be used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to use it and it seems that tsc and deno process files in different way so this doesn't work, sadly.

$ deno check ./main.ts
Check file:///data/data/com.termux/files/home/gleam/test/typescript_declarations/main.ts
TS2308 [ERROR]: Module "../prelude.mjs" has already exported a member named 'BitArray'. Consider explicitly re-exporting to resolve the ambiguity.
export type * from "../prelude.d.mts";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at file:///data/data/com.termux/files/home/gleam/test/typescript_declarations/build/dev/javascript/typescript_declarations/gleam.d.mts:2:1

TS2308 [ERROR]: Module "../prelude.mjs" has already exported a member named 'CustomType'. Consider explicitly re-exporting to resolve the ambiguity.
export type * from "../prelude.d.mts";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at file:///data/data/com.termux/files/home/gleam/test/typescript_declarations/build/dev/javascript/typescript_declarations/gleam.d.mts:2:1

TS2308 [ERROR]: Module "../prelude.mjs" has already exported a member named 'Empty'. Consider explicitly re-exporting to resolve the ambiguity.
export type * from "../prelude.d.mts";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at file:///data/data/com.termux/files/home/gleam/test/typescript_declarations/build/dev/javascript/typescript_declarations/gleam.d.mts:2:1

TS2308 [ERROR]: Module "../prelude.mjs" has already exported a member named 'Error'. Consider explicitly re-exporting to resolve the ambiguity.
export type * from "../prelude.d.mts";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at file:///data/data/com.termux/files/home/gleam/test/typescript_declarations/build/dev/javascript/typescript_declarations/gleam.d.mts:2:1

TS2308 [ERROR]: Module "../prelude.mjs" has already exported a member named 'List'. Consider explicitly re-exporting to resolve the ambiguity.
export type * from "../prelude.d.mts";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at file:///data/data/com.termux/files/home/gleam/test/typescript_declarations/build/dev/javascript/typescript_declarations/gleam.d.mts:2:1

TS2308 [ERROR]: Module "../prelude.mjs" has already exported a member named 'NonEmpty'. Consider explicitly re-exporting to resolve the ambiguity.
export type * from "../prelude.d.mts";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at file:///data/data/com.termux/files/home/gleam/test/typescript_declarations/build/dev/javascript/typescript_declarations/gleam.d.mts:2:1

TS2308 [ERROR]: Module "../prelude.mjs" has already exported a member named 'Ok'. Consider explicitly re-exporting to resolve the ambiguity.
export type * from "../prelude.d.mts";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at file:///data/data/com.termux/files/home/gleam/test/typescript_declarations/build/dev/javascript/typescript_declarations/gleam.d.mts:2:1

TS2308 [ERROR]: Module "../prelude.mjs" has already exported a member named 'Result'. Consider explicitly re-exporting to resolve the ambiguity.
export type * from "../prelude.d.mts";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at file:///data/data/com.termux/files/home/gleam/test/typescript_declarations/build/dev/javascript/typescript_declarations/gleam.d.mts:2:1

TS2308 [ERROR]: Module "../prelude.mjs" has already exported a member named 'UtfCodepoint'. Consider explicitly re-exporting to resolve the ambiguity.
export type * from "../prelude.d.mts";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at file:///data/data/com.termux/files/home/gleam/test/typescript_declarations/build/dev/javascript/typescript_declarations/gleam.d.mts:2:1

TS2308 [ERROR]: Module "../prelude.mjs" has already exported a member named 'codepointBits'. Consider explicitly re-exporting to resolve the ambiguity.
export type * from "../prelude.d.mts";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at file:///data/data/com.termux/files/home/gleam/test/typescript_declarations/build/dev/javascript/typescript_declarations/gleam.d.mts:2:1

TS2308 [ERROR]: Module "../prelude.mjs" has already exported a member named 'divideFloat'. Consider explicitly re-exporting to resolve the ambiguity.
export type * from "../prelude.d.mts";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at file:///data/data/com.termux/files/home/gleam/test/typescript_declarations/build/dev/javascript/typescript_declarations/gleam.d.mts:2:1

TS2308 [ERROR]: Module "../prelude.mjs" has already exported a member named 'divideInt'. Consider explicitly re-exporting to resolve the ambiguity.
export type * from "../prelude.d.mts";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at file:///data/data/com.termux/files/home/gleam/test/typescript_declarations/build/dev/javascript/typescript_declarations/gleam.d.mts:2:1

TS2308 [ERROR]: Module "../prelude.mjs" has already exported a member named 'isEqual'. Consider explicitly re-exporting to resolve the ambiguity.
export type * from "../prelude.d.mts";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at file:///data/data/com.termux/files/home/gleam/test/typescript_declarations/build/dev/javascript/typescript_declarations/gleam.d.mts:2:1

TS2308 [ERROR]: Module "../prelude.mjs" has already exported a member named 'prepend'. Consider explicitly re-exporting to resolve the ambiguity.
export type * from "../prelude.d.mts";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at file:///data/data/com.termux/files/home/gleam/test/typescript_declarations/build/dev/javascript/typescript_declarations/gleam.d.mts:2:1

TS2308 [ERROR]: Module "../prelude.mjs" has already exported a member named 'remainderInt'. Consider explicitly re-exporting to resolve the ambiguity.
export type * from "../prelude.d.mts";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at file:///data/data/com.termux/files/home/gleam/test/typescript_declarations/build/dev/javascript/typescript_declarations/gleam.d.mts:2:1

TS2308 [ERROR]: Module "../prelude.mjs" has already exported a member named 'sizedFloat'. Consider explicitly re-exporting to resolve the ambiguity.
export type * from "../prelude.d.mts";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at file:///data/data/com.termux/files/home/gleam/test/typescript_declarations/build/dev/javascript/typescript_declarations/gleam.d.mts:2:1

TS2308 [ERROR]: Module "../prelude.mjs" has already exported a member named 'sizedInt'. Consider explicitly re-exporting to resolve the ambiguity.
export type * from "../prelude.d.mts";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at file:///data/data/com.termux/files/home/gleam/test/typescript_declarations/build/dev/javascript/typescript_declarations/gleam.d.mts:2:1

TS2308 [ERROR]: Module "../prelude.mjs" has already exported a member named 'stringBits'. Consider explicitly re-exporting to resolve the ambiguity.
export type * from "../prelude.d.mts";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at file:///data/data/com.termux/files/home/gleam/test/typescript_declarations/build/dev/javascript/typescript_declarations/gleam.d.mts:2:1

TS2308 [ERROR]: Module "../prelude.mjs" has already exported a member named 'toBitArray'. Consider explicitly re-exporting to resolve the ambiguity.
export type * from "../prelude.d.mts";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at file:///data/data/com.termux/files/home/gleam/test/typescript_declarations/build/dev/javascript/typescript_declarations/gleam.d.mts:2:1

TS2308 [ERROR]: Module "../prelude.mjs" has already exported a member named 'toList'. Consider explicitly re-exporting to resolve the ambiguity.
export type * from "../prelude.d.mts";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at file:///data/data/com.termux/files/home/gleam/test/typescript_declarations/build/dev/javascript/typescript_declarations/gleam.d.mts:2:1

Found 20 errors.

error: Type checking failed.

@lpil lpil marked this pull request as draft August 17, 2025 10:14
@ankddev ankddev marked this pull request as ready for review August 18, 2025 08:34
@ankddev
Copy link
Contributor Author

ankddev commented Aug 18, 2025

@lpil I fixed all things you mentioned. Niw test includes more code and there is TS file which imports generated code and type-checking works.

One thing that I don't know what to do with is tsc requirement. I tried to use Deno and found following:

  • When using deno run it seems not to perform type checking
  • When using deno check it performs analyzis in different way than tsc and gives many errors (see review comment above)
    So, I don't know what we should do.

@ankddev ankddev requested a review from lpil August 18, 2025 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add integration test for typescript type definitions (d.ts)
3 participants