{"action":"created","issue":{"url":"https://api.github.com/repos/dsherret/ts-simple-ast/issues/122","repository_url":"https://api.github.com/repos/dsherret/ts-simple-ast","labels_url":"https://api.github.com/repos/dsherret/ts-simple-ast/issues/122/labels{/name}","comments_url":"https://api.github.com/repos/dsherret/ts-simple-ast/issues/122/comments","events_url":"https://api.github.com/repos/dsherret/ts-simple-ast/issues/122/events","html_url":"https://github.com/dsherret/ts-simple-ast/issues/122","id":271846742,"number":122,"title":"Import declaration problem with module containing typings","user":{"login":"anthonybriand","id":1897855,"avatar_url":"https://avatars1.githubusercontent.com/u/1897855?v=4","gravatar_id":"","url":"https://api.github.com/users/anthonybriand","html_url":"https://github.com/anthonybriand","followers_url":"https://api.github.com/users/anthonybriand/followers","following_url":"https://api.github.com/users/anthonybriand/following{/other_user}","gists_url":"https://api.github.com/users/anthonybriand/gists{/gist_id}","starred_url":"https://api.github.com/users/anthonybriand/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anthonybriand/subscriptions","organizations_url":"https://api.github.com/users/anthonybriand/orgs","repos_url":"https://api.github.com/users/anthonybriand/repos","events_url":"https://api.github.com/users/anthonybriand/events{/privacy}","received_events_url":"https://api.github.com/users/anthonybriand/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-11-07T14:17:45Z","updated_at":"2017-11-07T14:56:35Z","closed_at":null,"author_association":"NONE","body":"There seems to be a problem when I reference a class, an interface, a decorator from a module that is in node_modules and that contains an index.d.ts file.\r\n\r\nI create a SourceFileStructure, and when I add the namedImports referring to a module containing an index.d.ts file, it throws this error : \r\n```\r\n/Users/acidspike/Development/Sources/SCM/External/Harmony/Orm/node_modules/ts-simple-ast/dist/utils/EventContainer.js:53\r\n            finally { if (e_1) throw e_1.error; }\r\n                               ^\r\n\r\nError: Debug Failure. False expression.\r\n    at tryReuseStructureFromOldProgram (/Users/acidspike/Development/Sources/SCM/External/Harmony/Orm/node_modules/ts-simple-ast/node_modules/typescript/lib/typescript.js:72065:22)\r\n    at Object.createProgram (/Users/acidspike/Development/Sources/SCM/External/Harmony/Orm/node_modules/ts-simple-ast/node_modules/typescript/lib/typescript.js:71808:34)\r\n    at Program.reset (/Users/acidspike/Development/Sources/SCM/External/Harmony/Orm/node_modules/ts-simple-ast/dist/compiler/tools/Program.js:31:35)\r\n    at LanguageService.resetProgram (/Users/acidspike/Development/Sources/SCM/External/Harmony/Orm/node_modules/ts-simple-ast/dist/compiler/tools/LanguageService.js:112:26)\r\n    at LanguageService.addSourceFile (/Users/acidspike/Development/Sources/SCM/External/Harmony/Orm/node_modules/ts-simple-ast/dist/compiler/tools/LanguageService.js:252:14)\r\n    at /Users/acidspike/Development/Sources/SCM/External/Harmony/Orm/node_modules/ts-simple-ast/dist/GlobalContainer.js:21:40\r\n    at EventContainer.fire (/Users/acidspike/Development/Sources/SCM/External/Harmony/Orm/node_modules/ts-simple-ast/dist/utils/EventContainer.js:45:17)\r\n    at /Users/acidspike/Development/Sources/SCM/External/Harmony/Orm/node_modules/ts-simple-ast/dist/factories/CompilerFactory.js:136:49\r\n    at KeyValueCache.getOrCreate (/Users/acidspike/Development/Sources/SCM/External/Harmony/Orm/node_modules/ts-simple-ast/dist/utils/KeyValueCache.js:17:20)\r\n    at CompilerFactory.getSourceFile (/Users/acidspike/Development/Sources/SCM/External/Harmony/Orm/node_modules/ts-simple-ast/dist/factories/CompilerFactory.js:128:31)\r\n```\r\n\r\nBasic SourceFileStructure sample : \r\n```\r\n    {\r\n        classes: [\r\n            {\r\n                name: \"Aze\",\r\n                isExported: true,\r\n                decorators: [\r\n                    {\r\n                        name: \"Entity\",\r\n                        arguments: [\r\n                            `\r\n                            {\r\n                              \"connectionOptions\": {\r\n                                  \"connectionName\": \"default\"\r\n                              },\r\n                              \"name\": \"aze\"\r\n                          }\r\n                            `\r\n                        ]\r\n                    }\r\n                ],\r\n                properties: [],\r\n                methods: [],\r\n                \"extends\": \"BaseModel\"\r\n            }\r\n        ],\r\n        imports: [\r\n            {\r\n                namedImports: [\r\n                    {\r\n                        \"name\": \"Entity\"\r\n                    },\r\n                    {\r\n                        \"name\": \"BaseModel\"\r\n                    }\r\n                ],\r\n                moduleSpecifier: \"@harmony/orm\" //<-- this throw the error because the module contains an index.d.ts file\r\n            }\r\n        ]\r\n    }\r\n```\r\n\r\nOn the other hand the use of the @harmony/orm in a project (except AST) works correctly no error and typescript well understand the .d.ts"},"comment":{"url":"https://api.github.com/repos/dsherret/ts-simple-ast/issues/comments/342507660","html_url":"https://github.com/dsherret/ts-simple-ast/issues/122#issuecomment-342507660","issue_url":"https://api.github.com/repos/dsherret/ts-simple-ast/issues/122","id":342507660,"user":{"login":"dsherret","id":1609021,"avatar_url":"https://avatars0.githubusercontent.com/u/1609021?v=4","gravatar_id":"","url":"https://api.github.com/users/dsherret","html_url":"https://github.com/dsherret","followers_url":"https://api.github.com/users/dsherret/followers","following_url":"https://api.github.com/users/dsherret/following{/other_user}","gists_url":"https://api.github.com/users/dsherret/gists{/gist_id}","starred_url":"https://api.github.com/users/dsherret/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dsherret/subscriptions","organizations_url":"https://api.github.com/users/dsherret/orgs","repos_url":"https://api.github.com/users/dsherret/repos","events_url":"https://api.github.com/users/dsherret/events{/privacy}","received_events_url":"https://api.github.com/users/dsherret/received_events","type":"User","site_admin":false},"created_at":"2017-11-07T14:56:35Z","updated_at":"2017-11-07T14:56:35Z","author_association":"OWNER","body":"I'm not sure why that errors. It seems like TypeScript is having trouble creating a new program from the old one. On line 54 in [Program.ts}(https://github.com/dsherret/ts-simple-ast/blob/774bf701afb0bedfba61965bfb26e31e609d3b63/src/compiler/tools/Program.ts#L54), probably the last argument shouldn't bother to be passed in (`this._compilerObject`). That seems like just an optimization anyway.\r\n\r\nIt would be good to know why that \"debug failure\" happens internally in the TypeScript compiler though."}}
{"actor":{"display_login":"dsherret"}}