// @deno-types="./foo.d.ts"
import * as foo from "./foo.js";
/// <reference types="./foo.d.ts" />
export const foo = "foo";
After supporting Triple-slash reference directive
It seems there is no reason to use @deno-types
We should follow the standard, not create another one
I disagree...
Modifying the source is not always an option. The new triple slash directive only works in JavaScript files, where you can easily modify the source. @deno-types is used in situations where modifying the JavaScript source is not feasible, but the importer of the module knows the location of the types.
The reason and logic for each of the ways is discussed in the manual: https://github.com/denoland/deno/blob/master/std/manual.md#using-external-type-definitions including why triple slash references don't work in TypeScript files.
@kitsonk
We can customize the function languageServiceHost.resolveTypeReferenceDirectives to ignore it in the typescript file
resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedTypeReferenceDirective | undefined)[];
class Host {
// ...
resolveTypeReferenceDirectives(typeDirectiveNames, containingFile) {
// if it's typescript file. then ignore it.
if (containingFile.endsWith('.ts')) {
return []
}
// resolve type file
return // ...
}
}
I think this should be feasible.
It works for me at vscode-deno
@axetroy we don't use the language service host in Deno.
The new triple slash directive only works in JavaScript files
That is by design. Adding it to TypeScript files does nothing for Deno, but it is important to provide the capability of "pointing" to types in JavaScript files. Is there something not working? Because adding what you are suggesting would not impact Deno at all.
Most helpful comment
I disagree...
Modifying the source is not always an option. The new triple slash directive only works in JavaScript files, where you can easily modify the source.
@deno-typesis used in situations where modifying the JavaScript source is not feasible, but the importer of the module knows the location of the types.The reason and logic for each of the ways is discussed in the manual: https://github.com/denoland/deno/blob/master/std/manual.md#using-external-type-definitions including why triple slash references don't work in TypeScript files.