Skip to content

ts-loader error when working with `const enum` in definition file

Notifications You must be signed in to change notification settings

schmuli/ts-loader-enum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Const Enum Error

src/main.ts imports a const enum from common.d.ts. While tsc will replace the reference to the enum with the constant value, ts-loader doesn't, thereby causing the import to remain and webpack subsequently fails.

This only happens when using the transpileOnly option of ts-loader.

When using the isolatedModules options with tsc, error TS1209 will be displayed, which is similar, and might be related.

With tsc

npm run tsc

Completes successfully, without errors.

See output in dist/tsc.

With ts-loader

npm run webpack

Completes with an error:

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './common' in 'C:\Users\Schmulik\Documents\GitHub\schmuli\ts-loader-e
nums\src'
 @ ./src/main.ts 3:15-34

See output in dist/webpack.

With tsc --isolatedModules

npm run tsc:isolated

Compiles with an error:

error TS1209: Ambient const enums are not allowed when the '--isolatedModules' flag i
s provided.

See output in dist/tsc-isolated.

About

ts-loader error when working with `const enum` in definition file

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published