Skip to content

TypeScript: missing error on empty typeArguments and typeParameters #9462

@armano2

Description

@armano2

Bug Report

Current Behavior
Babel does not report error on empty typeParameters and typeArguments

Input Code

const foo: Foo<>
function f1<>() {}

Expected behavior/code
babel should throw errors:

Type parameter list cannot be empty.
Type argument list cannot be empty.

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

  const babel = require('@babel/parser');
  const plugins: ParserPlugin[] = [
    'typescript',
    'objectRestSpread',
    'decorators-legacy',
    'classProperties',
    'asyncGenerators',
    'dynamicImport',
    'estree',
    'bigInt',
    'importMeta'
  ];
  if (jsx) {
    plugins.push('jsx');
  }

  return babel.parse(text, {
    sourceType: 'unambiguous',
    allowImportExportEverywhere: true,
    allowReturnOutsideFunction: true,
    ranges: true,
    plugins
  });

Environment

  • Babel version(s): 7.3.2
  • Node/npm version: 6-11
  • OS: ----
  • Monorepo: ---
  • How you are using Babel: @babel/parser -> parse

Metadata

Metadata

Assignees

Labels

area: typescriptoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issuepkg: parser

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions