TypeStrong / TypeStrong/ts-loader
Enum values from d.ts files cause exception when build with transpileOnly=true
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 3.5k
- Forks
- 439
- Avg merge
- 17h 17m
- Merged PRs (30d)
- 2
Description
I tried to speed up build process. And transpileOnly=true works amazing!
Until I use any enum value in my code.
Example:
Definition file: definitions.d.ts
declare module MyModule {
export const enum MyEnum {
EnumValue1 = 0,
EnumValue2 = 1
}
}
TS file: example.ts
/// <reference path="./definitions.d.ts" />
console.log(MyModule.MyEnum.EnumValue1);
In runtime I get error: "MyModule is not defined"
Is there any way to force ts-loader NOT to ignore some specific *.d.ts files when I use transpileOnly=true? (something like transpileOnlyExcept...)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure from definitions.d.ts and example.ts with transpileOnly=true, then inspect how ts-loader handles referenced declaration files. Done means the example's enum access no longer fails at runtime with "MyModule is not defined", with the behavior covered by an appropriate loader test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100