GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||
GeezerVison is showing github.com — [ID-Prep] PR1 - Simplify declaration emit for literal types. by dragomirtitian · Pull Request #57444 · microsoft/TypeScript Conversation
|
| ? getWidenedLiteralType(getTypeOfSymbol(symbol)) | ||
| ? getTypeOfSymbol(symbol) | ||
| : errorType; | ||
| if(!isReadonlySymbol(symbol)) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The lack of this test is the reason for #57441
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
a937132 to
7fd08c4
Compare
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This introduces bugs in incremental compilation - by not preserving the widening behavior of the literals (wherever possible), by creating an initializer whenever the type at the location is a widening type, you can create declaration files where, when you check against the declaration files, you witness the literal type, while when you check against the source file, you witness the widening type (and thus, the base type). We have open issues about other types where we don't correctly do this today (eg, for tagged templates), and this would make the problem hugely worse.
This cannot be a baseline change in the compiler. This absolutely has to be flagged off, if we take it at all. There is a meaningful difference between a = 1 and : 1 on a variable declaration - that some emit mode can't track the widening behavior of literals across declarations does not mean we should introduce buggy behavior for all users.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
3ee926e to
a6c7559
Compare
|
Wesley Wigham (@weswigham) Sorry it took a while to get back to this. I changed the goal to just preserve the initializer node if possible. This should not change the meaning of the declaration. It should also be a safe change to make. Even older versions of TypeScript will understand all of the primitive literal syntax, even if it was previously not present in declarations. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
14c1e62 to
da5b104
Compare
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
[ID-Prep] Preserve constant initializer in declarations as written in source
There was an error while loading. Please reload this page.