Emit `#nowarn` deprecated when something is `Obsolete`
Booksbaum opened this issue · 0 comments
@deprecated is translated into ObsoleteAttribute. When that type (or function or whatever) is used, the compiler emits a warning:
This construct is deprecated. This type is deprecated, please use ...
That's great when writing code. But this is a declaration file -> generated & describes the api to use.
But it's quite common in decl files that something deprecated is referenced in the same decl file somewhere else and that produces a warning:
(source: @types/vscode)
/**
* @deprecated This type is deprecated, please use [`MarkdownString`](#MarkdownString) instead.
*/
export type MarkedString = MarkdownString | string | { language: string; value: string };
export class Hover {
contents: MarkedString[];
}==>
[<Obsolete("This type is deprecated, please use [`MarkdownString`](#MarkdownString) instead.")>]
type MarkedString =
U4<MarkdownString, string, {| language: string; value: string |}>
type [<AllowNullLiteral>] Hover =
abstract contents: ResizeArray<MarkedString> with get, set
// ^^^^^^^^^^^^This construct is deprecated. This type is deprecated, please use
MarkdownStringinstead.
I think in such cases it's reasonable to emit #nowarn "0044" to disable deprecation warnings in that file. (It's only in this file -- if an obsolete type is used somewhere else the F# compiler still warns)
Ideal would be only if there's a usage of something obsolete, but easier probably to always output that nowarn if there's at least one ObsoleteAttribute in the generated file.