Skip to content

Visual Studio Community 2013, Typescrip 1.4: When saving file, const enum doesn't resolve to constant when enum is defined in other file. #1742

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

Closed
mpawelski opened this issue Jan 20, 2015 · 8 comments · Fixed by #1788
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@mpawelski
Copy link

Hi,
I installed Visual Studio Community 2013 and Typescript 1.4. When I changed all my enums to const enum (btw, very nice feature, thanks!) I noticed that compile-on-save feature doesn't handle this feature well.

When I use those const enums in other file than the one it was defined in then when I save file, they are not resolved to constant numbers.

For example I have file firstFile.ts:

const enum TestEnum {
    Foo, Bar
}

var testFirstFile = TestEnum.Bar;

and when I save file (by pressing Ctrl+S) i get file firstFile.js:

var testFirstFile = 1 /* Bar */;
//# sourceMappingURL=firstFile.js.map

but When i have secondFile.ts file:

/// <reference path="firstfile.ts" />

var testInOtherFile = TestEnum.Bar;

and save file I get secondFile.js:

/// <reference path="firstfile.ts" />
var testInOtherFile = TestEnum.Bar;
//# sourceMappingURL=secondFile.js.map

only when I build project in Visual Studio I get proper secondFile.js file:

/// <reference path="firstfile.ts" />
var testInOtherFile = 1 /* Bar */;
//# sourceMappingURL=secondFile.js.map
@mhegazy mhegazy added Bug A bug in TypeScript Duplicate An existing issue was already created labels Jan 20, 2015
@mhegazy
Copy link
Contributor

mhegazy commented Jan 20, 2015

this looks like a duplicate of #1599

@mhegazy mhegazy closed this as completed Jan 20, 2015
@mhegazy
Copy link
Contributor

mhegazy commented Jan 20, 2015

looking at it again, this does not look the same. issue #1599, would cause this scenario:
change firstfile.ts to update values of the enum
save it, the values are updated correctly in firstfile.ts but not in secondfile.ts. is that what you are seeing, i am not seeing the same behavior you mention above locally?

@mhegazy mhegazy reopened this Jan 20, 2015
@danquirk danquirk removed the Duplicate An existing issue was already created label Jan 20, 2015
@mpawelski
Copy link
Author

I got this problem at work. I installed the newest Visual Studio Community 2013 and Typescript 1.4.

I have the same problem at home. Here I recorder video that demonstrate it (a little too long, sorry).
https://www.dropbox.com/s/4jbt41d1h1td0f0/typescript_const_enum_problem.mp4

@mhegazy
Copy link
Contributor

mhegazy commented Jan 20, 2015

yup that is different from #1599. looking more into it.

@vytautas-pranskunas-
Copy link

I have same problem. I see it is fixed already. Do you know when this will be available publicly and with what version. It is very important bug.

@DanielRosenwasser
Copy link
Member

@vytautas-pranskunas- it should be in for 1.5.

Also, 1.5-alpha is out now on npm if you're interested.

@vytautas-pranskunas-
Copy link

Should i replace only typescriptServices.js?
When oficial 1.5 release is planned?

@vytautas-pranskunas-
Copy link

btw: i have replaced typescriptServices.js file and now on save it does not generate any file and console sys: "Input file contained syntax errors. Output generation skipped."

I do not have any errors and on build everything works fine.

@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants