{"id":3930,"date":"2016-04-29T12:49:11","date_gmt":"2016-04-29T12:49:11","guid":{"rendered":"http:\/\/www.garysieling.com\/blog\/?p=3930"},"modified":"2016-04-29T12:49:11","modified_gmt":"2016-04-29T12:49:11","slug":"fixing-typescript-error-ts2666-exports-export-assignments-not-permitted-module-augmentations","status":"publish","type":"post","link":"https:\/\/www.garysieling.com\/blog\/fixing-typescript-error-ts2666-exports-export-assignments-not-permitted-module-augmentations\/","title":{"rendered":"Fixing Typescript error: TS2666: Exports and export assignments are not permitted in module augmentations"},"content":{"rendered":"<p>When I set up typings to run with typescript, I got stuck for a while trying to get imports from external libraries to work, with this error:<\/p>\n<pre>\ntypings\/main\/definitions\/react\/index.d.ts(2322,5): error TS2666: Exports and export assignments are not permitted in module augmentations.\n<\/pre>\n<p>This happens, for instance, trying to use React:<\/p>\n<pre lang=\"javascript\">\nimport * as React from 'react';\n\ninterface IMessage {\n  msg: String;\n}\n\nclass TestApp extends React.Component<IMessage, {}> {\n  public render(): Element {\n    return <div>test<\/div>;\n  }\n}\n<\/pre>\n<p>The reason for this is you need use a special incantation to install libraries:<\/p>\n<pre lang=\"bash\">\ntypings install react --ambient --save\n<\/pre>\n<p>In order for this to work without weird reference comments in the file, you also need a tsconfig.json:<\/p>\n<pre lang=\"javascript\">\n{\n    \"compilerOptions\": {\n    \"module\": \"commonjs\",\n    \"target\": \"es5\",\n    \"jsx\": \"react\",\n    \"sourceMap\": true,\n    \"emitDecoratorMetadata\": true,\n    \"experimentalDecorators\": true,\n    \"outDir\": \"dist\"\n    },\n    \"exclude\": [\n        \"node_modules\",\n    \"dist\",\n    \"node_modules\",\n    \"typings\"\n    ],\n    \"files\": [\n      \".\/app\/index.tsx\",\n      \".\/typings\/main.d.ts\"\n    ]\n}\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Fixing an import error with Typings + Typescript<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[9],"tags":[302,557,558],"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/3930"}],"collection":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/comments?post=3930"}],"version-history":[{"count":0,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/3930\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/media?parent=3930"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/categories?post=3930"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/tags?post=3930"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}