nomaed / dts-builder

Builds a single d.ts file library from generated d.ts sources
MIT License
12 stars 4 forks source link

Using the word 'import' in code or comment causes error #7

Closed steveschmitt closed 6 years ago

steveschmitt commented 6 years ago

The optimizeImports function is too sensitive to the word "import" in function.ts, line 101. If the code contains

...
    /** name of the import */
    import : string;
...

Then it throws "optimizeImports() could not deal with the following..."

I hacked my local copy to just do console.warn instead of throwing an error. Maybe that's acceptable, unless you have a more robust approach.

P.S. Thanks for this tool.

nomaed commented 6 years ago

I'm gad that you found this tool useful!

I'll look into it. It does look quite greedy to use result.match(/\bimport\b/) for something this trivial. Just need to remember why it was added in the first place...

nomaed commented 6 years ago

@steveschmitt Any chance you can provide an example of a file that causes the exception? I added a bunch of "import" words in change b500d31 but it wasn't enough to see the issue.

nomaed commented 6 years ago

Closing due to inactivity + unable to reproduce