Description
I'm writing a library and have a crude compile-time test system set up. I run the test and it compiles a bunch of snippets and compares the actual compiled output (declarations and errors) to the expected compiled output.
However, I've noticed that, every once in a while, when adding new features, the compiled output changes like in the above screenshot. The output isn't wrong per se. It's correct but adding a new file shouldn't change the compiled output (in my opinion).
It's just shuffling the elements of the union types in the error messages.
When the output does change, I just accept the change and subsequent compiles match the new output. So, I know the compile output is deterministic. It just seems like adding a new file and not modifying every other file has the possibility of changing the compile output... Of code that doesn't use the new file.
- Code A uses File A
- I add File B, I do not modify Code A or File A
- I compile
- Code A's output changes
I guess my question is "Why is it doing this?"
Below is how I'm compiling the snippets,
const rootNames = getAllTsFiles(inputRoot);
const program = ts.createProgram({
rootNames,
options : compilerOptions,
});
const emitResult = program.emit(
/*snip*/
);
const allDiagnostics = ts
.getPreEmitDiagnostics(program)
.concat(emitResult.diagnostics);
Activity
weswigham commentedon Dec 25, 2018
The order or types in members is determined by those types IDs. Type IDs are assigned on a first-checked basis. So adding a file can cause they type to be checked sooner and thus it's order in a union change.
AnyhowStep commentedon Dec 25, 2018
Ah. That makes sense to me. Thanks for the response!
Merry Christmas!
x
andy
types getting switched after updating #29255Blasz commentedon Sep 2, 2019
Relates to #17944
AnyhowStep commentedon Sep 2, 2019
#32224