question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiples Errors in main.d.ts

See original GitHub issue

Hi, I would like to use ts-simple-ast in an Angular projet. When I serve my program with ts-simple-ast imported I’ve got a bunch (around 40) of errors in main.d.ts that make the compilation fails. Like: node_modules/ts-simple-ast/dist/main.d.ts(3805,206): error TS1005: ';' expected. All the errors are in lines 3805 and 4433, and all about missing “;”, “(” and “)”.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
andreterroncommented, Jul 24, 2018

I was having this issue with the angular client, this is the postinstall script that worked for me, if anyone else runs into this:

import Project from "ts-simple-ast";

const mainFile = new Project().addExistingSourceFile("node_modules/ts-simple-ast/dist/main.d.ts");

mainFile.getTypeAliasOrThrow("NodePropertyToWrappedType").remove();
mainFile.addTypeAlias({
    name: "NodePropertyToWrappedType",
    typeParameters: [{name: "NodeType", constraint: "ts.Node"}, {name: "KeyType"}],
    type: "Node<NodeType>"
});

mainFile.getTypeAliasOrThrow("CompilerNodeToWrappedType").setType("Node<T>");

mainFile.save();

and in the package.json:

{
  "scripts": {
    "postinstall": "ts-node ./postinstall.ts"
  }
}
0reactions
andreterroncommented, Jul 24, 2018

Just as a FYI though, I wasn’t able to get it running on the browser. I unfortunately decided to change my API for now, and run it server-side.

Here are the current errors I’m facing, for reference (I manually replaced the actual folder for the {{project_folder}}):

WARNING in ./node_modules/ts-simple-ast/node_modules/typescript/lib/typescript.js
Module not found: Error: Can't resolve 'crypto' in '{{project_folder}}/node_modules/ts-simple-ast/node_modules/typescript/lib'

WARNING in ./node_modules/source-map-support/source-map-support.js
Module not found: Error: Can't resolve 'fs' in '{{project_folder}}/node_modules/source-map-support'

WARNING in ./node_modules/source-map-support/source-map-support.js
Module not found: Error: Can't resolve 'module' in '{{project_folder}}/node_modules/source-map-support'

WARNING in ./node_modules/minimatch/minimatch.js
Module not found: Error: Can't resolve 'path' in '{{project_folder}}/node_modules/minimatch'

ERROR in ./node_modules/@dsherret/to-absolute-glob/index.js
Module not found: Error: Can't resolve 'path' in '{{project_folder}}/node_modules/@dsherret/to-absolute-glob'

ERROR in ./node_modules/source-map-support/source-map-support.js
Module not found: Error: Can't resolve 'path' in '{{project_folder}}/node_modules/source-map-support'

ERROR in ./node_modules/ts-simple-ast/dist/fileSystem/DefaultFileSystemHost.js
Module not found: Error: Can't resolve 'path' in '{{project_folder}}/node_modules/ts-simple-ast/dist/fileSystem'

ERROR in ./node_modules/ts-simple-ast/dist/utils/FileUtils.js
Module not found: Error: Can't resolve 'path' in '{{project_folder}}/node_modules/ts-simple-ast/dist/utils'
Read more comments on GitHub >

github_iconTop Results From Across the Web

Visual Studio 2015 - errors on *.d.ts files in node_modules folder
Here's a sample of some of the errors I'm seeing in the file node_modules\@angular\common\src\directives\ng_class.d.ts:.
Read more >
Multiple errors from common/params when build with Typescript
Multiple similar errors from same folder: node_modules/firebase-functions/lib/common/params.d.ts:21:164 - error TS1005: ';' expected.
Read more >
multiple typescript errors in kendo-ui.d.ts - Telerik
After updating my project I get several errors about kendo-ui.d.ts. Typescript version 2.5. e.g..
Read more >
Documentation - Modules .d.ts - TypeScript
Comparing JavaScript to an example DTS. Common CommonJS Patterns. A module using CommonJS patterns uses module.exports to describe the exported values.
Read more >
TypeScript errors and how to fix them
A list of common TypeScript errors and how to fix them.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found