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

Compilation omits import aliases for TypeScript #7177

Closed
3axap4eHko opened this issue Mar 30, 2023 · 1 comment · Fixed by #7202
Closed

Compilation omits import aliases for TypeScript #7177

3axap4eHko opened this issue Mar 30, 2023 · 1 comment · Fixed by #7202
Labels
Milestone

Comments

@3axap4eHko
Copy link
Contributor

Describe the bug

swc omits import aliases

import * as NS from './a';

import Alias = NS;
import A = Alias.A;

export { A };

what results in the runtime error

var Alias = NS;
            ^
ReferenceError: NS is not defined

Input code

import * as NS from './a';

import Alias = NS;
import A = Alias.A;

export { A };

Config

{
  "module": {
    "type": "commonjs",
    "strict": true
  },
  "jsc": {
    "target": "es2022",
    "parser": {
      "syntax": "typescript"
    }
  }
}

Playground link

https://play.swc.rs/?version=1.3.43&code=H4sIAAAAAAAAA8vMLcgvKlHQUkgsVvALVkgrys9VUNfTT1S35uXi5cqEyDrmZAKlbYEKrBFiQD5YXM8RrDS1AixcDZSoBQoAAJhh2QdYAAAA&config=H4sIAAAAAAAAA1VPSQ7DIAy88wrkcw8Vx%2F6hj0DUiYjYhB2pKMrfCymkzc2exTPehJSwkIGH3OpYl6QzYT73ilAJrN8VAS4JyWSbGG6DZWrUpB3hAe1fBljnGbm5kNRdqe4AFyPhcHTM22Cn8p9pok8Zia7CJtVhdnhNFD0VfHytB9l%2FaX1bg3rNx7AQ%2FJQj8bwOlp7DznlFsX8AqE9BlhwBAAA%3D

Expected behavior

NS variable should be imported and declared

Actual behavior

NS is not defined

Version

1.3.42

Additional context

@kdy1 please let me know if it is clear

@kdy1 kdy1 added this to the Planned milestone Mar 31, 2023
kdy1 pushed a commit that referenced this issue Sep 25, 2023
**Description:**

## Bugfixes
- Exported `let`/`var` declarations in TypeScript namespaces should be mutable.
- Fix missing declaration of complex exported patterns in TypeScript namespaces.
- Preserve concrete TS namespaces.

## New Features
- Introducing [Verbatim Module Syntax](https://www.typescriptlang.org/tsconfig#verbatimModuleSyntax).
- Enum value will now be inlined whenever possible within a single module, optimizing runtime performance.
- Constant enums will be automatically eliminated when feasible, This can reduce bundle size.
- Added support for cross-referencing enum values.

## Deprecated
`TsEnumConfig` is deprecated
  - The `treat_const_enum_as_enum` transform option is deprecated.
  - The `ts_enum_is_readonly` assumption option is deprecated.

**BREAKING CHANGE:**

TypeScript Config is changed.


**Related issue:**

 - Closes #5197
 - Closes #5259 
 - Closes #7177
 - Closes #7453
 - Closes #7676 
 - Closes #7681
 - Closes #7791 
 - Closes #7961
@kdy1 kdy1 modified the milestones: Planned, v1.3.89 Sep 25, 2023
@swc-bot
Copy link
Collaborator

swc-bot commented Oct 26, 2023

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Oct 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

3 participants