Integrate the deprecations API into the spec/docs/protocol#3826
Integrate the deprecations API into the spec/docs/protocol#3826
Conversation
| /** | ||
| * Used for any user-emitted deprecation warnings. | ||
| */ | ||
| 'user-authored': Deprecation<'user-authored', 'user'>; |
There was a problem hiding this comment.
Do we have any testing in place that will catch if we add a deprecation to Dart Sass's enum that isn't listed here? If not, we should—I'm confident I'll make that mistake in the future 😅
There was a problem hiding this comment.
I've added a test to sass/sass-spec#1967 to ensure that Dart Sass and the embedded host don't expose any extra deprecations, which I think should be sufficient until we switch the deprecations list to a single source-of-truth (tracked in #3827)
js-api-doc/logger/index.d.ts
Outdated
| * | ||
| * @param message - The warning message. | ||
| * @param options.deprecation - Whether this is a deprecation warning. | ||
| * @param options.dperecationType - The type of deprecation this warning is |
There was a problem hiding this comment.
| * @param options.dperecationType - The type of deprecation this warning is | |
| * @param options.deprecationType - The type of deprecation this warning is |
js-api-doc/options.d.ts
Outdated
| * compilation, the compiler will ignore it instead. | ||
| * | ||
| * **Heads up!** The deprecated functionality you're depending on will | ||
| * eventually break |
| readonly patch: number; | ||
|
|
||
| /** | ||
| * Parses a version from a string. |
There was a problem hiding this comment.
This should probably document that it'll throw an error if the version can't be parsed.
spec/js-api/deprecations.d.ts.md
Outdated
| > Interfaces for user-declared importers that customize how Sass loads | ||
| > stylesheet dependencies. |
spec/js-api/deprecations.d.ts.md
Outdated
| export interface Deprecations { | ||
| ``` | ||
|
|
||
| #### `call-string` |
There was a problem hiding this comment.
I think we can get away without summaries here, since the individual specs say "emit a deprecation named ...".
There was a problem hiding this comment.
You could even get rid of the headers and have this all be a single code block.
| The compiler version this feature was fully removed in, making the deprecation | ||
| obsolete. |
There was a problem hiding this comment.
Probably worth mentioning that this is also implementation-dependent.
spec/js-api/deprecations.d.ts.md
Outdated
|
|
||
| The major version. | ||
|
|
||
| This must be a non-negative integer. |
There was a problem hiding this comment.
Since the spec is describing how an implementation should behave, it should define what happens if the number is negative rather than just declaring that it must not be.
There was a problem hiding this comment.
Done (updated the constructor spec to say the compiler should throw an error)
|
We should also explicitly specify what happens if the host refers to a deprecation ID that the compiler doesn't recognize or vice-versa. In the former case, I think the compiler should just throw an error, because the host should generally be responsible for ensuring it's speaking a compatible protocol to the compiler. In the latter case, I think it's fine to say that the warning is treated as a non-deprecation. |
js-api-doc/logger/index.d.ts
Outdated
| message: string, | ||
| options: { | ||
| deprecation: boolean; | ||
| deprecationType?: Deprecation; |
There was a problem hiding this comment.
We should probably type this explicitly so that deprecationType is set if and only if deprecation is true.
There was a problem hiding this comment.
Done. Is this the cleanest way to write this type, or is there some fancy Typescript feature to make deprecationType directly dependent on deprecation's value?
There was a problem hiding this comment.
I think this is the best option
spec/js-api/deprecations.d.ts.md
Outdated
| export interface Deprecations { | ||
| ``` | ||
|
|
||
| #### `call-string` |
There was a problem hiding this comment.
You could even get rid of the headers and have this all be a single code block.
| id: id; | ||
| ``` | ||
|
|
||
| The status of this deprecation. |
In the process of implementing this, I made two minor changes to the embedded protocol part of the proposal: (1) updating the field IDs since a new field got added to
CompileRequestsince the proposal was written and (2) adding adeprecation_typefield toLogEventso that the embedded host can pass that information to the JS API. Let me know if these changes are fine to just do here, or if I should factor them out into a separate PR.[skip dart-sass]
[skip sass-embedded]