awesome-typescript-loader icon indicating copy to clipboard operation
awesome-typescript-loader copied to clipboard

Path/BaseUrl does not generate type definitions correctly

Open dolanmiu opened this issue 7 years ago • 0 comments

I have tried to search for this, but couldn't find something similar, so I am asking 😄.

I am using awesome-typescript-loader to bundle my typescript project into one build/index.js file: https://github.com/dolanmiu/docx/blob/master/webpack.config.js#L7-L8

I am using compilerOptions.paths, and compilerOptions.baseUrl to enable me to import from root: https://github.com/dolanmiu/docx/blob/master/tsconfig.json#L14-L18

I also have declarations: true: https://github.com/dolanmiu/docx/blob/master/tsconfig.json#L11

However, when I use the library, I get the following error:

  • Notice how it is complaining about the root imports, such as file/media
  • If I delete all declarations, everything works fine
  • Something is wrong with the typings
  • I have tried using dts-bundle, doesn't work
../../docx/build/export/packer/express.d.ts(3,22): error TS2307: Cannot find module 'file'.
../../docx/build/file/document/body/section-properties/columns/columns-attributes.d.ts(1,39): error TS2307: Cannot find module 'file/xml-components'.
../../docx/build/file/document/body/section-properties/doc-grid/doc-grid-attributes.d.ts(1,39): error TS2307: Cannot find module 'file/xml-components'.
../../docx/build/file/document/body/section-properties/page-margin/page-margin-attributes.d.ts(1,39): error TS2307: Cannot find module 'file/xml-components'.
../../docx/build/file/document/body/section-properties/page-size/page-size-attributes.d.ts(1,39): error TS2307: Cannot find module 'file/xml-components'.
../../docx/build/file/document/body/section-properties/section-properties.d.ts(1,30): error TS2307: Cannot find module 'file/xml-components'.
../../docx/build/file/document/document.d.ts(1,28): error TS2307: Cannot find module 'file/media'.
../../docx/build/file/document/document.d.ts(2,30): error TS2307: Cannot find module 'file/xml-components'.

Screenshot of generated type definitions: image

the packer error is because of: https://github.com/s-panferov/awesome-typescript-loader/issues/432

Which I fixed with workaround.

Project:

https://github.com/dolanmiu/docx

dolanmiu avatar Jan 31 '18 21:01 dolanmiu