Skip to content

Invalid identifiers generated when importing files with leading numbers #4354

Description

@DavidSouther

Targeting commonjs, when importing files with leading numbers in their names results in invalid js emitted.

Given these inputs:

10_lib.ts

export function Foo(){};

main.ts

import { Foo } from './10_lib';

Foo();

Compiling with

$ tsc --modules commonjs main.ts

Generates

main.js

var 10_lib_1 = require('./10_lib');
10_lib_1.Foo();

Which is invalid, and when run errors with:

$ node main.js
.../main.js:1
(function (exports, require, module, __filename, __dirname) { var 10_lib_1 = r
                                                                  ^^
SyntaxError: Unexpected token ILLEGAL

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issueHelp WantedYou can do this

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions