Skip to content

Commit

Permalink
Merge pull request #1562 from glimmerjs/proper-deprecate
Browse files Browse the repository at this point in the history
[BUGFIX] properly surface deprecation message
  • Loading branch information
chancancode committed Feb 7, 2024
2 parents dc76897 + 81ef8d4 commit d735053
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
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

0 comments on commit d735053

Please sign in to comment.