π Search Terms
readonly import attributes, readonly ambient module, readonly pattern ambient module, module declaration attributes
π Version & Regression Information
β― Playground Link
N/A
π» Code
declare module "*.css" with { readonly type: "css" } {
const stylesheet: CSSStyleSheet;
export default stylesheet;
}
π Actual behavior
TypeScript accepts readonly on a property in an ambient moduleβs import attributes type.
Other modifiers such as private and declare are rejected by the ordinary type-member modifier checks, but readonly is valid on property signatures and is therefore accepted here.
It is unclear what readonly means for import attribute matching, declaration identity, specificity, or merging:
declare module "*.css" with { type: "css" } {
export const mutable: true;
}
declare module "*.css" with { readonly type: "css" } {
export const readonly: true;
}
Should these declarations describe identical import attributes types and merge, or should they be distinct?
π Expected behavior
readonly should be rejected in an import attributes type because these properties describe module-resolution attributes rather than mutable values, and the modifier has no apparent role in matching.
Alternatively, if readonly is intentionally supported, its effect on identity, merging, assignability, and specificity should be clarified.
Additional information about the issue
The import attributes grammar check added in #63931 validates property kind, optionality, name, and string-literal value type, but does not validate readonly.
π Search Terms
readonly import attributes, readonly ambient module, readonly pattern ambient module, module declaration attributes
π Version & Regression Information
β― Playground Link
N/A
π» Code
π Actual behavior
TypeScript accepts
readonlyon a property in an ambient moduleβs import attributes type.Other modifiers such as
privateanddeclareare rejected by the ordinary type-member modifier checks, butreadonlyis valid on property signatures and is therefore accepted here.It is unclear what
readonlymeans for import attribute matching, declaration identity, specificity, or merging:Should these declarations describe identical import attributes types and merge, or should they be distinct?
π Expected behavior
readonlyshould be rejected in an import attributes type because these properties describe module-resolution attributes rather than mutable values, and the modifier has no apparent role in matching.Alternatively, if
readonlyis intentionally supported, its effect on identity, merging, assignability, and specificity should be clarified.Additional information about the issue
The import attributes grammar check added in #63931 validates property kind, optionality, name, and string-literal value type, but does not validate
readonly.