Skip to content

Add isolatedDeclarations quickfix#3304

Draft
jakebailey wants to merge 3 commits intojabaile/fine-grained-idfrom
jabaile/id-fixes-2
Draft

Add isolatedDeclarations quickfix#3304
jakebailey wants to merge 3 commits intojabaile/fine-grained-idfrom
jabaile/id-fixes-2

Conversation

@jakebailey
Copy link
Copy Markdown
Member

Builds on #3303.

Had to port more fourslash generator code, but filtered down to just these fixes.

Comment on lines +787 to +791
propertyName.Parent = parameter.Name().Parent //nolint:customlint // .Parent set to get node to printback using text from original file instead of processed text; TODO: this should be achievable via EmitFlags instead
tx.EmitContext().AddEmitFlags(propertyName, printer.EFNoComments|printer.EFNoSourceMap)

localName := parameter.Name().Clone(tx.Factory())
localName.Parent = parameter.AsNode() //nolint:customlint // .Parent set to get node to printback using text from original file instead of processed text; TODO: this should be achievable via EmitFlags instead
localName.Parent = parameter.Name().Parent //nolint:customlint // .Parent set to get node to printback using text from original file instead of processed text; TODO: this should be achievable via EmitFlags instead
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This turned out to matter after all, which feels gross

ast.KindJsxNamespacedName:
// !!! If `node` is not a parse tree node, verify its original node comes from the same source file
if p.currentSourceFile == nil || node.Parent == nil || ast.NodeIsSynthesized(node) {
if !canUseSourceFile || ast.GetSourceFileOfNode(node) != p.emitContext.MostOriginal(p.currentSourceFile.AsNode()).AsSourceFile() {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This new check fixes some stuff, but re-broke the case with the escaped identifier.

Comment on lines +231 to +242
// For fourslash tests, use seenContentLine to preserve leading blank lines
// (matching TS fourslash's //// content markers). For compiler tests, use
// Len() != 0 which drops leading blanks (matching TS's harness behavior).
if options.AllowImplicitFirstFile {
if seenContentLine {
currentFileContent.WriteRune('\n')
}
seenContentLine = true
} else {
if currentFileContent.Len() != 0 {
currentFileContent.WriteRune('\n')
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I need to pull some of these changes into its own PR, as there are general improvements here that I found when fixing the ID stuff.

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.

1 participant