Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] properly surface deprecation message #1562

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions packages/@glimmer/syntax/lib/traversal/traverse.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { LOCAL_DEBUG } from '@glimmer/local-debug-flags';
import { deprecate, unwrap } from '@glimmer/util';

import type * as ASTv1 from '../v1/api';
Expand Down Expand Up @@ -70,11 +69,9 @@ function getNodeHandler<N extends ASTv1.Node>(
): NodeTraversal<ASTv1.Node> | undefined {
if (nodeType === 'Template' || nodeType === 'Block') {
if (visitor.Program) {
if (LOCAL_DEBUG) {
deprecate(
`The 'Program' visitor node is deprecated. Use 'Template' or 'Block' instead (node was '${nodeType}') `
);
}
deprecate(
`The 'Program' visitor node is deprecated. Use 'Template' or 'Block' instead (node was '${nodeType}') `
);

return visitor.Program as NodeTraversal<ASTv1.Node>;
}
Expand Down
9 changes: 2 additions & 7 deletions packages/@glimmer/syntax/lib/v1/public-builders.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Dict, Nullable } from '@glimmer/interfaces';
import { LOCAL_DEBUG } from '@glimmer/local-debug-flags';
import { asPresentArray, assert, assign, deprecate, isPresentArray } from '@glimmer/util';

import type { SourceLocation, SourcePosition } from '../source/location';
Expand Down Expand Up @@ -66,19 +65,15 @@ function buildBlock(
let elseBlock: Nullable<ASTv1.Block> | undefined;

if (_defaultBlock.type === 'Template') {
if (LOCAL_DEBUG) {
deprecate(`b.program is deprecated. Use b.blockItself instead.`);
}
deprecate(`b.program is deprecated. Use b.blockItself instead.`);

defaultBlock = assign({}, _defaultBlock, { type: 'Block' }) as unknown as ASTv1.Block;
} else {
defaultBlock = _defaultBlock;
}

if (_elseBlock !== undefined && _elseBlock !== null && _elseBlock.type === 'Template') {
if (LOCAL_DEBUG) {
deprecate(`b.program is deprecated. Use b.blockItself instead.`);
}
deprecate(`b.program is deprecated. Use b.blockItself instead.`);

elseBlock = assign({}, _elseBlock, { type: 'Block' }) as unknown as ASTv1.Block;
} else {
Expand Down
Loading