Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with typescript namespace #268

Closed
1 task
ynifamily3 opened this issue Aug 4, 2022 · 3 comments
Closed
1 task

Issue with typescript namespace #268

ynifamily3 opened this issue Aug 4, 2022 · 3 comments
Labels
bug Something isn't working pending triage

Comments

@ynifamily3
Copy link

ynifamily3 commented Aug 4, 2022

Bug description

Here's an example you can reproduce.
https://github.com/ynifamily3/esbuild-loader-issue

index.ts

import { NS } from "./types";
import B = NS.A;

function x(a: B) {
  console.log(a.message);
}

x({ message: "Hello" });

types.ts

export namespace NS {
  export interface A {
    message: string;
  }
}

When trying to bundle, I see an error.
TypeError: Cannot read properties of undefined (reading 'A')

Reproduction

Clone this this repo
Run npm i
Run npm run build # using ts-loader
Run npm run start
You should see a working node app.
Run npm run build:esbuild # using esbuild-loader
Run npm run start
You should see an error.

Node.js package manager

npm

Environment

System:
    OS: Windows 10 10.0.19042
    CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11700 @ 2.50GHz
    Memory: 16.01 GB / 31.86 GB
  Binaries:
    Node: 16.13.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.17 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 8.1.4 - C:\Program Files\nodejs\npm.CMD
  npmPackages:
    esbuild-loader: ^2.19.0 => 2.19.0
    webpack: ^5.74.0 => 5.74.0

Can you contribute a fix?

  • I’m interested in opening a pull request for this issue.
@ynifamily3 ynifamily3 added bug Something isn't working pending triage labels Aug 4, 2022
@privatenumber
Copy link
Owner

Can you use:

import type { NS } from "./types";

@ynifamily3
Copy link
Author

@privatenumber A ts(1380) error occurs. :(

@privatenumber
Copy link
Owner

I think this is the same issue as privatenumber/tsx#83

It's an esbuild issue so I'm closing this and redirecting conversation here:
evanw/esbuild#2468

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pending triage
Projects
None yet
Development

No branches or pull requests

2 participants