Skip to content

Commit

Permalink
feat(context): remove deprecated prop context/connect
Browse files Browse the repository at this point in the history
Remove legacy @prop({ context }) and connect options.
  • Loading branch information
adamdbradley committed Aug 4, 2020
1 parent 6cf3134 commit a87b738
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 65 deletions.
44 changes: 2 additions & 42 deletions src/compiler/transformers/decorators-to-static/prop-decorator.ts
Expand Up @@ -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;
Expand All @@ -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';
Expand Down Expand Up @@ -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);
}
};
19 changes: 0 additions & 19 deletions src/compiler/transformers/test/parse-deprecated-props.spec.ts

This file was deleted.

4 changes: 0 additions & 4 deletions src/declarations/stencil-public-runtime.ts
Expand Up @@ -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;
}
Expand Down

0 comments on commit a87b738

Please sign in to comment.