-
Notifications
You must be signed in to change notification settings - Fork 8
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
[Feature]: Replace TSTypeReference inside NewExpression #657
Labels
Comments
This happens as jscodeshift does nor detect TSQualifiedName inside NewExpression, like the following: const arr = new Array<AWS.CloudFormation.StackResourceSummary>(); But it detects TSQualifiedName in types as follows: const arr: AWS.CloudFormation.StackResourceSummary = new Array(); |
This appears to be a bug in JSCodeShift, as the following log clearly shows there's a TSQualifiedName for example input. Log: console.log(source.find(j.NewExpression).nodes()[0].typeParameters.params[0].typeName.left); Output: Node {
type: 'TSQualifiedName',
start: 50,
end: 68,
loc: SourceLocation {
start: Position { line: 3, column: 22, index: 50, token: 11 },
end: Position { line: 3, column: 40, index: 68, token: 14 },
filename: undefined,
identifierName: undefined,
lines: Lines {
infos: [Array],
mappings: [],
cachedSourceMap: null,
cachedTabWidth: 2,
length: 3,
name: null
},
tokens: [
[Token], [Token], [Token],
[Token], [Token], [Token],
[Token], [Token], [Token],
[Token], [Token], [Token],
[Token], [Token], [Token],
[Token], [Token], [Token],
[Token], [Token], [Token]
],
indent: 0
},
left: Node {
type: 'Identifier',
start: 50,
end: 53,
loc: SourceLocation {
start: [Position],
end: [Position],
filename: undefined,
identifierName: 'AWS',
lines: [Lines],
tokens: [Array],
indent: 0
},
name: 'AWS'
},
right: Node {
type: 'Identifier',
start: 54,
end: 68,
loc: SourceLocation {
start: [Position],
end: [Position],
filename: undefined,
identifierName: 'CloudFormation',
lines: [Lines],
tokens: [Array],
indent: 0
},
name: 'CloudFormation'
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Self-service
Problem
Codemod does not transform TSTypeReference inside NewExpression
Example input:
Returned output:
Solution
Replace TSTypeReference inside NewExpression
Alternatives
N/A
Additional context
No response
The text was updated successfully, but these errors were encountered: