-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Imported const enum is not inlined in generated code #16671
Comments
@Kovensky, I cannot seem to reproduce this behavior in |
It still happens with It looks like |
Unfortunately |
If that’s the case, then perhaps it should be an error to |
in my
I use it like this in my component code (angular4):
Everything compiles but I get runtime errors since there is no LMListType. In-lining would fix this for me I think. I could move my d.ts file to a regular ts file but then I have to import all of it's interfaces in each component that uses them. I'd like to avoid that. What is suggested for this issue? |
I've also encountered this problem when Typescript version: 2.6.1 |
so I do not think you can mix these two concepts, |
Which is why I now think that |
yes. it should be an error under |
@mhegazy What about under |
Not sure what you mean, but asserting that the code is safe to transpile one file at a time is what |
When |
Either that, or they should not be allowed to be |
Having this issue now with the vue cli. I don't know why but it was working before.. The correct settings are to turn the ts-loader //vue cli plugin typescript webpack config
addLoader({
loader: "ts-loader",
options: {
transpileOnly: false,
appendTsSuffixTo: ["\\.vue$"],
// https://github.com/TypeStrong/ts-loader#happypackmode-boolean-defaultfalse
happyPackMode: useThreads
}
});
//exporting a const enum that aren't being inlined
export const Directions {
UP
} Alright, seems like mode has to be set to production. Guess I'll try to look into what happens in development later. |
Version 3.8.0-dev.20200130 index.js "use strict";
//import { Enum01 } from './temp';
//
//export const aa = {
// a01: Enum01.A,
//}
exports.__esModule = true;
exports.bb = {
a02: temp_1.Enum02.A
};
{
"compilerOptions": {
"target": "ESNext",
"module": "CommonJS",
"isolatedModules": true
}
} temp.ts //export enum Enum01 {
// A
//}
export const enum Enum02 {
A
} index.ts //import { Enum01 } from './temp';
//
//export const aa = {
// a01: Enum01.A,
//}
import { Enum02 } from './temp';
export const bb = {
a02: Enum02.A
} |
Hi, what's the status of this issue? Can it be considered resolved in v3.x ? |
@funder7 No, it hasn't been resolved. I encountered this bug with TypeScript 4.0.2. For me, it caused |
Is this still a bug? When using export var Foo;
(function (Foo) {
Foo["Bar"] = "bar";
})(Foo || (Foo = {})); so it's available at runtime. |
Maybe related: local const enum N {zero, one}
import X = N;
const v0 = X.zero; // OK
import EINS = N.one; // either TS should complain here or compile it as expected Compiles to: "use strict";
const v0 = 0 /* zero */; // OK
var EINS = N.one; // ERROR |
@jestarray when |
I think this issue can be marked fixed (since #40499):
|
It seems like we’re in a better place now with additional errors and |
TypeScript Version: 2.4.0
Code
Expected behavior:
Foo.Bar
to be replaced with'bar'
Actual behavior:
The import is deleted and
Foo.Bar
is left as isThe text was updated successfully, but these errors were encountered: