Use compiled JS output for line number selection with TypeScript#3414
Closed
danielalanbates wants to merge 1 commit intoavajs:mainfrom
Closed
Use compiled JS output for line number selection with TypeScript#3414danielalanbates wants to merge 1 commit intoavajs:mainfrom
danielalanbates wants to merge 1 commit intoavajs:mainfrom
Conversation
When @ava/typescript is configured, the line number parser now resolves the compiled JavaScript file from the provider state's rewritePaths and parses that instead of the TypeScript source. This fixes line number selection (e.g. `ava test.ts:10`) for TypeScript projects, since acorn cannot parse TypeScript syntax. The source map lookup also uses the compiled file, so call expression positions are correctly translated back to the original TypeScript source lines. Callsite matching now checks both the original source file and the compiled file to handle the runtime execution context. Closes avajs#3064 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Member
|
A few things I think needs to be improved:
|
Author
|
Thank you for your time reviewing this. We're withdrawing this PR. Apologies for any inconvenience. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #3064
When
@ava/typescriptis configured, line number selection (e.g.ava test.ts:10) fails because acorn cannot parse TypeScript syntax. This PR resolves the compiled JavaScript output file using the provider state'srewritePathsand parses that instead.Changes
lib/worker/base.js: AddedresolveCompiledFile()which uses the TypeScript provider state (extensionsandrewritePaths) to map a.ts/.cts/.mtssource file to its compiled.js/.cjs/.mjsoutput. The resolved path is passed tolineNumberSelection().lib/worker/line-numbers.js: Accepts an optionalcompiledFileparameter. When provided:matchesFile()helper to avoid duplication)How it works
resolveCompiledFile()replicates the path rewriting logic from@ava/typescript'sworker.load()— using the samerewritePathsand extension mapping that are already available inproviderStatesCompatibility
@ava/typescript— uses existing provider state datacompiledFileisnulland behavior is unchangedThis PR was created with the assistance of Claude Opus 4.6 by Anthropic. Happy to make any adjustments! Reviewed and submitted by a human.