Closed
Description
Bug Report
See the last "or" condition:
TypeScript/src/compiler/parser.ts
Lines 10178 to 10180 in a70c409
Added as part of #51435 -- I think this was meant to be behind the --allowArbitraryExtensions
flag?
> function checkAmbient(fileUrl) {
const s = ts.createSourceFile(fileUrl, "");
console.log((s.flags & ts.NodeFlags.Ambient) === ts.NodeFlags.Ambient)
}
undefined
> ts.version
'5.0.2'
> checkAmbient("file:///V:/test.d.ts$22-28.ts")
true
> checkAmbient("file:///V:/test.d.tsblah.ts")
true
> ts.version
'4.9.5'
> checkAmbient("file:///V:/test.d.ts$22-28.ts")
false
> checkAmbient("file:///V:/test.d.ts22-28.ts")
false
Right now the only way I see to set if a file type is ambient is through the extension. Maybe the API needs a better way for consumers to tell it "this is a declaration file"? Maybe on CreateSourceFileOptions
? Then perhaps the code that does the arbitrary extension resolution could mark the declaration file that matches the arbitrary extension as ambient and the code here could be reverted.
🔎 Search Terms
extension declaration
🕗 Version & Regression Information
- 5.0.2
- I see this in main
🙁 Actual behavior
Declaration file specific errors
🙂 Expected behavior
No declaration file errors.