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

Enum literals not inserted using Compile on Save, but works with project build. #1916

Closed
mrcrowl opened this issue Feb 3, 2015 · 8 comments
Labels
Bug A bug in TypeScript Duplicate An existing issue was already created

Comments

@mrcrowl
Copy link

mrcrowl commented Feb 3, 2015

Since TypeScript 1.4, using the Compile on Save feature, enum members are not being replaced with their literal values in the output js file.

The same operation via a full project build inserts the literal value as expected. This occurs for both regular and const enums.

In the linked example project, there is an enum file "Animals.ts" which is being AMD-imported into the class file "Farm.ts". If you make a minor edit to the Farm.ts file (e.g. insert a space and save), then line 4 of Farm.js shows:

            this.animals = [Animals.Chicken, Animals.Cow, Animals.Sheep];

Whereas, if you do a project build, the line 4 of Farm.js shows the expected output:

            this.animals = [3 /* Chicken */, 0 /* Cow */, 1 /* Sheep */];

Example project: https://www.dropbox.com/s/xc34f0q6rhc0amm/ExampleProject.zip?dl=0

I can confirm that this is happening in both VS2013 + TS1.4 and VS2015 CTP.

@vladima
Copy link
Contributor

vladima commented Feb 3, 2015

looks like a duplicate of #1742, can you try to build the latest bits from the master and check if this issue can still be reproduced?

@mrcrowl
Copy link
Author

mrcrowl commented Feb 3, 2015

@vladima Yeah sorry, I found the other issues after I had posted.

I've built from the master and substituted in the resulting typescriptServices.js, but then I get this error when I try and open any ts file in VS2013:

API version mismatch: managed version '0.4', script version '0.5'

@vladima
Copy link
Contributor

vladima commented Feb 3, 2015

You can try to rollback to the revision prior to this commit (394d6f4) that has bumped the version - it should already contain the fix of the enum issue

@mrcrowl
Copy link
Author

mrcrowl commented Feb 4, 2015

Thanks @vladima. For anyone else wanting the correct typescriptServices.js file (pre-compiled), you can find it here: https://dl.dropboxusercontent.com/u/14232632/typescriptServices.js

@vladima
Copy link
Contributor

vladima commented Feb 4, 2015

@mrcrowl do you still see the issue with updated typescriptServices.js ?

@NoelAbrahams
Copy link

@vladima, the issue appears to have been fixed in the updated typeScriptServices.js

@vladima
Copy link
Contributor

vladima commented Feb 4, 2015

great to hear that!

@vladima vladima closed this as completed Feb 4, 2015
@vladima vladima added Bug A bug in TypeScript Duplicate An existing issue was already created labels Feb 4, 2015
@mrcrowl
Copy link
Author

mrcrowl commented Feb 5, 2015

@vladima Yes, this was fixed for me by using 26929ee.

@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 Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants