Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TSC in isolated declaration will still use the type checker to print types #129

Merged

Conversation

dragomirtitian
Copy link

This revealed some differences between TSC and DTE type printing.

Signed-off-by: Titian Cernicova-Dragomir <tcernicovad1@bloomberg.net>
Signed-off-by: Titian Cernicova-Dragomir <tcernicovad1@bloomberg.net>
Signed-off-by: Titian Cernicova-Dragomir <tcernicovad1@bloomberg.net>
@dragomirtitian dragomirtitian force-pushed the isolated-declarations-use-tsc-resolver branch from 3da49c4 to fb08ff8 Compare December 4, 2023 11:18
currentExportsSymbolTable = exports;
if (isBlockScopedContainerTopLevel(scope)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain a bit what the effect of this and related code separating a function local table? I don't think I fully understand the flow of what changed here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially we didn't go into blocks however I recently found that TS will add expando members from nested blocks. Ex:

function Foo() {}

if(Math.random()) { Foo.test = 1; }
{ Foo. bar =2; }

This means that we now do care about variables defined in blocks and the fact that they are only scoped to that block since that means any member accesses in that block will not add expando members to any variable that is shadowed in that scope:

function Foo() {}

if(Math.random()) { Foo.test = 1; }
{ let Foo: any = {}; Foo. bar =2; } // bar not on Foo

Playground Link

(TS also handled this incorrectly until recently: microsoft#56538)

Signed-off-by: Titian Cernicova-Dragomir <tcernicovad1@bloomberg.net>
Signed-off-by: Titian Cernicova-Dragomir <tcernicovad1@bloomberg.net>
@dragomirtitian dragomirtitian force-pushed the isolated-declarations-use-tsc-resolver branch from bb439ac to 2c0bf81 Compare December 5, 2023 10:09
@dragomirtitian dragomirtitian merged commit d91c282 into isolated-declarations Dec 5, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants