-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add source mappings for serialized properties with available declaration #60005
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
Changes from 5 commits
11ebae9
c5c2fe7
3a84cca
5a8bc8b
aeaede2
4b57ecb
c25efdc
ff71ac9
5dac6a6
c8ab65c
01983e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -985,6 +985,7 @@ import { | |
| setNodeFlags, | ||
| setOriginalNode, | ||
| setParent, | ||
| setSourceMapRange, | ||
| setSyntheticLeadingComments, | ||
| setTextRange as setTextRangeWorker, | ||
| setTextRangePosEnd, | ||
|
|
@@ -7174,8 +7175,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { | |
| context.tracker.reportNonSerializableProperty(symbolToString(propertySymbol)); | ||
| } | ||
| } | ||
| context.enclosingDeclaration = propertySymbol.valueDeclaration || propertySymbol.declarations?.[0] || saveEnclosingDeclaration; | ||
| const propertyDeclaration = propertySymbol.valueDeclaration || propertySymbol.declarations?.[0]; | ||
| context.enclosingDeclaration = propertyDeclaration || saveEnclosingDeclaration; | ||
| const propertyName = getPropertyNameNodeForSymbol(propertySymbol, context); | ||
| if (propertyDeclaration && (isPropertyAssignment(propertyDeclaration) || isShorthandPropertyAssignment(propertyDeclaration) || isMethodDeclaration(propertyDeclaration) || isMethodSignature(propertyDeclaration) || isPropertySignature(propertyDeclaration) || isPropertyDeclaration(propertyDeclaration) || isGetOrSetAccessorDeclaration(propertyDeclaration))) { | ||
| setSourceMapRange(propertyName, propertyDeclaration.name); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still feel at least a little uncomfortable with this; why isn't it declaration emit which can do this? The node builder produces lots of nodes, why doesn't this happen elsewhere?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, can this just be done in (In any case, this PR is safe, since
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
the required information is on the symbol, emit works based on the produced nodes and we need to pass somehow the information that it needs from here as this is the place where this information is being lost. This just leaves a breadcrumb that can be picked up by the emitter
maybe, im not sure sure ;p I'll try to analyze this
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For declaration emit nodes, just use
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using I have moved the fix to
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, it doesn't seem to help. I don't understand why this isn't working: propertyNameNode = setTextRange(context, propertyNameNode, declaration.name);So I would expect the original node stuff to "just work".
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you stick
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (maybe #59675?)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Somewhat offtopic, somewhat not. I've wanted to verify some existing behaviors around this so I put this in the code: diff --git a/src/compiler/factory/emitNode.ts b/src/compiler/factory/emitNode.ts
index beadc29d4c..b4d1e730eb 100644
--- a/src/compiler/factory/emitNode.ts
+++ b/src/compiler/factory/emitNode.ts
@@ -13,6 +13,7 @@ import {
ImportSpecifier,
InternalEmitFlags,
isParseTreeNode,
+ isTypeNodeKind,
Node,
NodeArray,
orderedRemoveItem,
@@ -137,6 +138,9 @@ export function getSourceMapRange(node: Node): SourceMapRange {
* Sets a custom text range to use when emitting source maps.
*/
export function setSourceMapRange<T extends Node>(node: T, range: SourceMapRange | undefined): T {
+ if (range && isTypeNodeKind(node.kind)) {
+ throw new Error("Type nodes cannot have source map ranges.");
+ }
getOrCreateEmitNode(node).sourceMapRange = range;
return node;
}and no existing test has thrown. So it seems that this has never been used on type nodes until now. |
||
| } | ||
| context.enclosingDeclaration = saveEnclosingDeclaration; | ||
| context.approximateLength += symbolName(propertySymbol).length + 1; | ||
|
|
||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.