Skip to content
Permalink
Browse files

feat(context): remove deprecated prop context/connect

Remove legacy @prop({ context }) and connect options.
  • Loading branch information
adamdbradley committed Aug 4, 2020
1 parent 6cf3134 commit a87b738782b12e0110cd217bb2d522aa468c4d05
@@ -21,33 +21,17 @@ export const propDecoratorsToStatic = (
watchable: Set<string>,
newMembers: ts.ClassElement[],
) => {
const connect: any[] = [];
const context: any[] = [];
const properties = decoratedProps
.filter(ts.isPropertyDeclaration)
.map(prop => parsePropDecorator(diagnostics, typeChecker, prop, context, connect, watchable, newMembers))
.map(prop => parsePropDecorator(diagnostics, typeChecker, prop, watchable))
.filter(prop => prop != null);

if (properties.length > 0) {
newMembers.push(createStaticGetter('properties', ts.createObjectLiteral(properties, true)));
}
if (context.length > 0) {
newMembers.push(createStaticGetter('contextProps', convertValueToLiteral(context)));
}
if (connect.length > 0) {
newMembers.push(createStaticGetter('connectProps', convertValueToLiteral(connect)));
}
};

const parsePropDecorator = (
diagnostics: d.Diagnostic[],
typeChecker: ts.TypeChecker,
prop: ts.PropertyDeclaration,
context: any[],
connect: any[],
watchable: Set<string>,
newMembers: ts.ClassElement[],
) => {
const parsePropDecorator = (diagnostics: d.Diagnostic[], typeChecker: ts.TypeChecker, prop: ts.PropertyDeclaration, watchable: Set<string>) => {
const propDecorator = prop.decorators.find(isDecoratorNamed('Prop'));
if (propDecorator == null) {
return null;
@@ -56,23 +40,6 @@ const parsePropDecorator = (
const propName = prop.name.getText();
const propOptions = getPropOptions(propDecorator, diagnostics);

if (propOptions.context) {
context.push({
name: propName,
context: propOptions.context,
});
removeProp(prop, newMembers);
return null;
}
if (propOptions.connect) {
connect.push({
name: propName,
connect: propOptions.connect,
});
removeProp(prop, newMembers);
return null;
}

if (isMemberPrivate(prop)) {
const err = buildError(diagnostics);
err.messageText = 'Properties decorated with the @Prop() decorator cannot be "private" nor "protected". More info: https://stenciljs.com/docs/properties';
@@ -244,10 +211,3 @@ const isAny = (t: ts.Type) => {
}
return false;
};

const removeProp = (prop: ts.ClassElement, classElements: ts.ClassElement[]) => {
const index = classElements.findIndex(p => prop === p);
if (index >= 0) {
classElements.splice(index, 1);
}
};

This file was deleted.

@@ -95,10 +95,6 @@ export interface PropOptions {

/** @deprecated: "attr" has been deprecated, please use "attribute" instead. */
attr?: string;
/** @deprecated "context" has been deprecated. */
context?: string;
/** @deprecated "connect" has been deprecated, please use ES modules and/or dynamic imports instead. */
connect?: string;
/** @deprecated "reflectToAttr" has been deprecated, please use "reflect" instead. */
reflectToAttr?: boolean;
}

0 comments on commit a87b738

Please sign in to comment.
You can’t perform that action at this time.