exportSpecifier builder and probably others are broken in ^0.14.0
- Dominant language
- TypeScript
- Stars
- 1.2k
- Forks
- 194
- Avg merge
- 22h 43m
- Merged PRs (30d)
- 10
Description
I don't fully understand what's supposed to happen when a node type is defined in two places (esprima and es6) but it seems to be causing problems for `exportSpecifier`:
```
> var t = require('ast-types').builders
undefined
> t.exportSpecifier()
Uncaught:
Error: no value or default function given for field "exported" of ExportSpecifier("id": Identifier | null, "name": Identifier | null)
at addParam (/Users/andy/temp/node_modules/ast-types/lib/types.js:443:27)
at /Users/andy/temp/node_modules/ast-types/lib/types.js:477:21
at Array.forEach ()
at Object.builder [as exportSpecifier] (/Users/andy/temp/node_modules/ast-types/lib/types.js:475:46)
> t.exportSpecifier(t.identifier('foo'), t.identifier('bar'))
Uncaught:
Error: no value or default function given for field "exported" of ExportSpecifier("id": Identifier | null, "name": Identifier | null)
at addParam (/Users/andy/temp/node_modules/ast-types/lib/types.js:443:27)
at /Users/andy/temp/node_modules/ast-types/lib/types.js:477:21
at Array.forEach ()
at Object.builder [as exportSpecifier] (/Users/andy/temp/node_modules/ast-types/lib/types.js:475:46)
```
Can't reproduce this issue in 0.13.4.
I noticed that field names `id` and `name` come from the esprima defs, whereas the field name `exported` comes from the es6 defs.
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the two exportSpecifier builder calls and start in lib/types.js at the stack-traced builder logic. Compare the esprima and es6 definitions for ExportSpecifier and determine how their fields are combined; done means both calls work without the missing-field error while preserving the behavior from 0.13.4.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- compilers, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100