benjamn / benjamn/ast-types

`b.functionExpression.from(functionDeclaration)` is failing on Windows

Open
#814 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.2k
Forks
194
Avg merge
22h 43m
Merged PRs (30d)
10

Description

When we got this problem in the `remix` repo (https://github.com/remix-run/remix/pull/3987), I reported this in the `jscodeshift` repo (https://github.com/facebook/jscodeshift/issues/520), but since all their builders are coming from `recast` (https://github.com/benjamn/recast/issues/1170), which on themselves are re-exported from `ast-types`, I thought it would be a good idea to also report it in this repo

When we got this problem in the `remix` repo (https://github.com/remix-run/remix/pull/3987), I reported this in the `jscodeshift` repo (https://github.com/facebook/jscodeshift/issues/520), but since all their builders are coming from `recast`, I thought it would be a good idea to also report it in this repo

> For some reason Windows is throwing an error when converting a `FunctionDeclaration` to a `FunctionExpression`, while this is perfectly working (as expected) on Linux.
>
> As @mcansh pointed out in https://github.com/remix-run/remix/pull/3987#issuecomment-1218239753, the origin of this problem is coming from `ast-types`
> https://github.com/benjamn/ast-types/blob/master/lib/types.ts#L656-L658
>
> AST Explorer example (which is failing as well): https://astexplorer.net/#/gist/31f7305e1a29c0565f6efb13709e93a8/latest

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the FunctionDeclaration-to-FunctionExpression conversion using the AST Explorer example and compare Windows with Linux behavior. Inspect lib/types.ts around lines 656-658, then verify that the conversion no longer throws on Windows while retaining the expected result.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.