-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
Fix AvailableA PR has been opened for this issueA PR has been opened for this issue
Description
Bug Report
@zepumph and I observed incorrect behavior from tsc when incremental was set to true. A similar behavior was also discussed in #42769. It seems like the tsbuildinfo is stale.
🔎 Search Terms
incremental, stale, tsbuildinfo
🕗 Version & Regression Information
- This is the behavior in 4.6.3 and 4.7.3
💻 Code
// ###################### js/MessageablePerson.ts ##############
const Messageable = () => {
return class MessageableClass {
public message = 'hello';
}
};
const wrapper = () => Messageable();
type MessageablePerson = InstanceType<ReturnType<typeof wrapper>>;
export default MessageablePerson;
// ###################### js/main.ts ##############
import MessageablePerson from './MessageablePerson.js';
function logMessage( person: MessageablePerson ) {
console.log( person.message );
}
// ###################### ./tsconfig.json ##############
{
"compilerOptions": {
"incremental": true,
"target": "ES2020",
"module": "ES2020",
"declaration": false,
"outDir": "./outDir",
"composite": false,
"noEmit": true
},
"include": [
"js/**/*"
]
}🙁 Actual behavior
- Set up the 3 files described above, note the relative paths
- Run
tsc. Observe that type checking passes, as expected - Change
public message = 'hello';toprotected message = 'hello';and runtsc. Observe that type checking fails, as expected. The error message isjs/main.ts:5:23 - error TS2445: Property 'message' is protected and only accessible within class 'MessageableClass' and its subclasses. - Change
protected message = 'hello';back topublic message = 'hello';and runtsc. Observe that type checking fails when it should have succeeded. Same error message as in prior step. - Change
"incremental": true,to"incremental": false,in the tsconfig file and runtsc. Observe that type checking succeeds as expected.
🙂 Expected behavior
- In Step 4, we would have expected no type errors, since
messageispublic. However,tscreports a type error. - In Step 5, we would expect no change in behavior whether
incrementalis set totrueorfalse. - Note that we experimented with combining main into the MessageablePerson file and could not exhibit the bug in that way
- Note also that the bug appears in both ways: (a) reporting an error when there isn't one and (b) reporting that there is no error when there really is an error.
michal-minich and ganor38
Metadata
Metadata
Assignees
Labels
Fix AvailableA PR has been opened for this issueA PR has been opened for this issue