Skip to content

incremental compilation does not handle const enum properlyΒ #57310

@godmiaozi

Description

@godmiaozi

πŸ”Ž 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

Metadata

Metadata

Assignees

Labels

Fix AvailableA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions