Skip to content

Integrate the deprecations API into the spec/docs/protocol#3826

Merged
jathak merged 13 commits intomainfrom
deprecations
Apr 3, 2024
Merged

Integrate the deprecations API into the spec/docs/protocol#3826
jathak merged 13 commits intomainfrom
deprecations

Conversation

@jathak
Copy link
Member

@jathak jathak commented Apr 1, 2024

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 CompileRequest since the proposal was written and (2) adding a deprecation_type field to LogEvent so 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]

@jathak jathak requested a review from nex3 April 1, 2024 21:36
/**
* Used for any user-emitted deprecation warnings.
*/
'user-authored': Deprecation<'user-authored', 'user'>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 😅

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

*
* @param message - The warning message.
* @param options.deprecation - Whether this is a deprecation warning.
* @param options.dperecationType - The type of deprecation this warning is
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param options.dperecationType - The type of deprecation this warning is
* @param options.deprecationType - The type of deprecation this warning is

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

* compilation, the compiler will ignore it instead.
*
* **Heads up!** The deprecated functionality you're depending on will
* eventually break
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: period

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

readonly patch: number;

/**
* Parses a version from a string.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably document that it'll throw an error if the version can't be parsed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines +3 to +4
> Interfaces for user-declared importers that customize how Sass loads
> stylesheet dependencies.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy-paste error

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

export interface Deprecations {
```

#### `call-string`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can get away without summaries here, since the individual specs say "emit a deprecation named ...".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could even get rid of the headers and have this all be a single code block.

Comment on lines +256 to +257
The compiler version this feature was fully removed in, making the deprecation
obsolete.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably worth mentioning that this is also implementation-dependent.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


The major version.

This must be a non-negative integer.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done (updated the constructor spec to say the compiler should throw an error)

@nex3
Copy link
Contributor

nex3 commented Apr 2, 2024

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.

message: string,
options: {
deprecation: boolean;
deprecationType?: Deprecation;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably type this explicitly so that deprecationType is set if and only if deprecation is true.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the best option

@jathak jathak requested a review from nex3 April 3, 2024 02:07
export interface Deprecations {
```

#### `call-string`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could even get rid of the headers and have this all be a single code block.

id: id;
```

The status of this deprecation.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a header.

@jathak jathak merged commit ede7f25 into main Apr 3, 2024
@jathak jathak deleted the deprecations branch April 3, 2024 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants