TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

incremental compilation does not handle const enum properly

Open godmiaozi opened this issue 1 year ago • 4 comments

🔎 Search Terms

incremental const enum

🕗 Version & Regression Information

4.9.5

⏯ Playground Link

No response

💻 Code

step1, assume we have the following code a.ts

import {A} from "./c"
let a = A.ONE

b.d.ts

export const enum A {
         ONE = 1
 }

c.ts

import {A} from "./b"
let b = A.ONE
export {A}

cmdline

tsc --incremental a.ts --tsBuildInfoFile ./buildFile

output a.js

"use strict";
exports.__esModule = true;
var a = 1 /* A.ONE */;

c.js

"use strict";
exports.__esModule = true;
var b = 1 /* A.ONE */;

step2, then modify b.d.ts

export const enum A {
         ONE = 2
 }

run cmdline

tsc --incremental a.ts --tsBuildInfoFile ./buildFile

step3, modify b.d.ts again

export const enum A {
         ONE = 3
 }

run cmdline

tsc --incremental a.ts --tsBuildInfoFile ./buildFile

the output is not correct output: a.js

"use strict";                                                                              
exports.__esModule = true;  
var a = 2 /* A.ONE */;

c.js

"use strict";
exports.__esModule = true;
var b = 3 /* A.ONE */

🙁 Actual behavior

output of step3 a.js

"use strict";                                                                              
exports.__esModule = true;  
var a = 2 /* A.ONE */;

c.js

"use strict";
exports.__esModule = true;
var b = 3 /* A.ONE */

🙂 Expected behavior

output of step3 a.js

"use strict";                                                                              
exports.__esModule = true;  
var a = 3 /* A.ONE */;

c.js

"use strict";
exports.__esModule = true;
var b = 3 /* A.ONE */

Additional information about the issue

No response

godmiaozi avatar Feb 06 '24 16:02 godmiaozi

TypeScript 4.9 is 18 months old - can you please try on latest?

RyanCavanaugh avatar Feb 06 '24 18:02 RyanCavanaugh

Based on the latest (86a16636cac9599c8752f8588f4b9518860b47ff) of master branch, it still has the same issue

zhuoli72 avatar Feb 18 '24 01:02 zhuoli72

Based on the latest (86a1663) of master branch, it still has the same issue

@RyanCavanaugh please take a look thanks

godmiaozi avatar Feb 18 '24 02:02 godmiaozi

any update? @RyanCavanaugh @sheetalkamat

godmiaozi avatar Mar 22 '24 08:03 godmiaozi