Skip to content

ICE when compiling a *.d.ts file #10502

@jrop

Description

@jrop

Bug Report

Current Behavior
An exception is thrown when attempting to transform a *.d.ts file here: https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-typescript/src/index.js#L142

TypeError: Cannot read property 'name' of null
  at PluginPass.Program (node_modules/@babel/plugin-transform-typescript/lib/index.js:167:57)
  at newFn (node_modules/@babel/traverse/lib/visitors.js:195:21)
  at NodePath._call (node_modules/@babel/traverse/lib/path/context.js:53:20)
  at NodePath.call (node_modules/@babel/traverse/lib/path/context.js:40:17)
  at NodePath.visit (node_modules/@babel/traverse/lib/path/context.js:88:12)
  at TraversalContext.visitQueue (node_modules/@babel/traverse/lib/context.js:120:16)
  at TraversalContext.visitSingle (node_modules/@babel/traverse/lib/context.js:92:19)
  at TraversalContext.visit (node_modules/@babel/traverse/lib/context.js:148:19)
  at Function.traverse.node (node_modules/@babel/traverse/lib/index.js:96:17)
  at traverse (node_modules/@babel/traverse/lib/index.js:78:12)

Input Code

export default function<T>(x: T): T;

Expected behavior/code

Babel should not process *.d.ts files, or should give a better error.

Babel Configuration (.babelrc, package.json, cli command)

{
  "presets": [["@babel/preset-env", { "targets": { "node": 10 } }], "@babel/preset-typescript"],
  "plugins": ["babel-plugin-macros"]
}

Environment

  • Babel version(s): [e.g. v6.0.0, v7.0.0-beta.34]
  • Node 10 / Yarn 1.17.3
  • OS: MacOS 10.14.6
  • Monorepo: yes: yarn workspace
  • How you are using Babel: cli: ./node_modules/.bin/babel -d lib -x '.ts' src

Possible Solution

When I add this to my config, it works:

{
  ...
  "ignore": ["src/dbg.macro.d.ts"]
}

Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.

Metadata

Metadata

Assignees

No one assigned

    Labels

    i: needs triageoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions