Skip to content

Can't import plain d.ts files when transpileOnly=true #277

Closed
@ronzeidman

Description

@ronzeidman

This is actually the exact same issue as I have with awesome-typescript-loader: s-panferov/awesome-typescript-loader#225:

I have a shared module for shared interfaces between my server and my client. It contains several d.ts files with interfaces I share between my server and the UI. When I use ts-loader everything works as expected, when I use this ts-loader with transpileOnly=true I get:

ERROR in ./src/component.ts
Module not found: Error: Cannot resolve module 'shared/data' in ...src/component
 @ ./src/component.ts 12:26-73

The shared/data should be shared/data.d.ts but it doen't find it. If I add the d.ts explicitly I get this error:

ERROR in ./~/shared/data.d.ts
Module build failed: Error: Debug Failure. False expression: Output generation failed
    at Object.assert (node_modules\typescript\lib\typescript.js:2099:23)
    at Object.transpileModule (node_modules\typescript\lib\typescript.js:53173:18)
    at Object.loader (node_modules\ts-loader\index.js:421:49)
 @ ./src/component.ts 12:31-83

configuration:

'ts-loader?' + JSON.stringify({
                        transpileOnly: true,
                        configFileName: 'tsconfig.webpack.json'
                    })

config file:

{
    "compilerOptions": {
        "isolatedModules": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "module": "es6",
        "moduleResolution": "node",
        "noImplicitAny": false,
        "sourceMap": true,
        "target": "es5"
   },
   "files": ["src/component"]
}

Not critical workaround is to just change the files to ts files and transpile them to empty js files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions